Skip to content

Commit

Permalink
Statamic 5 Support (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed May 8, 2024
1 parent 3c21353 commit eaeabb6
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 71 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ jobs:

strategy:
matrix:
php: [8.0, 8.1, 8.2]
laravel: [9.*, 10.*]
php: [8.1, 8.2, 8.3]
laravel: [10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
include:
- os: windows-latest
php: 8.1
laravel: 9.*
php: 8.3
laravel: 10.*
stability: prefer-stable
- os: windows-latest
php: 8.1
laravel: 10.*
php: 8.3
laravel: 11.*
stability: prefer-stable
exclude:
- php: 8.0
laravel: 10.*
- php: 8.1
laravel: 11.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -52,7 +52,7 @@ jobs:

- name: Send Slack notification
uses: 8398a7/action-slack@v2
if: failure()
if: failure() && github.event_name == 'schedule'
with:
status: ${{ job.status }}
author_name: ${{ github.actor }}
Expand Down
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@
## Installation

Install the package using Composer:
You can install the Static Site Generator package with the following command:

```
composer require statamic/ssg
php please install:ssg
```

If you want or need to customize the way the site is generated, you can do so by publishing and modifying the config file with the following command:

```
php artisan vendor:publish --provider="Statamic\StaticSite\ServiceProvider"
```

The config file will be in `config/statamic/ssg.php`. This is optional and you can do it anytime.
The command will install the `statamic/ssg` package via Composer, optionally publish the configuration file and prompt you if you wish to install the `spatie/fork` package for running [multiple workers](#multiple-workers).


## Usage
Expand All @@ -29,6 +23,7 @@ php please ssg:generate

Your site will be generated into a directory which you can deploy however you like. See [Deployment Examples](#deployment-examples) below for inspiration.


### Multiple Workers

For improved performance, you may spread the page generation across multiple workers. This requires Spatie's [Fork](https://github.com/spatie/fork) package. Then you may specify how many workers are to be used. You can use as many workers as you have CPU cores.
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "statamic/ssg",
"type": "statamic-addon",
"description": "Static site generator for Statamic 3.",
"description": "Generate static sites with Statamic.",
"autoload": {
"psr-4": {
"Statamic\\StaticSite\\": "src"
Expand All @@ -15,7 +15,7 @@
"extra": {
"statamic": {
"name": "Static Site Generator",
"description": "Static Site Generator addon"
"description": "Generate static sites with Statamic."
},
"laravel": {
"providers": [
Expand All @@ -24,10 +24,10 @@
}
},
"require": {
"statamic/cms": "^4.0"
"statamic/cms": "^5.0"
},
"require-dev": {
"orchestra/testbench": "^7.0 || ^8.0"
"orchestra/testbench": "^8.0 || ^9.0"
},
"config": {
"allow-plugins": {
Expand Down
8 changes: 2 additions & 6 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Routing\Router;
use Illuminate\Support\Arr;
use League\Flysystem\Filesystem as Flysystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use Statamic\Contracts\Imaging\UrlBuilder;
use Statamic\Facades\Collection;
use Statamic\Facades\Entry;
Expand Down Expand Up @@ -120,13 +121,8 @@ public function bindGlide()

$directory = Arr::get($this->config, 'glide.directory');

// Determine which adapter to use for Flysystem 1.x or 3.x.
$localAdapter = class_exists($legacyAdapter = '\League\Flysystem\Adapter\Local')
? $legacyAdapter
: '\League\Flysystem\Local\LocalFilesystemAdapter';

$this->app['League\Glide\Server']->setCache(
new Flysystem(new $localAdapter($this->config['destination'].'/'.$directory))
new Flysystem(new LocalFilesystemAdapter($this->config['destination'].'/'.$directory))
);

$this->app->bind(UrlBuilder::class, function () use ($directory) {
Expand Down
4 changes: 3 additions & 1 deletion tests/Localized/GenerateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Filesystem\Filesystem;
use Statamic\Facades\Config;
use Statamic\Facades\Site;
use Tests\Concerns\RunsGeneratorCommand;
use Tests\TestCase;

Expand All @@ -18,8 +19,9 @@ protected function getEnvironmentSetUp($app)
parent::getEnvironmentSetUp($app);

$app['config']->set('statamic.editions.pro', true);
$app['config']->set('statamic.system.multisite', true);

$app['config']->set('statamic.sites.sites', [
Site::setSites([
'default' => [
'name' => 'English',
'locale' => 'en_US',
Expand Down
5 changes: 2 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ protected function resolveApplicationConfiguration($app)
parent::resolveApplicationConfiguration($app);

$configs = [
'assets', 'cp', 'forms', 'routes', 'static_caching',
'sites', 'stache', 'system', 'users',
'assets', 'cp', 'forms', 'routes', 'static_caching', 'stache', 'system', 'users',
];

foreach ($configs as $config) {
$app['config']->set("statamic.$config", require(__DIR__."/../vendor/statamic/cms/config/{$config}.php"));
$app['config']->set("statamic.$config", require (__DIR__."/../vendor/statamic/cms/config/{$config}.php"));
}
}

Expand Down

0 comments on commit eaeabb6

Please sign in to comment.