Skip to content

Commit 4b8f83e

Browse files
committed
Remove 404 handler code
1 parent 3f3a5f0 commit 4b8f83e

7 files changed

Lines changed: 1 addition & 155 deletions

File tree

data/templates/errors/403.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66
{% block content %}
77
<h1>Forbidden</h1>
88
<p>The URI you have requested, <a href="{{ uri }}"><code>{{ uri }}</code></a>, might exist but the server has been instructed not to let you reach it.</p>
9-
{% if tool %}
10-
<h2>If you have reached this page from somewhere else...</h2>
11-
<p>This URI is managed by the <a href="{{ urlFor('tool', {'name': tool}) }}"><code>{{ tool }}</code></a> tool, maintained by {{ utils.printMaintainers( maintainers ) }}.</p>
12-
<p>Perhaps this content can only be accessed from the secret underground lair of the maintainers, or the link you've followed doesn't actually lead somewhere useful?</p>
13-
<p>If you're pretty sure this shouldn't be an error, you may wish to notify the tool's maintainers (they are listed above) about the error and how you ended up here.</p>
14-
<h2>If you maintain this tool</h2>
15-
<p>The error might be caused by incorrect permissions, or by the absence of an index file (this webserver does not list directory contents by default).</p>
16-
{% else %}
179
<p>Perhaps the webserver has temporarily become confused, or the link you've followed doesn't actually lead somewhere useful?</p>
1810
<p>If you're pretty sure this shouldn't be an error, you may wish to notify the <a href="{{ urlFor('tool', {'name': 'admin'}) }}">project administrators</a> about the error and how you ended up here.</p>
19-
{% endif %}
2011
{% endblock content %}

data/templates/errors/404.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
{% block content %}
77
<h1>Four hundred and four!</h1>
88
<p>The URI you have requested, <code>{{ uri }}</code>, doesn't seem to actually exist.</p>
9-
{% if tool %}
10-
<h2>If you have reached this page from somewhere else...</h2>
11-
<p>This URI is managed by the <a href="{{ urlFor('tool', {'name': tool}) }}"><code>{{ tool }}</code></a> tool, maintained by {{ utils.printMaintainers( maintainers ) }}.</p>
12-
<p>Perhaps its files are on vacation, or the link you've followed doesn't actually lead somewhere useful?</p>
13-
<p>You might want to look at the <a href="{{ urlFor('tools') }}">list of tools</a> to find what you were looking for. If you're pretty sure this shouldn't be an error, you may wish to notify the tool's maintainers (they are listed above) about the error and how you ended up here.</p>
14-
{% else %}
159
<p>Perhaps the webserver has temporarily become confused, or the link you've followed doesn't actually lead somewhere useful?</p>
1610
<p>You might want to look at the <a href="{{ urlFor('tools') }}">list of tools</a> to find what you were looking for. If you're pretty sure this shouldn't be an error, you may wish to notify the <a href="{{ urlFor('tool', {'name': 'admin'}) }}">project administrators</a> about the error and how you ended up here.</p>
17-
{% endif %}
1811
{% endblock content %}

data/templates/errors/500.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,5 @@
66
{% block content %}
77
<h1>Internal error</h1>
88
<p>The URI you have requested, <a href="{{ uri }}"><code>{{ uri }}</code></a>, appears to be non-functional at this time.</p>
9-
{% if tool %}
10-
<h2>If you have reached this page from somewhere else...</h2>
11-
<p>This URI is part of the <a href="{{ urlFor('tool', {'name': tool}) }}"><code>{{ tool }}</code></a> tool, maintained by {{ utils.printMaintainers( maintainers ) }}.</p>
12-
<p>Perhaps its magical script elves are temporarily ill, or the link you've followed doesn't actually lead somewhere useful?<p>
13-
<p>If you're pretty sure this shouldn't be an error, you may wish to notify the tool's maintainers (they are listed above) about the error and how you ended up here.</p>
14-
<h2>If you maintain this tool</h2>
15-
<p>The error might be caused by incorrect permission, or by an error in the script or CGI that was meant to execute here. Please check the error logs for your web service.</p>
16-
{% else %}
17-
<p>Perhaps the webserver has temporarily become confused, or the link you've followed doesn't actually lead somewhere useful?</p>
18-
<p>If you're pretty sure this shouldn't be an error, you may wish to notify the <a href="{{ urlFor('tool', {'name': 'admin'}) }}">project administrators</a> about the error and how you ended up here.</p>
19-
{% endif %}
9+
<p>You may wish to notify the <a href="{{ urlFor('tool', {'name': 'admin'}) }}">project administrators</a> about the error and how you ended up here.</p>
2010
{% endblock content %}

