Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ssg.running flag #151

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ You may configure a custom routing style in `config/statamic/ssg.php`:
'pagination_route' => '{url}/{page_name}/{page_number}',
```

## Views

You can tell if the SSG was running from your templates by using the following check.

This is antlers, but the same principle will work for any conditional checking the `statamic.ssg.running` config key:

```
{{ if ! config:statamic:ssg:running }}
<meta name="csrf-token" content="{{ csrf_token }}">
{{ /if }}
```

## Post-generation callback

Expand Down
36 changes: 14 additions & 22 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="APP_URL" value="http://cool-runnings.com" />
<env name="APP_KEY" value="base64:QeU8nSJFKtBB3Y9SdxH0U4xH/1rsFd4zNfOLTeK/DUw=" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="APP_URL" value="http://cool-runnings.com"/>
<env name="APP_KEY" value="base64:QeU8nSJFKtBB3Y9SdxH0U4xH/1rsFd4zNfOLTeK/DUw="/>
</php>
</phpunit>
2 changes: 2 additions & 0 deletions src/Commands/StaticSiteGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function handle()
{
Partyline::bind($this);

config(['statamic.ssg.running' => true]);

if (config('statamic.editions.pro') && ! config('statamic.system.license_key')) {
$this->error('Statamic Pro is enabled but no site license was found.');
$this->warn('Please set a valid Statamic License Key in your .env file.');
Expand Down
2 changes: 2 additions & 0 deletions tests/Concerns/RunsGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ protected function generate($options = [])

$this->assertTrue($this->files->exists($this->destination));

$this->assertTrue(app('config')->get('statamic.ssg.running'));

return $this->getGeneratedFilesAtPath($this->destination);
}

Expand Down