Simplified error templates

This commit is contained in:
Alejandro Celaya 2018-11-18 20:04:12 +01:00
parent 64737b741b
commit e30f49a791
5 changed files with 50 additions and 61 deletions

View file

@ -19,9 +19,8 @@ class TranslatorExtension implements ExtensionInterface
$this->translator = $translator;
}
public function register(Engine $engine)
public function register(Engine $engine): void
{
$engine->registerFunction('translate', [$this->translator, 'translate']);
$engine->registerFunction('translate_plural', [$this->translator, 'translatePlural']);
}
}

View file

@ -27,10 +27,11 @@ class TranslatorExtensionTest extends TestCase
public function properFunctionsAreReturned()
{
$engine = $this->prophesize(Engine::class);
$registerFunction = $engine->registerFunction('translate', Argument::type('callable'))->will(function () {
});
$engine->registerFunction('translate', Argument::type('callable'))->shouldBeCalledOnce();
$engine->registerFunction('translate_plural', Argument::type('callable'))->shouldBeCalledOnce();
$this->extension->register($engine->reveal());
$funcs = $this->extension->register($engine->reveal());
$registerFunction->shouldHaveBeenCalledOnce();
}
}

View file

@ -1,19 +1,19 @@
<?php $this->layout('ShlinkCore::layout/default') ?>
<?php $this->start('title') ?>
<?= $this->translate('URL Not Found') ?>
<?= $this->translate('URL Not Found') ?>
<?php $this->end() ?>
<?php $this->start('stylesheets') ?>
<style>
p {margin-bottom: 20px;}
body {text-align: center;}
</style>
<style>
p {margin-bottom: 20px;}
body {text-align: center;}
</style>
<?php $this->end() ?>
<?php $this->start('main') ?>
<h1>404</h1>
<hr>
<h3><?= $this->translate('Page not found.') ?></h3>
<p><?= $this->translate('The page you requested could not be found.') ?></p>
<h1>404</h1>
<hr>
<h3><?= $this->translate('Page not found.') ?></h3>
<p><?= $this->translate('The page you requested could not be found.') ?></p>
<?php $this->end() ?>

View file

@ -1,25 +1,25 @@
<?php $this->layout('ShlinkCore::layout/default') ?>
<?php $this->start('title') ?>
<?= $this->e($status . ' ' . $reason) ?>
<?= $this->e($status . ' ' . $reason) ?>
<?php $this->end() ?>
<?php $this->start('stylesheets') ?>
<style>
p {margin-bottom: 20px;}
body {text-align: center;}
</style>
<style>
p {margin-bottom: 20px;}
body {text-align: center;}
</style>
<?php $this->end() ?>
<?php $this->start('main') ?>
<h1><?= $this->translate('Oops!') ?></h1>
<hr>
<h1><?= $this->translate('Oops!') ?></h1>
<hr>
<?php if ($status !== 404): ?>
<p><?= sprintf($this->translate('We encountered a %s %s error.'), $status, $reason) ?></p>
<?php else: ?>
<p><?= $this->translate('This short URL doesn\'t seem to be valid.') ?></p>
<p><?= $this->translate('Make sure you included all the characters, with no extra punctuation.') ?></p>
<?php endif; ?>
<?php if ($status !== 404): ?>
<p><?= sprintf($this->translate('We encountered a %s %s error.'), $status, $reason) ?></p>
<?php else: ?>
<p><?= $this->translate('This short URL doesn\'t seem to be valid.') ?></p>
<p><?= $this->translate('Make sure you included all the characters, with no extra punctuation.') ?></p>
<?php endif; ?>
<?php $this->end() ?>

View file

@ -1,42 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title><?= $this->section('title', '') ?> | URL shortener</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
<style>
body {padding-top: 60px;}
.app {display: flex; min-height: 100vh; flex-direction: column;}
.app-content {flex: 1;}
.app-footer p {margin-bottom: 20px;}
</style>
<?= $this->section('stylesheets', '') ?>
<title><?= $this->section('title', '') ?> | URL shortener</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<style>
body {padding-top: 60px;}
.app {display: flex; min-height: 100vh; flex-direction: column;}
.app-content {flex: 1;}
.app-footer p {margin-bottom: 20px;}
</style>
<?= $this->section('stylesheets', '') ?>
</head>
<body class="app">
<div class="app-content">
<main class="container">
<?= $this->section('main', '') ?>
</main>
<div class="app-content">
<main class="container">
<?= $this->section('main', '') ?>
</main>
</div>
<footer class="app-footer">
<div class="container">
<hr />
<p>&copy; <?= date('Y') ?> <a href="https://shlink.io">Shlink</a></p>
</div>
<footer class="app-footer">
<div class="container">
<hr />
<?php if ($this->section('footer')): ?>
<?= $this->section('footer') ?>
<?php else: ?>
<p>
&copy; <?= date('Y') ?> <a href="https://shlink.io">Shlink</a>
</p>
<?php endif; ?>
</div>
</footer>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<?= $this->section('javascript', '') ?>
</footer>
</body>
</html>