Skip to content

Commit

Permalink
Merge pull request #1663 from ChisSoc/future3/html-404
Browse files Browse the repository at this point in the history
Give helpful 404 pages with hints how to resolve the underlying issues
  • Loading branch information
Chris authored Dec 5, 2021
2 parents 44528a1 + 57c39b1 commit 4b587d2
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 4 deletions.
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>

0 comments on commit 4b587d2

Please sign in to comment.