Skip to content

Commit

Permalink
Make templates dynamic so I don't forget
Browse files Browse the repository at this point in the history
Also officially bump up version to 3.0 🎉
  • Loading branch information
Eggbertx committed Jan 30, 2022
1 parent 8e706a3 commit e2339f9
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 9 deletions.
12 changes: 12 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ def build(debugging=False):
ldflags = " -ldflags=\"-X main.versionStr=" + version + "{}\""
build_cmd = "go build -v -asmflags=" + trimpath

print("Building error pages from templates")
with open("templates/404.html", "r") as tmpl404:
tmpl404str = tmpl404.read().strip()
with open("html/error/404.html", "w") as page404:
page404.write(tmpl404str.format(version))
with open("templates/5xx.html", "r") as tmpl5xx:
tmpl5xxStr = tmpl5xx.read().strip()
with open("html/error/500.html", "w") as page500:
page500.write(tmpl5xxStr.format(version=version, title="Error 500: Internal Server error"))
with open("html/error/502.html", "w") as page502:
page502.write(tmpl5xxStr.format(version=version, title="Error 502: Bad gateway"))

if debugging:
print("Building for", gcos, "with debugging symbols")
gcflags = gcflags.format(" -l -N")
Expand Down
4 changes: 2 additions & 2 deletions html/error/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<h1>404: File not found</h1>
<img src="./lol 404.gif" border="0" alt="">
<p>The requested file could not be found on this server.</p>
<hr><address>http://gochan.org powered by Gochan v3.0.0-beta</address>
<hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v3.0.0
</body>
</html>
</html>
10 changes: 5 additions & 5 deletions html/error/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<title>Error 500: Internal Server error</title>
</head>
<body>
<h1>500: Internal Server error</h1>
<img src="./derpy server.gif" border="0" alt="">
<p>The server encountered an error while trying to serve the page, and we apologize for the inconvenience. The <a href="https://en.wikipedia.org/wiki/Idiot">system administrator</a> will try to fix things as soon has he/she/it can.</p>
<hr><address>http://gochan.org powered by Gochan v3.0.0-beta</address>
<h1>Error 500: Internal Server error</h1>
<img src="./server500.gif" border="0" alt="">
<p>The server encountered an error while trying to serve the page, and we apologize for the inconvenience. The <a href="https://en.wikipedia.org/wiki/Idiot">system administrator</a> will try to fix things as soon they get around to it, whenever that is. Hopefully soon.</p>
<hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v3.0.0
</body>
</html>
</html>
12 changes: 12 additions & 0 deletions html/error/502.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Error 502: Bad gateway</title>
</head>
<body>
<h1>Error 502: Bad gateway</h1>
<img src="./server500.gif" border="0" alt="">
<p>The server encountered an error while trying to serve the page, and we apologize for the inconvenience. The <a href="https://en.wikipedia.org/wiki/Idiot">system administrator</a> will try to fix things as soon they get around to it, whenever that is. Hopefully soon.</p>
<hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v3.0.0
</body>
</html>
Binary file removed html/error/derpy server.gif
Binary file not shown.
Binary file added html/error/server500.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion sample-configs/gochan-fastcgi.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ server {
include fastcgi_params;
}


location ~ /\.ht {
deny all;
}
Expand Down
12 changes: 12 additions & 0 deletions templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Error 404: File not Found</title>
</head>
<body>
<h1>404: File not found</h1>
<img src="./lol 404.gif" border="0" alt="">
<p>The requested file could not be found on this server.</p>
<hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v{}
</body>
</html>
12 changes: 12 additions & 0 deletions templates/5xx.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
</head>
<body>
<h1>{title}</h1>
<img src="./server500.gif" border="0" alt="">
<p>The server encountered an error while trying to serve the page, and we apologize for the inconvenience. The <a href="https://en.wikipedia.org/wiki/Idiot">system administrator</a> will try to fix things as soon they get around to it, whenever that is. Hopefully soon.</p>
<hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v{version}
</body>
</html>
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0-beta
3.0.0

0 comments on commit e2339f9

Please sign in to comment.