From 4602f5fefb7b58d9d4c0ce8d818c9713add825a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Brandenburg?= Date: Thu, 21 Dec 2023 22:21:45 +0100 Subject: [PATCH 1/2] let `make run` serve 404.html --- srv/server.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/srv/server.py b/srv/server.py index e831e75d0c..ce484b30b1 100644 --- a/srv/server.py +++ b/srv/server.py @@ -1,10 +1,24 @@ -import http.server -from http.server import HTTPServer, BaseHTTPRequestHandler +from http.server import SimpleHTTPRequestHandler import socketserver PORT = 8000 -Handler = http.server.SimpleHTTPRequestHandler + +class Handler(SimpleHTTPRequestHandler): + def send_error(self, code, message=None): + if code == 404: + with open("404.html", "rb") as err_msg: + page404 = err_msg.read() + + self.send_response(code) + self.send_header("Connection", "close") + self.send_header("Content-Type", "text/html") + self.send_header("Content-Length", str(len(page404))) + self.end_headers() + self.wfile.write(page404) + else: + SimpleHTTPRequestHandler.send_error(self, code, message) + Handler.extensions_map={ '.manifest': 'text/cache-manifest', From a6a03376dcbafc71596b5417c01c17359cd09fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Brandenburg?= Date: Thu, 21 Dec 2023 22:41:27 +0100 Subject: [PATCH 2/2] propagate hash fragment (=href anchor) when redirecting URLs When redirecting requests for stdlib or refman pages, propagate the URL's fragment identifer (the string following the '#' sign, if any). This is required for stdlib URLs so that links generated by coqdoc resolve to specifc identifiers, as intended. While at it, also preserve the fragment identifier in refman pages, in case someone, somewhere meant to link to specific parts of the reference manual. Fixes: https://github.com/coq/coq.github.io/issues/235 --- pages/404.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pages/404.html b/pages/404.html index 6876bb68ee..d56c943de3 100644 --- a/pages/404.html +++ b/pages/404.html @@ -1,6 +1,7 @@ <#include "incl/macros.html">