From 30620d23f960405b7dc0624959d970fdfad12004 Mon Sep 17 00:00:00 2001 From: Joseph Date: Tue, 1 May 2018 16:03:51 +0100 Subject: [Bug Fix] Fix the Edit & Source links on Wiki revision viewer --- pysite/views/wiki/history/compare.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pysite/views/wiki/history/compare.py b/pysite/views/wiki/history/compare.py index 6296f734..6411ab30 100644 --- a/pysite/views/wiki/history/compare.py +++ b/pysite/views/wiki/history/compare.py @@ -50,7 +50,9 @@ class CompareView(RouteView, DBMixin): diff = highlight(diff, DiffLexer(), HtmlFormatter()) return self.render("wiki/compare_revision.html", title=after["post"]["title"], - diff=diff, slug=before["slug"], + page=before["slug"], + diff=diff, + slug=before["slug"], can_edit=self.is_staff()) def is_staff(self): -- cgit v1.2.3 From 94171a9329724d728eb9b99613bb0101eee40e81 Mon Sep 17 00:00:00 2001 From: biskette <37150633+biskette@users.noreply.github.com> Date: Tue, 1 May 2018 18:40:13 +0100 Subject: Fixed those pesky rapper names. (#66) --- pysite/database/table_init/hiphopify_namelist.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pysite/database/table_init/hiphopify_namelist.json b/pysite/database/table_init/hiphopify_namelist.json index 28d6242a..6d90a4a2 100644 --- a/pysite/database/table_init/hiphopify_namelist.json +++ b/pysite/database/table_init/hiphopify_namelist.json @@ -1977,7 +1977,7 @@ }, { "name": "Isaiah Rashad", - "image_url": "http://www.rehabonlinemag.com/wp-content/uploads/2015/09/5854_12.jpg" + "image_url": "http://okp-cdn.okayplayer.com/wp-content/uploads/2014/06/xxl-freshman-2014-cypher-drama-cannon-lead.jpg" }, { "name": "Iyanya", @@ -2777,7 +2777,7 @@ }, { "name": "Lloyd Banks", - "image_url": "http://www.streetgangs.com/wp-content/uploads/2010/01/promoter2.jpg" + "image_url": "https://www.bet.com/music/2018/03/17/lloyd-banks/_jcr_content/image.large2x1image.dimg/__1521337827454__1521335807971/031718-music-lloyd-banks.jpg" }, { "name": "Locksmith", -- cgit v1.2.3 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 From 9d11f558395f0450fbbe1e8d323917dff3ebe167 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 2 May 2018 13:37:49 +0100 Subject: [All Pages] Account for pages without a title when sorting --- pysite/views/wiki/special/all_pages.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pysite/views/wiki/special/all_pages.py b/pysite/views/wiki/special/all_pages.py index 2d5376aa..1305fc29 100644 --- a/pysite/views/wiki/special/all_pages.py +++ b/pysite/views/wiki/special/all_pages.py @@ -1,5 +1,3 @@ -from operator import itemgetter - from pysite.base_route import RouteView from pysite.mixins import DBMixin @@ -11,7 +9,7 @@ class PageView(RouteView, DBMixin): def get(self): pages = self.db.pluck(self.table_name, "title", "slug") - pages = sorted(pages, key=itemgetter("title")) + pages = sorted(pages, key=lambda d: d.get("title", "No Title")) letters = {} -- cgit v1.2.3 From 4062b111c771225a7185af700722490a0da9067b Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 2 May 2018 13:44:33 +0100 Subject: [All Pages] Fix the other half of that dumb --- pysite/views/wiki/special/all_pages.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pysite/views/wiki/special/all_pages.py b/pysite/views/wiki/special/all_pages.py index 1305fc29..d2e02a72 100644 --- a/pysite/views/wiki/special/all_pages.py +++ b/pysite/views/wiki/special/all_pages.py @@ -14,6 +14,9 @@ class PageView(RouteView, DBMixin): letters = {} for page in pages: + if "title" not in page: + page["title"] = "No Title" + letter = page["title"][0].upper() if letter not in letters: -- cgit v1.2.3 From 664b5758c999ba7c8f2b05b152cccdbefc8171e0 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 2 May 2018 13:52:07 +0100 Subject: [All Pages] Fix links --- templates/wiki/special_all.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/wiki/special_all.html b/templates/wiki/special_all.html index 60df4ac3..92aa12a4 100644 --- a/templates/wiki/special_all.html +++ b/templates/wiki/special_all.html @@ -16,7 +16,7 @@
      {% for page in pages %} -
    • +
    • {{ page.title }} ({{ page.slug }})
    • {% endfor %} -- cgit v1.2.3 From 9dc05b5324b478ab84276f6f0ac993c56cc13c3a Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 2 May 2018 14:50:09 +0100 Subject: [Wiki] Implement page deletions and improve sidebar construction --- pysite/views/wiki/delete.py | 67 +++++++++++++++++++++++++++++++ templates/wiki/base.html | 87 ++++++++++++++++++++++++----------------- templates/wiki/page_delete.html | 26 ++++++++++++ templates/wiki/page_edit.html | 2 +- 4 files changed, 146 insertions(+), 36 deletions(-) create mode 100644 pysite/views/wiki/delete.py create mode 100644 templates/wiki/page_delete.html diff --git a/pysite/views/wiki/delete.py b/pysite/views/wiki/delete.py new file mode 100644 index 00000000..0e3bcbbf --- /dev/null +++ b/pysite/views/wiki/delete.py @@ -0,0 +1,67 @@ +import datetime + +import requests +from flask import redirect, url_for +from werkzeug.exceptions import NotFound + +from pysite.base_route import RouteView +from pysite.constants import EDITOR_ROLES, WIKI_AUDIT_WEBHOOK +from pysite.decorators import csrf, require_roles +from pysite.mixins import DBMixin + + +class EditView(RouteView, DBMixin): + path = "/delete/" # "path" means that it accepts slashes + name = "delete" + table_name = "wiki" + revision_table_name = "wiki_revisions" + + @require_roles(*EDITOR_ROLES) + def get(self, page): + obj = self.db.get(self.table_name, page) + + if obj: + title = obj.get("title", "") + + if obj.get("lock_expiry") and obj.get("lock_user") != self.user_data.get("user_id"): + lock_time = datetime.datetime.fromtimestamp(obj["lock_expiry"]) + if datetime.datetime.utcnow() < lock_time: + return self.render("wiki/page_in_use.html", page=page) + + return self.render("wiki/page_delete.html", page=page, title=title) + else: + raise NotFound() + + @require_roles(*EDITOR_ROLES) + @csrf + def post(self, page): + obj = self.db.get(self.table_name, page) + + if not obj: + raise NotFound() + + self.db.delete(self.table_name, page) + self.db.delete(self.revision_table_name, page) + + self.audit_log(obj) + + return redirect(url_for("wiki.page", page="home"), code=303) # Redirect, ensuring a GET + + def audit_log(self, obj): + if WIKI_AUDIT_WEBHOOK: # If the audit webhook is not configured there is no point processing it + audit_payload = { + "username": "Wiki Updates", + "embeds": [ + { + "title": "Page Deletion", + "description": f"**{obj['title']}** was deleted by **{self.user_data.get('username')}**", + "color": 4165079, + "timestamp": datetime.datetime.utcnow().isoformat(), + "thumbnail": { + "url": "https://pythondiscord.com/static/logos/logo_discord.png" + } + } + ] + } + + requests.post(WIKI_AUDIT_WEBHOOK, json=audit_payload) diff --git a/templates/wiki/base.html b/templates/wiki/base.html index 28431324..eec0ecb8 100644 --- a/templates/wiki/base.html +++ b/templates/wiki/base.html @@ -70,24 +70,47 @@  Minecraft -
    • + {% set ACTIONABLE_PAGES = ["page", "edit", "history.show", "history.compare", "source", "delete"] %} + {% set actionable = current_page in ACTIONABLE_PAGES %} - {% if (can_edit or debug) and current_page != "edit" %} -
    • - -  Edit - -
    • - {% elif current_page == "edit" %} -
    • - -  Back - -
    • - {% endif %} + {% if actionable %} +
    • + + {% if current_page == "edit" %} +
    • + +  Back + +
    • + {% else %} +
    • + +  Edit + +
    • + {% endif %} + + {% if current_page == "delete" %} +
    • + +  Back + +
    • + {% else %} +
    • + +  Delete + +
    • + {% endif %} - {% if current_page != "history.show" %} - {% if current_page == "history.compare" %} + {% if current_page == "history.show" %} +
    • + +  Back + +
    • + {% elif current_page == "history.compare" %}
    •  Back @@ -100,26 +123,20 @@
    • {% endif %} - {% else %} -
    • - -  Back - -
    • - {% endif %} - {% if current_page != "source" %} -
    • - -  Source - -
    • - {% else %} -
    • - -  Back - -
    • + {% if current_page == "source" %} +
    • + +  Back + +
    • + {% else %} +
    • + +  Source + +
    • + {% endif %} {% endif %}
    • diff --git a/templates/wiki/page_delete.html b/templates/wiki/page_delete.html new file mode 100644 index 00000000..f4d52653 --- /dev/null +++ b/templates/wiki/page_delete.html @@ -0,0 +1,26 @@ +{% extends "wiki/base.html" %} +{% block title %}Wiki | Delete: {{ page }}{% endblock %} +{% block og_title %}Wiki | Delete: {{ page }}{% endblock %} +{% block og_description %}{% endblock %} +{% block extra_head %} + +{% endblock %} +{% block content %} +
      +

      Delete Page: {{ page }}

      +

      + Are you sure you want to delete this page? +

      + +
      +
      + Cancel +
      +
      + +
      + + +
      +
      +{% endblock %} diff --git a/templates/wiki/page_edit.html b/templates/wiki/page_edit.html index a2d709e2..51ce70db 100644 --- a/templates/wiki/page_edit.html +++ b/templates/wiki/page_edit.html @@ -1,7 +1,7 @@ {% extends "wiki/base.html" %} {% block title %}Wiki | Edit: {{ page }}{% endblock %} {% block og_title %}Wiki | Edit: {{ page }}{% endblock %} -{% block og_description %}Landing page for the wiki{% endblock %} +{% block og_description %}{% endblock %} {% block extra_head %} {% endblock %} -- cgit v1.2.3 From caa2ad7f4ddd6d69f053cf8fc41df8739bd2d003 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 2 May 2018 15:13:54 +0100 Subject: [Wiki] 7rem wasn't quite enough for the sidebar --- static/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/style.css b/static/style.css index fd182b03..ab910acc 100644 --- a/static/style.css +++ b/static/style.css @@ -140,7 +140,7 @@ img.navbar-logo { } #wiki-nav .uk-nav-divider { - min-width: 7rem; + min-width: 7.1rem; } /* Resource page styling */ -- cgit v1.2.3 From bb0a8a528a1deed6cc42683ae02624da3f35fd4d Mon Sep 17 00:00:00 2001 From: Christopher Baklid Date: Wed, 2 May 2018 18:23:16 +0200 Subject: upgrades alpine and adds docker commands to pipenv (#65) --- Pipfile | 4 ++++ docker/Dockerfile.base | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 13811259..a9315ea1 100644 --- a/Pipfile +++ b/Pipfile @@ -41,3 +41,7 @@ start = "gunicorn -w 12 -b 0.0.0.0:10012 -c gunicorn_config.py --log-level info lint = "python -m flake8" test = "py.test app_test.py --cov pysite --cov-report term-missing -v" clean = "rm -rf __pycache__ htmlcov .coverage .pytest_cache" +build = "docker build -t pythondiscord/site:latest -f docker/Dockerfile ." +push = "docker push pythondiscord/site:latest" +buildbase = "docker build -t pythondiscord/site-base:latest -f docker/Dockerfile.base ." +pushbase = "docker push pythondiscord/site-base:latest" diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base index 87c6fd73..a09a04e8 100644 --- a/docker/Dockerfile.base +++ b/docker/Dockerfile.base @@ -1,4 +1,4 @@ -FROM python:3.6-alpine +FROM python:3.6-alpine3.7 RUN apk add --update tini RUN apk add --update git -- cgit v1.2.3 From f0727eee3426e7e9c0012a3957566e21720eeef1 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Fri, 4 May 2018 09:56:29 +0100 Subject: [Wiki] 7.1rem wasn't quite enough for the sidebar --- static/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/style.css b/static/style.css index ab910acc..78f2663b 100644 --- a/static/style.css +++ b/static/style.css @@ -140,7 +140,7 @@ img.navbar-logo { } #wiki-nav .uk-nav-divider { - min-width: 7.1rem; + min-width: 8.0rem; } /* Resource page styling */ -- cgit v1.2.3 From d4ed7ebd7b3ad37ffff422dc74d02d41c920d0dc Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sat, 5 May 2018 16:47:20 +0100 Subject: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f689aabe..5a65550f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Python Discord website -[![Build Status](https://travis-ci.org/discord-python/site.svg?branch=master)](https://travis-ci.org/discord-python/site) [![Coverage Status](https://coveralls.io/repos/github/discord-python/site/badge.svg?branch=master)](https://coveralls.io/github/discord-python/site?branch=master) +[![Build Status](https://travis-ci.org/discord-python/site.svg?branch=master)](https://travis-ci.org/discord-python/site) [![Coverage Status](https://coveralls.io/repos/github/discord-python/site/badge.svg?branch=master)](https://coveralls.io/github/discord-python/site?branch=master) [![Discord](https://discordapp.com/api/guilds/267624335836053506/embed.png)](https://discord.gg/2B963hn) ### See the wiki for details -- cgit v1.2.3