Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/vendor/*

/panel/.yarn/*
/panel/assets/css/*
/panel/assets/js/*
/panel/logs/*
/panel/node_modules/*

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ composer create-project getformwork/formwork

Composer will create a `formwork` folder with a fresh ready-to-use Formwork installation.

To use the administration panel you need to build the [assets](#building-administration-panel-assets-with-yarn).

### Cloning from GitHub
If you want to get the currently worked master version, you can clone the GitHub repository and then install the dependencies with Composer.

Expand All @@ -55,6 +57,17 @@ cd formwork
composer install
```

3. Build the administration panel [assets](#building-administration-panel-assets-with-yarn).

### Building administration panel assets with Yarn
After installing with Composer or cloning from GitHub, you need to build the panel assets with [Yarn](https://yarnpkg.com/) by running the following commands:

```shell
cd panel
yarn install
yarn build
```

## Running Formwork server

You can test Formwork right away with the `serve` command, a customized wrapper of the [PHP Built-in web server](https://www.php.net/manual/en/features.commandline.webserver.php).
Expand Down
4 changes: 4 additions & 0 deletions formwork/views/errors/panel/assets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php include dirname(__DIR__) . '/partials/header.php' ?>
<h2>The administration panel is currently offline due to technical problems</h2>
<p>Required panel assets were not found. If you are the maintainer of this site, please run <code>cd panel; yarn install && yarn build</code></p>
<?php include dirname(__DIR__) . '/partials/footer.php' ?>
1 change: 1 addition & 0 deletions formwork/views/errors/partials/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
color: #7d7d7d;
font-family: SFMono-Regular, 'SF Mono', 'Cascadia Mono', 'Liberation Mono', Menlo, Consolas, monospace;
font-size: 0.875em;
text-wrap: nowrap;
}

.error-code {
Expand Down
Empty file added panel/assets/css/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion panel/assets/css/panel-dark.min.css

This file was deleted.

1 change: 0 additions & 1 deletion panel/assets/css/panel.min.css

This file was deleted.

Empty file added panel/assets/js/.gitkeep
Empty file.
43 changes: 0 additions & 43 deletions panel/assets/js/app.min.js

This file was deleted.

18 changes: 18 additions & 0 deletions panel/routes.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?php

use Formwork\App;
use Formwork\Config\Config;
use Formwork\Http\JsonResponse;
use Formwork\Http\RedirectResponse;
use Formwork\Http\Request;
use Formwork\Http\Response;
use Formwork\Http\ResponseStatus;
use Formwork\Panel\Panel;
use Formwork\Security\CsrfToken;
use Formwork\Site;
use Formwork\Translations\Translations;
use Formwork\Utils\FileSystem;
use Formwork\View\ViewFactory;

return [
'routes' => [
Expand Down Expand Up @@ -280,6 +283,21 @@
'types' => ['HTTP', 'XHR'],
],

'panel.checkAssets' => [
'action' => static function (Config $config, ViewFactory $viewFactory) {
$path = $config->get('system.panel.paths.assets');
$assets = ['css/panel.min.css', 'css/panel-dark.min.css', 'js/app.min.js'];

foreach ($assets as $asset) {
$assetPath = FileSystem::joinPaths($path, $asset);
if (!FileSystem::isFile($assetPath, assertExists: false)) {
$view = $viewFactory->make('errors.panel.assets');
return new Response($view->render(), ResponseStatus::InternalServerError);
}
}
},
],

'panel.register' => [
'action' => static function (Request $request, App $app, Site $site, Panel $panel) {
// Register panel if no user exists
Expand Down