]> git.ipfire.org Git - ipfire.org.git/commitdiff
wiki: Add custom 404 page
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 12 Nov 2018 18:39:51 +0000 (18:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 12 Nov 2018 18:39:51 +0000 (18:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/wiki/404.html [new file with mode: 0644]
src/web/wiki.py

index 08ef93a844f42a664c272abfbf95c5eb47864dc3..bb8f9f8d1249e8608cf339d6b952a8be68ba438b 100644 (file)
@@ -254,6 +254,7 @@ templates_static_DATA = \
 templates_staticdir = $(templatesdir)/static
 
 templates_wiki_DATA = \
+       src/templates/wiki/404.html \
        src/templates/wiki/base.html \
        src/templates/wiki/page.html \
        src/templates/wiki/recent-changes.html
diff --git a/src/templates/wiki/404.html b/src/templates/wiki/404.html
new file mode 100644 (file)
index 0000000..b09d76f
--- /dev/null
@@ -0,0 +1,25 @@
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Page Not Found") }}{% end block %}
+
+{% block container %}
+    <section>
+        <div class="container">
+            <div class="row justify-content-center mt-5">
+                <div class="col col-md-7">
+                    <h5 class="mb-0">{{ _("Error 404") }}</h5>
+
+                    <h2>{{ _("This Page Does Not Exist") }}</h2>
+
+                    <p>
+                        {{ _("This wiki page does not exist, yet.") }}
+                    </p>
+
+                    <a class="btn btn-primary btn-block" href="{{ request.path }}?action=edit">
+                        {{ _("Create Now") }}
+                    </a>
+                </div>
+            </div>
+        </div>
+    </section>
+{% end block %}
index 5ba76af0afd8117f228d7fb70258324bdccf326a..de81880dad76885074db5913d8a0e6e987ab06aa 100644 (file)
@@ -7,6 +7,15 @@ from . import base
 from . import ui_modules
 
 class PageHandler(auth.CacheMixin, base.BaseHandler):
+       def write_error(self, status_code, **kwargs):
+               # Render a custom page for 404
+               if status_code == 404:
+                       self.render("wiki/404.html", **kwargs)
+                       return
+
+               # Otherwise raise this to one layer above
+               super().write_error(status_code, **kwargs)
+
        @tornado.web.removeslash
        def get(self, page):
                page = self.backend.wiki.get_page(page)