Skip to content

Commit 3bc1a0a

Browse files
TheoChevalierpascalchevrel
authored andcommitted
Add a 404 page, fixes #568
1 parent 0c18b9c commit 3bc1a0a

6 files changed

Lines changed: 37 additions & 6 deletions

File tree

app/inc/dispatcher.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<?php
22
namespace Transvision;
33

4+
if ($api_url) {
5+
$page = 'api';
6+
} else {
7+
$page = isset($urls[$url['path']]) ? $urls[$url['path']] : 'notfound';
8+
}
9+
410
$template = true;
5-
$page = $api_url ? 'api' : $urls[$url['path']];
611
$extra = null;
712
$experimental = false;
813
$show_title = true;
@@ -110,7 +115,9 @@
110115
$page_descr = 'Show potential errors related to missing or mispelled variables in your strings.';
111116
break;
112117
default:
113-
$controller = 'mainsearch';
118+
$view = '404';
119+
$page_title = '404: Page Not Found';
120+
$page_descr = '';
114121
break;
115122
}
116123

app/inc/router.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
// Include all valid urls here
4848
require_once __DIR__ . '/urls.php';
4949

50-
if (! array_key_exists($url['path'], $urls) && ! $api_url) {
51-
return false;
52-
}
53-
5450
// Always redirect to an url ending with slashes
5551
$temp_url = parse_url(str_replace(':', '%3A', $_SERVER['REQUEST_URI']));
5652
if (substr($temp_url['path'], -1) != '/') {

app/views/404.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
namespace Transvision;
3+
4+
http_response_code(400);
5+
?>
6+
<div id="pagecontent">
7+
<p>
8+
You can use the menu at the top to browse the available pages. If you think this URL should work and it’s a bug, please <a href="https://github.com/mozfr/transvision/issues/new">open an issue on GitHub</a>.
9+
</p>
10+
<img src="/img/404.png"/>
11+
</div>

tests/functional/pages.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
['unchanged/', 200, 'Display a list of strings identical', 'Locale'],
1818
['unlocalized/', 200, 'Display the list of the most common untranslated words', 'Occurrences'],
1919
['variables/', 200, 'Show potential errors related to', 'no errors found'],
20+
['foo/', 400, '404: Page Not Found', 'You can use the menu at the top'],
21+
['123/', 400, '404: Page Not Found', 'You can use the menu at the top'],
2022
];
2123

2224
$obj = new \pchevrel\Verif('Check public pages HTTP responses and content');

web/img/404.png

78.2 KB
Loading

web/style/transvision.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,21 @@ fieldset {
818818
text-align: right;
819819
}
820820

821+
/* 404 */
822+
#notfound #pagecontent {
823+
text-align: center;
824+
width: 90%;
825+
margin: auto;
826+
}
827+
828+
#notfound #pagecontent img {
829+
max-width: 800px;
830+
max-height: 379px;
831+
width: 100%;
832+
height: 100%;
833+
margin-top: 15px;
834+
}
835+
821836
/* Responsive */
822837

823838
@media only screen and (max-width: 850px) {

0 commit comments

Comments
 (0)