From e53ffc8d431ca75876d9155d1cdc4357552320a2 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 12 Oct 2017 10:03:14 +0200 Subject: [PATCH] Migrated templates to plates --- config/autoload/templates.global.php | 3 +++ module/Common/config/templates.config.php | 2 +- module/Core/templates/error/404.html.twig | 17 ------------- module/Core/templates/error/404.phtml | 19 ++++++++++++++ module/Core/templates/error/error.html.twig | 21 ---------------- module/Core/templates/error/error.phtml | 25 +++++++++++++++++++ .../{default.html.twig => default.phtml} | 16 ++++++------ .../src/Middleware/PathVersionMiddleware.php | 2 +- public/index.php | 6 ++--- 9 files changed, 61 insertions(+), 50 deletions(-) delete mode 100644 module/Core/templates/error/404.html.twig create mode 100644 module/Core/templates/error/404.phtml delete mode 100644 module/Core/templates/error/error.html.twig create mode 100644 module/Core/templates/error/error.phtml rename module/Core/templates/layout/{default.html.twig => default.phtml} (70%) diff --git a/config/autoload/templates.global.php b/config/autoload/templates.global.php index cf8e404b..24296d41 100644 --- a/config/autoload/templates.global.php +++ b/config/autoload/templates.global.php @@ -4,6 +4,9 @@ return [ 'templates' => [ 'extension' => 'phtml', + ], + + 'plates' => [ 'extensions' => [ // extension service names or instances ], diff --git a/module/Common/config/templates.config.php b/module/Common/config/templates.config.php index 37a6714d..eb25ef78 100644 --- a/module/Common/config/templates.config.php +++ b/module/Common/config/templates.config.php @@ -5,7 +5,7 @@ use Shlinkio\Shlink\Common\Template\Extension\TranslatorExtension; return [ - 'templates' => [ + 'plates' => [ 'extensions' => [ TranslatorExtension::class, ], diff --git a/module/Core/templates/error/404.html.twig b/module/Core/templates/error/404.html.twig deleted file mode 100644 index fe36f047..00000000 --- a/module/Core/templates/error/404.html.twig +++ /dev/null @@ -1,17 +0,0 @@ -{% extends 'core/layout/default.html.twig' %} - -{% block title %}{{ translate('URL Not Found') }}{% endblock %} - -{% block stylesheets %} - -{% endblock %} - -{% block content %} -

{{ translate('Oops!') }}

-
-

{{ translate('This short URL doesn\'t seem to be valid.') }}

-

{{ translate('Make sure you included all the characters, with no extra punctuation.') }}

-{% endblock %} diff --git a/module/Core/templates/error/404.phtml b/module/Core/templates/error/404.phtml new file mode 100644 index 00000000..369a168b --- /dev/null +++ b/module/Core/templates/error/404.phtml @@ -0,0 +1,19 @@ +layout('ShlinkCore::layout/default') ?> + +start('title') ?> + translate('URL Not Found') ?> +end() ?> + +start('stylesheets') ?> + +end() ?> + +start('main') ?> +

translate('Oops!') ?>

+
+

translate('This short URL doesn\'t seem to be valid.') ?>

+

translate('Make sure you included all the characters, with no extra punctuation.') ?>

+end() ?> diff --git a/module/Core/templates/error/error.html.twig b/module/Core/templates/error/error.html.twig deleted file mode 100644 index 5cb66c57..00000000 --- a/module/Core/templates/error/error.html.twig +++ /dev/null @@ -1,21 +0,0 @@ -{% extends 'core/layout/default.html.twig' %} - -{% block title %}{{ status }} {{ reason }}{% endblock %} - -{% block stylesheets %} - -{% endblock %} - -{% block content %} -

{{ translate('Oops!') }}

-
- {% if status != 404 %} -

{{ translate('We encountered a %s %s error.') | format(status, reason) }}

- {% else %} -

{{ translate('This short URL doesn\'t seem to be valid.') }}

-

{{ translate('Make sure you included all the characters, with no extra punctuation.') }}

- {% endif %} -{% endblock %} diff --git a/module/Core/templates/error/error.phtml b/module/Core/templates/error/error.phtml new file mode 100644 index 00000000..6d22ed9f --- /dev/null +++ b/module/Core/templates/error/error.phtml @@ -0,0 +1,25 @@ +layout('ShlinkCore::layout/default') ?> + +start('title') ?> + e($status . ' ' . $reason) ?> +end() ?> + +start('stylesheets') ?> + +end() ?> + +start('main') ?> +

translate('Oops!') ?>

+
+ + +

translate('We encountered a %s %s error.'), $status, $reason) ?>

+ +

translate('This short URL doesn\'t seem to be valid.') ?>

+

translate('Make sure you included all the characters, with no extra punctuation.') ?>

+ +end() ?> + diff --git a/module/Core/templates/layout/default.html.twig b/module/Core/templates/layout/default.phtml similarity index 70% rename from module/Core/templates/layout/default.html.twig rename to module/Core/templates/layout/default.phtml index 4b405c5b..802bf466 100644 --- a/module/Core/templates/layout/default.html.twig +++ b/module/Core/templates/layout/default.phtml @@ -3,7 +3,7 @@ - {% block title %}{% endblock %} | URL shortener + <?= $this->section('title', '') ?> | URL shortener @@ -13,28 +13,30 @@ .app-content {flex: 1;} .app-footer p {margin-bottom: 20px;} - {% block stylesheets %}{% endblock %} + section('stylesheets', '') ?>
- {% block content %}{% endblock %} + section('main', '') ?>
- {% block javascript %}{% endblock %} + section('javascript', '') ?> diff --git a/module/Rest/src/Middleware/PathVersionMiddleware.php b/module/Rest/src/Middleware/PathVersionMiddleware.php index 3220bfaf..b247f50c 100644 --- a/module/Rest/src/Middleware/PathVersionMiddleware.php +++ b/module/Rest/src/Middleware/PathVersionMiddleware.php @@ -37,7 +37,7 @@ class PathVersionMiddleware implements MiddlewareInterface $uri = $request->getUri(); $path = $uri->getPath(); - // If the path does not begin with the version number, prepend v1 by default for retrocompatibility purposes + // If the path does not begin with the version number, prepend v1 by default for BC compatibility purposes if (strpos($path, '/v') !== 0) { $parts = explode('/', $path); // Remove the first empty part and the diff --git a/public/index.php b/public/index.php index 6b310943..3f2c0f84 100644 --- a/public/index.php +++ b/public/index.php @@ -1,9 +1,9 @@ get(Application::class); -$app->run(); +$app = $container->get(Application::class)->run();