added layout and translation to error pages #100 (#101)

This commit is contained in:
Kevin Papst
2018-01-21 22:53:10 +01:00
committed by GitHub
parent 4cbc5391c0
commit 6ae9bc4df5
13 changed files with 186 additions and 98 deletions

View File

@@ -90,12 +90,13 @@ APP_ENV=dev
APP_SECRET=some_random_secret_string_for_your_installation
```
Now create the database schemas:
Now create the database schemas and warm up the cache:
```bash
$ bin/console doctrine:schema:create
$ bin/console cache:warmup --env=prod
```
And finally create your first user:
Finally create your first user:
```bash
$ bin/console kimai:create-user username password admin@example.com ROLE_SUPER_ADMIN

28
composer.lock generated
View File

@@ -2508,24 +2508,24 @@
},
{
"name": "symfony/flex",
"version": "v1.0.61",
"version": "v1.0.66",
"source": {
"type": "git",
"url": "https://github.com/symfony/flex.git",
"reference": "f872f8faccf5ff95678e1e428f460a333ba1e5d0"
"reference": "b366e902710c8dc8d8be97ed8d64ef574d9bffcb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/flex/zipball/f872f8faccf5ff95678e1e428f460a333ba1e5d0",
"reference": "f872f8faccf5ff95678e1e428f460a333ba1e5d0",
"url": "https://api.github.com/repos/symfony/flex/zipball/b366e902710c8dc8d8be97ed8d64ef574d9bffcb",
"reference": "b366e902710c8dc8d8be97ed8d64ef574d9bffcb",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.1",
"composer-plugin-api": "^1.0",
"php": "^7.0"
},
"require-dev": {
"composer/composer": "^1.4",
"composer/composer": "^1.0.2",
"symfony/phpunit-bridge": "^3.2.8"
},
"type": "composer-plugin",
@@ -2550,7 +2550,7 @@
"email": "fabien.potencier@gmail.com"
}
],
"time": "2018-01-12T13:09:44+00:00"
"time": "2018-01-21T09:15:48+00:00"
},
{
"name": "symfony/form",
@@ -3984,21 +3984,21 @@
},
{
"name": "symfony/thanks",
"version": "v1.0.1",
"version": "v1.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/thanks.git",
"reference": "b637913a92664571afd1067fc645ecb30c9cf5b2"
"reference": "8c12bbe4baabcb8e640efaaaab40e3a4497c9fb4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/thanks/zipball/b637913a92664571afd1067fc645ecb30c9cf5b2",
"reference": "b637913a92664571afd1067fc645ecb30c9cf5b2",
"url": "https://api.github.com/repos/symfony/thanks/zipball/8c12bbe4baabcb8e640efaaaab40e3a4497c9fb4",
"reference": "8c12bbe4baabcb8e640efaaaab40e3a4497c9fb4",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.1",
"php": "^5.5.9|^7.0.8"
"composer-plugin-api": "^1.0",
"php": "^5.5.9|^7.0.0"
},
"type": "composer-plugin",
"extra": {
@@ -4023,7 +4023,7 @@
}
],
"description": "Give thanks (in the form of a GitHub ⭐) to your fellow PHP package maintainers (not limited to Symfony components)!",
"time": "2018-01-03T09:30:52+00:00"
"time": "2018-01-19T16:12:41+00:00"
},
{
"name": "symfony/translation",

View File

@@ -1,6 +1,6 @@
_errors:
resource: '@TwigBundle/Resources/config/routing/errors.xml'
prefix: /_error
prefix: /{_locale}/_error
requirements:
_locale: '%app_locales%'
defaults:

View File

@@ -161,7 +161,7 @@ class CustomerController extends AbstractController
protected function getToolbarForm(CustomerQuery $query)
{
return $this->createForm(CustomerToolbarForm::class, $query, [
'action' => $this->generateUrl('admin_customer_paginated', [
'action' => $this->generateUrl('admin_customer', [
'page' => $query->getPage(),
]),
'method' => 'GET',

View File

@@ -165,7 +165,7 @@ class ProjectController extends AbstractController
protected function getToolbarForm(ProjectQuery $query)
{
return $this->createForm(ProjectToolbarForm::class, $query, [
'action' => $this->generateUrl('admin_project_paginated', [
'action' => $this->generateUrl('admin_project', [
'page' => $query->getPage(),
]),
'method' => 'GET',

View File

@@ -104,7 +104,7 @@ class UserController extends AbstractController
protected function getToolbarForm(UserQuery $query)
{
return $this->createForm(UserToolbarForm::class, $query, [
'action' => $this->generateUrl('admin_user_paginated', [
'action' => $this->generateUrl('admin_user', [
'page' => $query->getPage(),
]),
'method' => 'GET',

View File

@@ -54,6 +54,10 @@ class NavbarShowUserSubscriber implements EventSubscriberInterface
*/
public function onShowUser(ShowUserEvent $event)
{
if ($this->storage->getToken() === null) {
return;
}
/* @var $myUser User */
$myUser = $this->storage->getToken()->getUser();

View File

@@ -7,22 +7,33 @@
your application from some errors.
See http://symfony.com/doc/current/cookbook/controller/error_pages.html
#}
<!DOCTYPE html>
<html>
<head>
<meta charset="{{ _charset }}" />
<title>{{ 'http_error.title'|trans({}, 'exceptions') }}: {{ status_text }}</title>
</head>
<body>
{% extends 'base.html.twig' %}
{% set errorTitleKey = "http_error_#{status_code}.description" %}
{% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% if errorTitleKey == errorTitleTrans %}
{% set errorTitleKey = 'http_error.description' %}
{% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% endif %}
{% block body_id 'error' %}
{% set errorMessageKey = "http_error_#{status_code}.suggestion" %}
{% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% if errorMessageKey == errorMessageTrans %}
{% set errorMessageKey = 'http_error.suggestion' %}
{% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% endif %}
{% block main %}
<h1 class="text-danger">{{ 'http_error.name'|trans({ '%status_code%': status_code }) }}</h1>
<h1>{{ errorTitleTrans }}</h1>
<h2>{{ status_code }}: {{ status_text }}</h2>
<p class="lead">
{{ 'http_error.description'|trans({ '%status_code%': status_code }) }}
</p>
<p>
{{ 'http_error.suggestion'|trans({ '%url%': path('homepage') })|raw }}
</p>
{% endblock %}
{% block sidebar %}
{{ parent() }}
{% endblock %}
<div>
{{ errorMessageTrans }}
</div>
</body>
</html>

View File

@@ -1,28 +1,31 @@
{#
This template is used to render errors of type HTTP 403 (Forbidden)
This is the simplest way to customize error pages in Symfony applications.
In case you need it, you can also hook into the internal exception handling
made by Symfony. This allows you to perform advanced tasks and even recover
your application from some errors.
See http://symfony.com/doc/current/cookbook/controller/error_pages.html
#}
{% extends 'base.html.twig' %}
{% block body_id 'error' %}
{% block page_title %}{{ 'http_error.title'|trans({}, 'exceptions') }}{% endblock %}
{% block page_subtitle %}{{ status_code }}{% endblock %}
{% block main %}
<h1 class="text-danger"><i class="fa fa-unlock-alt"></i> {{ 'http_error.name'|trans({ '%status_code%': 403 }) }}</h1>
{% set errorTitleKey = "http_error_#{status_code}.description" %}
{% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% if errorTitleKey == errorTitleTrans %}
{% set errorTitleKey = 'http_error.description' %}
{% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% endif %}
<p class="lead">
{{ 'http_error_403.description'|trans }}
</p>
<p>
{{ 'http_error_403.suggestion'|trans }}
</p>
{% set errorMessageKey = "http_error_#{status_code}.suggestion" %}
{% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% if errorMessageKey == errorMessageTrans %}
{% set errorMessageKey = 'http_error.suggestion' %}
{% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% endif %}
<div class="error-page">
<h2 class="headline text-yellow"> {{ status_code }}</h2>
<div class="error-content">
<h3><i class="fa fa-unlock-alt text-yellow"></i> {{ errorTitleTrans }}</h3>
<p>{{ errorMessageTrans }}</p>
</div>
</div>
{% endblock %}
{% block sidebar %}
{{ parent() }}
{% endblock %}
{% block avanzu_control_sidebar %}{% endblock %}
{% block avanzu_navbar_control_sidebar_toggle %}{% endblock %}

View File

@@ -1,28 +1,31 @@
{#
This template is used to render errors of type HTTP 404 (Not Found)
This is the simplest way to customize error pages in Symfony applications.
In case you need it, you can also hook into the internal exception handling
made by Symfony. This allows you to perform advanced tasks and even recover
your application from some errors.
See http://symfony.com/doc/current/cookbook/controller/error_pages.html
#}
{% extends 'base.html.twig' %}
{% block body_id 'error' %}
{% block page_title %}{{ 'http_error.title'|trans({}, 'exceptions') }}{% endblock %}
{% block page_subtitle %}{{ status_code }}{% endblock %}
{% block main %}
<h1 class="text-danger">{{ 'http_error.name'|trans({ '%status_code%': 404 }) }}</h1>
{% set errorTitleKey = "http_error_#{status_code}.description" %}
{% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% if errorTitleKey == errorTitleTrans %}
{% set errorTitleKey = 'http_error.description' %}
{% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% endif %}
<p class="lead">
{{ 'http_error_404.description'|trans }}
</p>
<p>
{{ 'http_error_404.suggestion'|trans({ '%url%': path('homepage') })|raw }}
</p>
{% set errorMessageKey = "http_error_#{status_code}.suggestion" %}
{% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% if errorMessageKey == errorMessageTrans %}
{% set errorMessageKey = 'http_error.suggestion' %}
{% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'exceptions') %}
{% endif %}
<div class="error-page">
<h2 class="headline text-yellow"> {{ status_code }}</h2>
<div class="error-content">
<h3><i class="fa fa-unlock-alt text-yellow"></i> {{ errorTitleTrans }}</h3>
<p>{{ errorMessageTrans }}</p>
</div>
</div>
{% endblock %}
{% block sidebar %}
{{ parent() }}
{% endblock %}
{% block avanzu_control_sidebar %}{% endblock %}
{% block avanzu_navbar_control_sidebar_toggle %}{% endblock %}

View File

@@ -7,22 +7,4 @@
your application from some errors.
See http://symfony.com/doc/current/cookbook/controller/error_pages.html
#}
{% extends 'base.html.twig' %}
{% block body_id 'error' %}
{% block main %}
<h1 class="text-danger">{{ 'http_error.name'|trans({ '%status_code%': 500 }) }}</h1>
<p class="lead">
{{ 'http_error_500.description'|trans }}
</p>
<p>
{{ 'http_error_500.suggestion'|trans({ '%url%': path('homepage') })|raw }}
</p>
{% endblock %}
{% block sidebar %}
{{ parent() }}
{% endblock %}
{% extends '@Twig/Exception/error.html.twig' %}

View File

@@ -6,6 +6,48 @@
<source>access.denied</source>
<target>Der Zugriff wurde verweigert</target>
</trans-unit>
<trans-unit id="stacktrace">
<source>stacktrace</source>
<target>Das Problem ist hier passiert</target>
</trans-unit>
<trans-unit id="http_error.title">
<source>http_error.title</source>
<target>Fehler</target>
</trans-unit>
<trans-unit id="http_error.description">
<source>http_error.description</source>
<target>Oops! Ein Fehler ist aufgetreten.</target>
</trans-unit>
<trans-unit id="http_error.suggestion">
<source>http_error.suggestion</source>
<target>
Ein unerwarteter Fehler ist aufgetreten.
Möglicherweise haben Sie einen Bug gefunden, daher kontaktieren Sie bitte ihren Administrator
wenn der Fehler nach einem erneuten Versuch immer noch vorhanden sein sollte.
</target>
</trans-unit>
<trans-unit id="http_error_404.description">
<source>http_error_404.description</source>
<target>Oops! Seite wurde nicht gefunden.</target>
</trans-unit>
<trans-unit id="http_error_404.suggestion">
<source>http_error_404.suggestion</source>
<target>
Wir konnten die angeforderte Seite leider nicht finden.
Bitte wechseln Sie zurück zu ihrem Dashboard und starten von vorne.
</target>
</trans-unit>
<trans-unit id="http_error_403.description">
<source>http_error_403.description</source>
<target>Diese Seite ist geschützt.</target>
</trans-unit>
<trans-unit id="http_error_403.suggestion">
<source>http_error_403.suggestion</source>
<target>
Entschuldigung, Sie haben nicht genügend Berechtigungen um diese Seite zu sehen.
Bitte sprechen Sie mit ihrem Administrator wenn Sie dies für einen Fehler halten.
</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@@ -6,6 +6,48 @@
<source>access.denied</source>
<target>Access was denied</target>
</trans-unit>
<trans-unit id="stacktrace">
<source>stacktrace</source>
<target>The problem occured here</target>
</trans-unit>
<trans-unit id="http_error.title">
<source>http_error.title</source>
<target>Error</target>
</trans-unit>
<trans-unit id="http_error.description">
<source>http_error.description</source>
<target>Oops! An error occured.</target>
</trans-unit>
<trans-unit id="http_error.suggestion">
<source>http_error.suggestion</source>
<target>
An unexpected error occured, please try again.
You may have found a bug, so please contact your administrator if the problem
doesn't go away after you tried it again.
</target>
</trans-unit>
<trans-unit id="http_error_404.description">
<source>http_error_404.description</source>
<target>Oops! Page not found.</target>
</trans-unit>
<trans-unit id="http_error_404.suggestion">
<source>http_error_404.suggestion</source>
<target>
We could not find the page you were looking for.
Meanwhile, you may return to your dashboard and start over.
</target>
</trans-unit>
<trans-unit id="http_error_403.description">
<source>http_error_403.description</source>
<target>This page is restricted.</target>
</trans-unit>
<trans-unit id="http_error_403.suggestion">
<source>http_error_403.suggestion</source>
<target>
Sorry, but you do not have sufficient permissions to see this page.
Please talk to your administrator if you think this is an error.
</target>
</trans-unit>
</body>
</file>
</xliff>