From 3bdffd9cfb61c8a8e75c472765fbb738a67c6ca0 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 2 May 2018 13:28:51 +0100 Subject: Add special pages and an "all pages" special page --- pysite/views/wiki/special/__init__.py | 1 + pysite/views/wiki/special/all_pages.py | 26 ++++++++++++++++++++++++++ pysite/views/wiki/special/index.py | 10 ++++++++++ templates/wiki/base.html | 18 ++++++++---------- templates/wiki/special.html | 17 +++++++++++++++++ templates/wiki/special_all.html | 26 ++++++++++++++++++++++++++ 6 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 pysite/views/wiki/special/__init__.py create mode 100644 pysite/views/wiki/special/all_pages.py create mode 100644 pysite/views/wiki/special/index.py create mode 100644 templates/wiki/special.html create mode 100644 templates/wiki/special_all.html diff --git a/pysite/views/wiki/special/__init__.py b/pysite/views/wiki/special/__init__.py new file mode 100644 index 00000000..9bad5790 --- /dev/null +++ b/pysite/views/wiki/special/__init__.py @@ -0,0 +1 @@ +# coding=utf-8 diff --git a/pysite/views/wiki/special/all_pages.py b/pysite/views/wiki/special/all_pages.py new file mode 100644 index 00000000..2d5376aa --- /dev/null +++ b/pysite/views/wiki/special/all_pages.py @@ -0,0 +1,26 @@ +from operator import itemgetter + +from pysite.base_route import RouteView +from pysite.mixins import DBMixin + + +class PageView(RouteView, DBMixin): + path = "/special/all_pages" + name = "special.all_pages" + table_name = "wiki" + + def get(self): + pages = self.db.pluck(self.table_name, "title", "slug") + pages = sorted(pages, key=itemgetter("title")) + + letters = {} + + for page in pages: + letter = page["title"][0].upper() + + if letter not in letters: + letters[letter] = [] + + letters[letter].append(page) + + return self.render("wiki/special_all.html", letters=letters) diff --git a/pysite/views/wiki/special/index.py b/pysite/views/wiki/special/index.py new file mode 100644 index 00000000..15c0a649 --- /dev/null +++ b/pysite/views/wiki/special/index.py @@ -0,0 +1,10 @@ +from pysite.base_route import RouteView +from pysite.mixins import DBMixin + + +class PageView(RouteView, DBMixin): + path = "/special" + name = "special" + + def get(self): + return self.render("wiki/special.html") diff --git a/templates/wiki/base.html b/templates/wiki/base.html index c6f8deca..28431324 100644 --- a/templates/wiki/base.html +++ b/templates/wiki/base.html @@ -69,14 +69,7 @@
  •  Minecraft
  • -{#
  • active
  • #} -{#
  • #} -{# Contributing#} -{# #} -{#
  • #} +
  • {% if (can_edit or debug) and current_page != "edit" %} @@ -115,7 +108,6 @@ {% endif %} - {% if current_page != "source" %}
  • @@ -129,8 +121,14 @@
  • {% endif %} +
  • -
  •  Help
  • +
  • +  Special Pages +
  • +
  • +  Help +
  • diff --git a/templates/wiki/special.html b/templates/wiki/special.html new file mode 100644 index 00000000..12e9cb18 --- /dev/null +++ b/templates/wiki/special.html @@ -0,0 +1,17 @@ +{% extends "wiki/base.html" %} +{% block title %}Wiki | Special Pages{% endblock %} +{% block og_title %}Wiki | Special Pages{% endblock %} +{% block og_description %}Wiki special pages, non-article informational pages{% endblock %} +{% block content %} +
    +

    + Special Pages +

    + + +
    +{% endblock %} \ No newline at end of file diff --git a/templates/wiki/special_all.html b/templates/wiki/special_all.html new file mode 100644 index 00000000..60df4ac3 --- /dev/null +++ b/templates/wiki/special_all.html @@ -0,0 +1,26 @@ +{% extends "wiki/base.html" %} +{% block title %}Wiki | Special: All Pages{% endblock %} +{% block og_title %}Wiki | Special: All Pages{% endblock %} +{% block og_description %}A listing for all pages on the wiki{% endblock %} +{% block content %} +
    +

    + Special: All Pages +

    +

    + A listing for all pages on the wiki +

    + + {% for letter, pages in letters.items() %} +

    {{ letter }}

    + + + {% endfor %} +
    +{% endblock %} \ No newline at end of file -- cgit v1.2.3