From bb22b1b5c5a3989729f40267621050341807a279 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 14 Apr 2019 20:00:51 +0100 Subject: Breadcrumb/article menu work --- pydis_site/static/js/wiki/dropdown.js | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pydis_site/static/js/wiki/dropdown.js (limited to 'pydis_site/static/js/wiki/dropdown.js') diff --git a/pydis_site/static/js/wiki/dropdown.js b/pydis_site/static/js/wiki/dropdown.js new file mode 100644 index 00000000..55b2e9fc --- /dev/null +++ b/pydis_site/static/js/wiki/dropdown.js @@ -0,0 +1,37 @@ +// TODO: Move to django-simple-bulma + +(function() { + window.dropdowns = {}; + + let elements = document.getElementsByClassName("dropdown"); + + for (let element of elements) { + let menu_element = element.getElementsByClassName("dropdown-menu")[0]; + + function show() { + $(element).addClass("is-active"); + } + + function hide() { + $(element).removeClass("is-active"); + } + + function handle_event(e) { + show(); + + $(document.body).on("click." + menu_element.id, function() { + hide(); + + $(document.body).off("click." + menu_element.id); + }); + + e.stopPropagation(); + } + + $(element).click(handle_event); + $(element).hover(handle_event); + $(element).mouseleave(hide); + + window.dropdowns[menu_element.id] = element; + } +})(); -- cgit v1.2.3 From bbeb451ac6750c526166db12080b1b6bc040c860 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sat, 20 Apr 2019 14:32:53 +0100 Subject: Address reviews --- pydis_site/apps/home/templatetags/wiki_extra.py | 7 +- pydis_site/settings.py | 5 +- pydis_site/static/js/wiki/dropdown.js | 2 - pydis_site/templates/wiki/article.html | 3 +- pydis_site/templates/wiki/base.html | 7 +- pydis_site/templates/wiki/base_site.html | 170 --------------- pydis_site/templates/wiki/create.html | 11 +- pydis_site/templates/wiki/create_root.html | 7 +- pydis_site/templates/wiki/delete.html | 4 +- pydis_site/templates/wiki/deleted.html | 4 +- pydis_site/templates/wiki/deleted_list.html | 3 +- pydis_site/templates/wiki/dir.html | 15 +- pydis_site/templates/wiki/edit.html | 17 +- pydis_site/templates/wiki/error.html | 7 +- pydis_site/templates/wiki/history.html | 227 +++++++++------------ .../templates/wiki/includes/article_menu.html | 2 +- pydis_site/templates/wiki/includes/editor.html | 2 +- .../templates/wiki/includes/editor_sidebar.html | 60 +++--- .../templates/wiki/includes/editormedia.html | 20 +- pydis_site/templates/wiki/includes/form.html | 9 +- pydis_site/templates/wiki/includes/pagination.html | 1 + pydis_site/templates/wiki/includes/render.html | 4 +- .../templates/wiki/includes/revision_info.html | 18 +- .../templates/wiki/includes/searchresult.html | 22 +- pydis_site/templates/wiki/move.html | 73 +++---- .../templates/wiki/plugins/images/index.html | 28 ++- .../templates/wiki/plugins/images/purge.html | 6 +- .../templates/wiki/plugins/images/render.html | 2 +- .../wiki/plugins/images/revision_add.html | 5 +- .../templates/wiki/plugins/images/sidebar.html | 5 +- .../templates/wiki/plugins/links/sidebar.html | 4 +- pydis_site/templates/wiki/preview_inline.html | 20 +- pydis_site/templates/wiki/root_missing.html | 3 +- pydis_site/templates/wiki/search.html | 5 +- pydis_site/templates/wiki/settings.html | 42 ++-- pydis_site/templates/wiki/source.html | 3 +- 36 files changed, 325 insertions(+), 498 deletions(-) delete mode 100644 pydis_site/templates/wiki/base_site.html (limited to 'pydis_site/static/js/wiki/dropdown.js') diff --git a/pydis_site/apps/home/templatetags/wiki_extra.py b/pydis_site/apps/home/templatetags/wiki_extra.py index 9847ef5a..289b0279 100644 --- a/pydis_site/apps/home/templatetags/wiki_extra.py +++ b/pydis_site/apps/home/templatetags/wiki_extra.py @@ -26,7 +26,7 @@ TEMPLATES: Dict[Type, str] = { register = template.Library() -def get_unbound_field(field: BoundField) -> Field: +def get_unbound_field(field: Union[BoundField, Field]) -> Field: while isinstance(field, BoundField): field = field.field @@ -39,10 +39,7 @@ def render(template_path: str, context: Dict[str, Any]): @register.simple_tag def render_field(field: Field, render_labels: bool = True): - if isinstance(field, BoundField): - unbound_field = get_unbound_field(field) - else: - unbound_field = field + unbound_field = get_unbound_field(field) if not isinstance(render_labels, bool): render_labels = True diff --git a/pydis_site/settings.py b/pydis_site/settings.py index c4c8a535..a9fef6b7 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -277,12 +277,11 @@ CRISPY_TEMPLATE_PACK = "bulma" # Custom settings for django-simple-bulma BULMA_SETTINGS = { "variables": { + "green": "#21c65c", # Accessibility: Better contrast with the light text "primary": "#7289DA", "link": "$primary", - "green": "#21c65c", # Better contrast with the light text - - "dimensions": "16 24 32 48 64 96 128 256 512" # Image dimensions + "dimensions": "16 24 32 48 64 96 128 256 512" # Possible image dimensions } } diff --git a/pydis_site/static/js/wiki/dropdown.js b/pydis_site/static/js/wiki/dropdown.js index 55b2e9fc..a914a4ab 100644 --- a/pydis_site/static/js/wiki/dropdown.js +++ b/pydis_site/static/js/wiki/dropdown.js @@ -1,5 +1,3 @@ -// TODO: Move to django-simple-bulma - (function() { window.dropdowns = {}; diff --git a/pydis_site/templates/wiki/article.html b/pydis_site/templates/wiki/article.html index 39e1728d..890e4300 100644 --- a/pydis_site/templates/wiki/article.html +++ b/pydis_site/templates/wiki/article.html @@ -1,6 +1,5 @@ {% extends "wiki/base.html" %} -{% load wiki_tags i18n sekizai_tags %} - +{% load wiki_tags %} {% block wiki_pagetitle %}{{ article.current_revision.title }}{% endblock %} diff --git a/pydis_site/templates/wiki/base.html b/pydis_site/templates/wiki/base.html index 112523cd..c47f6bfb 100644 --- a/pydis_site/templates/wiki/base.html +++ b/pydis_site/templates/wiki/base.html @@ -1,5 +1,6 @@ {% extends "base/base.html" %} -{% load sekizai_tags i18n wiki_tags static %} +{% load static %} +{% load wiki_tags %} {% block title %} Wiki | {% block wiki_pagetitle %}{% endblock %}{% block wiki_site_title %}{% endblock %} @@ -41,7 +42,9 @@ {% endblock %} {% block site_footer %} - {% include "base/footer.html" %} + {% block wiki_footer_prepend %}{% endblock %} + + {{ block.super }} {% endblock %} diff --git a/pydis_site/templates/wiki/base_site.html b/pydis_site/templates/wiki/base_site.html deleted file mode 100644 index afa2b41d..00000000 --- a/pydis_site/templates/wiki/base_site.html +++ /dev/null @@ -1,170 +0,0 @@ -{% extends "base/base.html" %} -{% load sekizai_tags i18n wiki_tags static %} - -{# This template is no longer used - we can remove it later when the rest are done #} - -{% block title %} - {% block wiki_pagetitle %}{% endblock %}{% block wiki_site_title %} - django-\/\/ i K |{% endblock %} -{% endblock %} - - - - - Wiki | {% block wiki_pagetitle %}{% endblock %}{% block wiki_site_title %}{% endblock %} - - - - - - - - - {% render_block "css" %} - - - - - - - - - {% block wiki_body %} - - {% block wiki_navbar %} - - {% endblock %} - -
- - {% wiki_messages %} - - - {% block wiki_breadcrumbs %}{% endblock %} - - - {% block wiki_contents %}{% endblock %} - -
-
- {% block wiki_footer_logo %} - - {% endblock %} - {% block wiki_footer_prepend %} - {% endblock %} -