data/templates/errors/503.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66
{% block content %}
77
<h1>No webservice</h1>
88
<p>The URI you have requested, <a href="{{ uri }}"><code>{{ uri }}</code></a>, is not currently serviced.</p>
9-
{% if tool %}
109
<h2>If you have reached this page from somewhere else...</h2>
11-
<p>This URI is part of the <a href="{{ urlFor('tool', {'name': tool}) }}"><code>{{ tool }}</code></a> tool, maintained by {{ utils.printMaintainers( maintainers ) }}.</p>
12-
<p>That tool might not have a web interface, or it may currently be disabled.</p>
13-
<p>If you're pretty sure this shouldn't be an error, you may wish to notify the tool's maintainers (above) about the error and how you ended up here.</p>
14-
<h2>If you maintain this tool</h2>
15-
<p>You have not enabled a web service for your tool, or it has stopped working because of a fatal error. Please check the error logs of your web service.</p>
16-
{% else %}
17-
<h2>If you have reached this page from somewhere else...</h2>
18-
<p>This URI is not currently part of any tool.</p>
1910
<p>If you're pretty sure this shouldn't be an error, you may wish to notify the <a href="{{ urlFor('tool', {'name': 'admin'}) }}">project administrators</a> about the error and how you ended up here.</p>
20-
{% endif %}
2111
{% endblock content %}

src/App.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ protected function configureIoc( \Slim\Helper\Set $container ) {
105105
);
106106
} );
107107

108-
$container->singleton( 'tools', function ( $c ) {
109-
return new Tools( $c->cache, $c->log );
110-
} );
111-
112108
$container->singleton( 'toolinfo', function ( $c ) {
113109
return new Toolinfo(
114110
$c->settings['toolinfo.uri'], $c->cache, $c->log );

src/Pages/Error.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,9 @@ public function setTools( $tools ) {
4545
protected function handleGet( $errorCode, $notFoundHandler = false ) {
4646
$env = \Slim\Environment::getInstance();
4747
$uri = $env['HTTP_X_ORIGINAL_URI'] ?: $env['PATH_INFO'];
48-
if ( preg_match( '@^/([^/]+)/@', $uri, $match ) ) {
49-
$info = $this->tools->getToolInfo( $match[1] );
50-
51-
if ( $notFoundHandler && $info['name'] !== false ) {
52-
// Route was for a known tool
53-
if ( $uri === "/{$info['name']}" ) {
54-
// Redirect bare /<toolname> to /<toolname>
55-
$this->redirect( "/{$info['name']}/", 301 );
56-
} else {
57-
// The tool's service must be down. Send a 503 response.
58-
$errorCode = '503';
59-
}
60-
}
61-
} else {
62-
$info = [
63-
'name' => false,
64-
'maintainers' => []
65-
];
66-
}
6748

6849
$httpStatus = $notFoundHandler ? (int)$errorCode : 200;
6950
$this->view->set( 'uri', $uri );
70-
$this->view->set( 'tool', $info['name'] );
71-
$this->view->set( 'maintainers', $info['maintainers'] );
7251
$this->render( "errors/{$errorCode}.html", [], $httpStatus );
7352
}
7453
}

src/Tools.php

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)