Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give helpful 404 pages with hints how to resolve the underlying issues #1663

Merged
1 commit merged into from Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions resources/default-settings/nginx.default
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,51 @@ server {
server_name _;

location / {
location = /index.html {
error_page 404 = @buildwebui;
log_not_found off;
}
location = / {
error_page 404 = @buildwebui;
log_not_found off;
}
try_files $uri $uri/ =404;
}

location /docs {
alias /home/pi/RPi-Jukebox-RFID/docs/sphinx/_build/html/;
index index.html index.htm;
}

location /docs {
root /home/pi/RPi-Jukebox-RFID/docs/sphinx/_build/html;
try_files $uri $uri/ =404;
location = /docs/index.html {
error_page 404 = @runsphinx;
log_not_found off;
}
location = /docs {
error_page 404 = @runsphinx;
log_not_found off;
}
location = /docs/ {
error_page 404 = @runsphinx;
log_not_found off;
}

}

location @runsphinx {
root /home/pi/RPi-Jukebox-RFID/resources/html;
try_files /runsphinx.html =404;
internal;
}

location @buildwebui {
root /home/pi/RPi-Jukebox-RFID/resources/html;
try_files /runbuildui.html =404;
internal;
}

error_page 404 = /404.html;
location /404.html {
root /home/pi/RPi-Jukebox-RFID/resources/html;
internal;
}
}
22 changes: 22 additions & 0 deletions resources/html/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Phoniebox: File not found -- 404</title>
<style>
<!--
body {font-family: arial,sans-serif}
img { border:none; }
//-->
</style>
</head>
<body>
<blockquote>
<h2>Ups! Requested file not found.</h2>
<p>Why not try again from the top-level of
<ul>
<li><a href="/index.html">Web User Interface</a></li>
<li><a href="/docs/index.html">Documentation</a></li>
</ul>
</blockquote>
</body>
</html>
24 changes: 24 additions & 0 deletions resources/html/runbuildui.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Phoniebox Web UI not found: please re-build Web UI</title>
<style>
<!--
body {font-family: arial,sans-serif}
img { border:none; }
//-->
</style>
</head>
<body>
<blockquote>
<h2>Ups! Looks like your Web UI has not been build!</h2>
<p>No reason to panic. Please run through the following steps:
<ul>
<li>cd /home/pi/RPi-Jukebox-RFID/src/webapp</li>
<li>./run_rebuild.sh</li>
<li>Reload this page</li>
</ul>
<p>In case of trouble when building the Web UI, consult the <a href="/docs/index.html">documentation</a>!
</blockquote>
</body>
</html>
24 changes: 24 additions & 0 deletions resources/html/runsphinx.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Phoniebox documentation not found: please build documentation</title>
<style>
<!--
body {font-family: arial,sans-serif}
img { border:none; }
//-->
</style>
</head>
<body>
<blockquote>
<h2>Ups! Looks like your documentation has not been build!</h2>
<p>No reason to panic. Please run through the following steps:
<ul>
<li>cd /home/pi/RPi-Jukebox-RFID</li>
<li>./run_sphinx.sh -c</li>
<li>Reload this page</li>
</ul>
<p>Or check out the <a href="https://rpi-jukebox-rfid.readthedocs.io/">online documentation</a> at Read The Docs.
</blockquote>
</body>
</html>