{% blocktrans %}Powered by django-wiki, an open source application under the GPLv3 license. Let knowledge be the cure.{% endblocktrans %}

-
-
-
- - {% endblock %} - - - - - - - {% render_block "js" %} - - - diff --git a/pydis_site/templates/wiki/create.html b/pydis_site/templates/wiki/create.html index 5aaa017c..3fbba969 100644 --- a/pydis_site/templates/wiki/create.html +++ b/pydis_site/templates/wiki/create.html @@ -1,11 +1,11 @@ {% extends "wiki/base.html" %} -{% load wiki_tags i18n sekizai_tags static %} +{% load sekizai_tags %} +{% load static %} +{% load wiki_tags %} - -{% block wiki_pagetitle %}{% trans "Add new article" %}{% endblock %} +{% block wiki_pagetitle %}Add new article{% endblock %} {% block wiki_contents %} - {% addtoblock "js" %} @@ -15,7 +15,7 @@ {% endaddtoblock %} {% include "wiki/includes/editormedia.html" %} -

{% trans "Add new article" %}

+

Add new article

{% wiki_form create_form %} @@ -39,5 +39,4 @@
- {% endblock %} diff --git a/pydis_site/templates/wiki/create_root.html b/pydis_site/templates/wiki/create_root.html index 376321c6..330fea33 100644 --- a/pydis_site/templates/wiki/create_root.html +++ b/pydis_site/templates/wiki/create_root.html @@ -1,7 +1,8 @@ {% extends "wiki/base.html" %} -{% load wiki_tags crispy_forms_tags i18n sekizai_tags static %} +{% load static %} +{% load wiki_tags %} -{% block wiki_pagetitle %}{% trans "Create root article" %}{% endblock %} +{% block wiki_pagetitle %}{Create root article{% endblock %} {% block head %} {{ block.super }} @@ -17,7 +18,6 @@ {% endfor %} {% endblock %} - {% block wiki_contents %}

Create First Article

@@ -49,5 +49,4 @@ - {% endblock %} diff --git a/pydis_site/templates/wiki/delete.html b/pydis_site/templates/wiki/delete.html index 755e8d7a..bb7a7966 100644 --- a/pydis_site/templates/wiki/delete.html +++ b/pydis_site/templates/wiki/delete.html @@ -1,6 +1,6 @@ {% extends "wiki/base.html" %} -{% load wiki_tags sekizai_tags static %} - +{% load static %} +{% load wiki_tags %} {% block wiki_pagetitle %}Delete Article{% endblock %} diff --git a/pydis_site/templates/wiki/deleted.html b/pydis_site/templates/wiki/deleted.html index 75705cbb..cdde2c47 100644 --- a/pydis_site/templates/wiki/deleted.html +++ b/pydis_site/templates/wiki/deleted.html @@ -1,6 +1,5 @@ {% extends "wiki/base.html" %} -{% load wiki_tags i18n sekizai_tags %} - +{% load wiki_tags %} {% block wiki_pagetitle %}Article deleted{% endblock %} @@ -17,7 +16,6 @@ {% if not article.current_revision.locked or article|can_delete:user %} -

Restore Article

diff --git a/pydis_site/templates/wiki/deleted_list.html b/pydis_site/templates/wiki/deleted_list.html index 6ec2a8df..1a8d203c 100644 --- a/pydis_site/templates/wiki/deleted_list.html +++ b/pydis_site/templates/wiki/deleted_list.html @@ -1,5 +1,5 @@ {% extends "wiki/base.html" %} -{% load wiki_tags sekizai_tags %} +{% load wiki_tags %} {% block wiki_pagetitle %}Deleted Articles{% endblock %} @@ -15,6 +15,7 @@ Restore Article + {% for article in deleted_articles %} diff --git a/pydis_site/templates/wiki/dir.html b/pydis_site/templates/wiki/dir.html index 163a9d29..5a30de7b 100644 --- a/pydis_site/templates/wiki/dir.html +++ b/pydis_site/templates/wiki/dir.html @@ -1,8 +1,10 @@ {% extends "wiki/article.html" %} -{% load wiki_tags wiki_extra i18n humanize %} +{% load humanize %} +{% load i18n %} +{% load wiki_extra %} +{% load wiki_tags %} - -{% block wiki_pagetitle %}{% trans "Listing articles in" %} {{ article.current_revision.title }}{% endblock %} +{% block wiki_pagetitle %}Listing articles in {{ article.current_revision.title }}{% endblock %} {% block wiki_contents_tab %} {% url 'wiki:dir' urlpath.path as self_url %} @@ -11,6 +13,7 @@
{% render_field filter_form.query render_labels=False %}
+
@@ -53,6 +56,7 @@ Slug Last modified + {% for urlpath in directory %} @@ -76,14 +80,17 @@ {% endif %} + {{ urlpath.slug }} + {{ urlpath.article.current_revision.created|naturaltime }} - {% empty%} + + {% empty %} There are no articles at this level diff --git a/pydis_site/templates/wiki/edit.html b/pydis_site/templates/wiki/edit.html index 622e98eb..c378362a 100644 --- a/pydis_site/templates/wiki/edit.html +++ b/pydis_site/templates/wiki/edit.html @@ -1,22 +1,13 @@ {% extends "wiki/article.html" %} -{% load wiki_tags i18n sekizai_tags static %} - +{% load static %} +{% load wiki_tags %} {% block wiki_pagetitle %} Edit: {{ article.current_revision.title }} {% endblock %} {% block wiki_contents_tab %} - - {% if not user.is_authenticated %} -

- {% trans "Warning: You are not logged in. Your IP address will be logged." %} - {% trans "Click here to log in" %} » -

- {% endif %} -
-
{% with edit_form as form %} @@ -60,18 +51,14 @@

-
{% include "wiki/includes/editor_sidebar.html" %}
-
-
-