From 3d868521f60b1b8d5d1106e4b8cd089a018328e3 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Mon, 8 Apr 2019 12:48:53 +0100 Subject: First attempt at getting the wiki up --- pydis_site/settings.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index e8355918..2212da21 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -64,22 +64,34 @@ else: INSTALLED_APPS = [ 'pydis_site.apps.api', 'pydis_site.apps.home', - 'pydis_site.apps.wiki', + 'pydis_site.apps.wiki_container', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', + 'django.contrib.humanize.apps.HumanizeConfig', 'django.contrib.sessions', 'django.contrib.messages', + 'django.contrib.sites.apps.SitesConfig', 'django.contrib.staticfiles', 'crispy_forms', + 'django_crispy_bulma', 'django_hosts', 'django_filters', - 'django_crispy_bulma', + 'django_nyt.apps.DjangoNytConfig', 'django_simple_bulma', + 'mptt', 'rest_framework', - 'rest_framework.authtoken' + 'rest_framework.authtoken', + 'sekizai', + 'sorl.thumbnail', + + 'wiki.apps.WikiConfig', + 'wiki.plugins.attachments.apps.AttachmentsConfig', + 'wiki.plugins.notifications.apps.NotificationsConfig', + 'wiki.plugins.images.apps.ImagesConfig', + 'wiki.plugins.macros.apps.MacrosConfig', ] MIDDLEWARE = [ @@ -112,6 +124,8 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + + "sekizai.context_processors.sekizai", ], }, }, @@ -257,3 +271,9 @@ BULMA_SETTINGS = { "link": "$primary", } } + +# Required for the wiki +SITE_ID = 1 + +WIKI_ACCOUNT_HANDLING = False +WIKI_ACCOUNT_SIGNUP_ALLOWED = False -- cgit v1.2.3 From 4dc58e6e14702989f7419d6bfc4ca589898f2e56 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Mon, 8 Apr 2019 14:05:50 +0100 Subject: Remove wiki host, use /wiki - Also some wiki config I've included the monokai pygments theme, but we can change it later --- .dockerignore | 2 - Pipfile | 1 + Pipfile.lock | 10 ++++- pydis_site/apps/home/urls.py | 7 +-- pydis_site/apps/wiki_container/__init__.py | 0 pydis_site/apps/wiki_container/apps.py | 6 --- pydis_site/apps/wiki_container/urls.py | 6 --- pydis_site/hosts.py | 3 +- pydis_site/settings.py | 29 ++++++++++++- pydis_site/static/css/pygments.css | 70 ++++++++++++++++++++++++++++++ 10 files changed, 113 insertions(+), 21 deletions(-) delete mode 100644 pydis_site/apps/wiki_container/__init__.py delete mode 100644 pydis_site/apps/wiki_container/apps.py delete mode 100644 pydis_site/apps/wiki_container/urls.py create mode 100644 pydis_site/static/css/pygments.css (limited to 'pydis_site/settings.py') diff --git a/.dockerignore b/.dockerignore index ca6ba308..4ad7c8a7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -31,5 +31,3 @@ README.md scripts Vagrantfile venv -pydis_site/apps/wiki/tests -pydis_site/apps/wiki/tests.py diff --git a/Pipfile b/Pipfile index 1fd34c35..c6f210ab 100644 --- a/Pipfile +++ b/Pipfile @@ -28,6 +28,7 @@ psycopg2-binary = "~=2.8" django-simple-bulma = ">=1.1.6,<2.0" django-crispy-bulma = ">=0.1.2,<2.0" wiki = "~=0.4.4" +pygments = "~=2.3.1" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index a908b8c7..777dbd38 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "a63ccdec81594bd69f4af503e5a62fe01a74adfd6daaaa0fb9be08b25631cb84" + "sha256": "d6bbf11476ca021d14ef03475ef6154b148d75a3ceada522194a56e80a27ccf1" }, "pipfile-spec": 6, "requires": { @@ -229,6 +229,14 @@ "index": "pypi", "version": "==2.8.1" }, + "pygments": { + "hashes": [ + "sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a", + "sha256:e8218dd399a61674745138520d0d4cf2621d7e032439341bc3f647bff125818d" + ], + "index": "pypi", + "version": "==2.3.1" + }, "pytz": { "hashes": [ "sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/home/urls.py index a01e019e..ede0531e 100644 --- a/pydis_site/apps/home/urls.py +++ b/pydis_site/apps/home/urls.py @@ -1,10 +1,11 @@ from django.contrib import admin -from django.urls import path +from django.urls import path, include from django.views.generic import TemplateView app_name = 'home' urlpatterns = [ - path('', TemplateView.as_view(template_name='home/index.html'), name='index'), - path('admin/', admin.site.urls) + path('admin/', admin.site.urls), + path('wiki/', include('wiki.urls')), + path('/', TemplateView.as_view(template_name='home/index.html'), name='index'), ] diff --git a/pydis_site/apps/wiki_container/__init__.py b/pydis_site/apps/wiki_container/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/pydis_site/apps/wiki_container/apps.py b/pydis_site/apps/wiki_container/apps.py deleted file mode 100644 index 874ae8e4..00000000 --- a/pydis_site/apps/wiki_container/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from wiki.apps import WikiConfig - - -class WikiContainerConfig(WikiConfig): - name = 'wiki_container' - default_site = 'pydis_site.sites.PyDisWikiSite' diff --git a/pydis_site/apps/wiki_container/urls.py b/pydis_site/apps/wiki_container/urls.py deleted file mode 100644 index 1537fe8c..00000000 --- a/pydis_site/apps/wiki_container/urls.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.urls import path, include - -urlpatterns = [ - path('notifications/', include('django_nyt.urls')), - path('', include('wiki.urls')) -] diff --git a/pydis_site/hosts.py b/pydis_site/hosts.py index fc43d0eb..25220ee0 100644 --- a/pydis_site/hosts.py +++ b/pydis_site/hosts.py @@ -3,8 +3,7 @@ from django_hosts import host, patterns host_patterns = patterns( '', - # host(r"subdomain pattern", "URLs module", "host entry name") - host(r'wiki', 'pydis_site.apps.wiki_container.urls', name="wiki"), + # host(r"subdomain pattern", "URLs module", "host entry name"), host(r'admin', 'pydis_site.apps.admin.urls', name="admin"), host(r'api', 'pydis_site.apps.api.urls', name='api'), host(r'.*', 'pydis_site.apps.home.urls', name=settings.DEFAULT_HOST) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 2212da21..e55b3132 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -64,7 +64,6 @@ else: INSTALLED_APPS = [ 'pydis_site.apps.api', 'pydis_site.apps.home', - 'pydis_site.apps.wiki_container', 'django.contrib.admin', 'django.contrib.auth', @@ -277,3 +276,31 @@ SITE_ID = 1 WIKI_ACCOUNT_HANDLING = False WIKI_ACCOUNT_SIGNUP_ALLOWED = False + +WIKI_ANONYMOUS = True +WIKI_ANONYMOUS_CREATE = DEBUG +WIKI_ANONYMOUS_UPLOAD = DEBUG +WIKI_ANONYMOUS_WRITE = DEBUG + +WIKI_MARKDOWN_KWARGS = { + "extension_configs": { + "wiki.plugins.macros.mdx.toc": { + "title": "Contents" + } + }, "extensions": [ + "markdown.extensions.abbr", + "markdown.extensions.attr_list", + "markdown.extensions.extra", + "markdown.extensions.fenced_code", + "markdown.extensions.footnotes", + "markdown.extensions.nl2br", + "markdown.extensions.sane_lists", + + "wiki.core.markdown.mdx.codehilite", + "wiki.core.markdown.mdx.previewlinks", + "wiki.core.markdown.mdx.responsivetable", + "wiki.plugins.macros.mdx.macro", + "wiki.plugins.macros.mdx.toc", + "wiki.plugins.macros.mdx.wikilinks", + ] +} diff --git a/pydis_site/static/css/pygments.css b/pydis_site/static/css/pygments.css new file mode 100644 index 00000000..d2e9fc72 --- /dev/null +++ b/pydis_site/static/css/pygments.css @@ -0,0 +1,70 @@ +.codehilite .hll { background-color: #49483e } +.codehilite { background: #272822; color: #f8f8f2 } +.codehilite .c { color: #75715e } /* Comment */ +.codehilite .err { color: #960050; background-color: #1e0010 } /* Error */ +.codehilite .k { color: #66d9ef } /* Keyword */ +.codehilite .l { color: #ae81ff } /* Literal */ +.codehilite .n { color: #f8f8f2 } /* Name */ +.codehilite .o { color: #f92672 } /* Operator */ +.codehilite .p { color: #f8f8f2 } /* Punctuation */ +.codehilite .ch { color: #75715e } /* Comment.Hashbang */ +.codehilite .cm { color: #75715e } /* Comment.Multiline */ +.codehilite .cp { color: #75715e } /* Comment.Preproc */ +.codehilite .cpf { color: #75715e } /* Comment.PreprocFile */ +.codehilite .c1 { color: #75715e } /* Comment.Single */ +.codehilite .cs { color: #75715e } /* Comment.Special */ +.codehilite .gd { color: #f92672 } /* Generic.Deleted */ +.codehilite .ge { font-style: italic } /* Generic.Emph */ +.codehilite .gi { color: #a6e22e } /* Generic.Inserted */ +.codehilite .gs { font-weight: bold } /* Generic.Strong */ +.codehilite .gu { color: #75715e } /* Generic.Subheading */ +.codehilite .kc { color: #66d9ef } /* Keyword.Constant */ +.codehilite .kd { color: #66d9ef } /* Keyword.Declaration */ +.codehilite .kn { color: #f92672 } /* Keyword.Namespace */ +.codehilite .kp { color: #66d9ef } /* Keyword.Pseudo */ +.codehilite .kr { color: #66d9ef } /* Keyword.Reserved */ +.codehilite .kt { color: #66d9ef } /* Keyword.Type */ +.codehilite .ld { color: #e6db74 } /* Literal.Date */ +.codehilite .m { color: #ae81ff } /* Literal.Number */ +.codehilite .s { color: #e6db74 } /* Literal.String */ +.codehilite .na { color: #a6e22e } /* Name.Attribute */ +.codehilite .nb { color: #f8f8f2 } /* Name.Builtin */ +.codehilite .nc { color: #a6e22e } /* Name.Class */ +.codehilite .no { color: #66d9ef } /* Name.Constant */ +.codehilite .nd { color: #a6e22e } /* Name.Decorator */ +.codehilite .ni { color: #f8f8f2 } /* Name.Entity */ +.codehilite .ne { color: #a6e22e } /* Name.Exception */ +.codehilite .nf { color: #a6e22e } /* Name.Function */ +.codehilite .nl { color: #f8f8f2 } /* Name.Label */ +.codehilite .nn { color: #f8f8f2 } /* Name.Namespace */ +.codehilite .nx { color: #a6e22e } /* Name.Other */ +.codehilite .py { color: #f8f8f2 } /* Name.Property */ +.codehilite .nt { color: #f92672 } /* Name.Tag */ +.codehilite .nv { color: #f8f8f2 } /* Name.Variable */ +.codehilite .ow { color: #f92672 } /* Operator.Word */ +.codehilite .w { color: #f8f8f2 } /* Text.Whitespace */ +.codehilite .mb { color: #ae81ff } /* Literal.Number.Bin */ +.codehilite .mf { color: #ae81ff } /* Literal.Number.Float */ +.codehilite .mh { color: #ae81ff } /* Literal.Number.Hex */ +.codehilite .mi { color: #ae81ff } /* Literal.Number.Integer */ +.codehilite .mo { color: #ae81ff } /* Literal.Number.Oct */ +.codehilite .sa { color: #e6db74 } /* Literal.String.Affix */ +.codehilite .sb { color: #e6db74 } /* Literal.String.Backtick */ +.codehilite .sc { color: #e6db74 } /* Literal.String.Char */ +.codehilite .dl { color: #e6db74 } /* Literal.String.Delimiter */ +.codehilite .sd { color: #e6db74 } /* Literal.String.Doc */ +.codehilite .s2 { color: #e6db74 } /* Literal.String.Double */ +.codehilite .se { color: #ae81ff } /* Literal.String.Escape */ +.codehilite .sh { color: #e6db74 } /* Literal.String.Heredoc */ +.codehilite .si { color: #e6db74 } /* Literal.String.Interpol */ +.codehilite .sx { color: #e6db74 } /* Literal.String.Other */ +.codehilite .sr { color: #e6db74 } /* Literal.String.Regex */ +.codehilite .s1 { color: #e6db74 } /* Literal.String.Single */ +.codehilite .ss { color: #e6db74 } /* Literal.String.Symbol */ +.codehilite .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ +.codehilite .fm { color: #a6e22e } /* Name.Function.Magic */ +.codehilite .vc { color: #f8f8f2 } /* Name.Variable.Class */ +.codehilite .vg { color: #f8f8f2 } /* Name.Variable.Global */ +.codehilite .vi { color: #f8f8f2 } /* Name.Variable.Instance */ +.codehilite .vm { color: #f8f8f2 } /* Name.Variable.Magic */ +.codehilite .il { color: #ae81ff } /* Literal.Number.Integer.Long */ -- cgit v1.2.3 From a880a3441100b387e1171c79cbeff36d3aa8d445 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 10 Apr 2019 23:17:08 +0100 Subject: Some initial work on updating the wiki templates for Bulma --- pydis_site/settings.py | 1 + pydis_site/templates/wiki/base.html | 31 +++++++++++++- pydis_site/templates/wiki/base_site.html | 14 +++++-- pydis_site/templates/wiki/create_root.html | 18 +------- pydis_site/templates/wiki/root_missing.html | 64 +++++++++++++++-------------- 5 files changed, 76 insertions(+), 52 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index e55b3132..6c9af3aa 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -272,6 +272,7 @@ BULMA_SETTINGS = { } # Required for the wiki +LOGIN_URL = "/admin/login" # TODO: Update this when the real login system is in place SITE_ID = 1 WIKI_ACCOUNT_HANDLING = False diff --git a/pydis_site/templates/wiki/base.html b/pydis_site/templates/wiki/base.html index 5260bfcd..95b0186d 100644 --- a/pydis_site/templates/wiki/base.html +++ b/pydis_site/templates/wiki/base.html @@ -1,3 +1,30 @@ -{% extends "wiki/base_site.html" %} +{% extends "base/base.html" %} +{% load sekizai_tags i18n wiki_tags static %} -{# Intentionally empty, to allow easy customization with no copy-paste #} +{% block title %} + Wiki | {% block wiki_pagetitle %}{% endblock %}{% block wiki_site_title %}{% endblock %} +{% endblock %} + +{% block content %} + {% include "base/navbar.html" with active_item=True dropdowns=True icon_weight="far" use_logo=True %} + + {% block wiki_body %} + {% block wiki_navbar %} + + {% endblock %} + +
+
+ {% wiki_messages %} + + {% block wiki_breadcrumbs %}{% endblock %} + +
+ {% block wiki_contents %}{% endblock %} +
+
+
+ {% endblock %} + + {% include "base/footer.html" %} +{% endblock %} diff --git a/pydis_site/templates/wiki/base_site.html b/pydis_site/templates/wiki/base_site.html index d025e53c..afa2b41d 100644 --- a/pydis_site/templates/wiki/base_site.html +++ b/pydis_site/templates/wiki/base_site.html @@ -1,8 +1,16 @@ -{% load sekizai_tags i18n wiki_tags static %} +{% 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 %} + - {% block wiki_pagetitle %}{% endblock %}{% block wiki_site_title %} - django-\/\/ i K |{% endblock %} + Wiki | {% block wiki_pagetitle %}{% endblock %}{% block wiki_site_title %}{% endblock %} @@ -149,8 +157,6 @@ - - {% endblock %} diff --git a/pydis_site/templates/wiki/create_root.html b/pydis_site/templates/wiki/create_root.html index 73a14ae0..52f5ffb6 100644 --- a/pydis_site/templates/wiki/create_root.html +++ b/pydis_site/templates/wiki/create_root.html @@ -4,23 +4,9 @@ {% block wiki_pagetitle %}{% trans "Create root article" %}{% endblock %} {% block wiki_contents %} +

{% trans "Congratulations!" %}

- {% addtoblock "js" %} - {% for js in editor.Media.js %} - - {% endfor %} - {% endaddtoblock %} - - {% addtoblock "css" %} - {% for media, srcs in editor.Media.css.items %} - {% for src in srcs %} - - {% endfor %} - {% endfor %} - {% endaddtoblock %} - -

{% trans "Congratulations!" %}

-

+

{% trans "You have django-wiki installed... but there are no articles. So it's time to create the first one, the root article." %} {% trans "In the beginning, it will only be editable by administrators, but you can define permissions after." %}

diff --git a/pydis_site/templates/wiki/root_missing.html b/pydis_site/templates/wiki/root_missing.html index 0fb610ad..01efa4cb 100644 --- a/pydis_site/templates/wiki/root_missing.html +++ b/pydis_site/templates/wiki/root_missing.html @@ -2,36 +2,40 @@ {% load i18n wiki_tags %} {% block wiki_contents %} - -
-
-
- -

{% trans "Congratulations!" %}

-

- {% trans "You have django-wiki installed and it seems to be working. But there are no articles yet." %} -

- - {% if not user.is_superuser %} -

- {% trans "Not to worry! You simply have to login with a superuser account and create the first article in the root of the URL hierarchy." %} -

- {% login_url as wiki_login_url %} - {% if wiki_login_url %} - {% trans "Click here to login" %} - {% endif %} - - {% else %} - -

- {% trans "But since you're logged in as a superuser, we should really get started..." %} -

- {% trans "Yes, I'll go and create the first article" %} - {% trans "No thanks, I'd rather read the documentation" %} - - {% endif %} +
+
+
+
+

Congratulations!

+
+
+

+ {% trans "You have django-wiki installed and it seems to be working. But there are no articles yet." %} +

+ + {% if not user.is_superuser %} +

+ {% trans "Not to worry! You simply have to login with a superuser account and create the first article in the root of the URL hierarchy." %} +

+ + {% login_url as wiki_login_url %} + + {% if wiki_login_url %} + + {% endif %} + {% else %} +

+ {% trans "But since you're logged in as a superuser, we should really get started..." %} +

+ + Create Article + Documentation + {% endif %} +
+
+
-
-
{% endblock %} -- cgit v1.2.3 From adafc9e405434b6b5ce47eff5be0e8be9e9688b6 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 14 Apr 2019 14:44:15 +0100 Subject: Fixing up image plugin --- .gitignore | 1 + pydis_site/apps/home/urls.py | 5 ++++- pydis_site/settings.py | 5 +++++ pydis_site/templates/base/base.html | 6 ++++-- 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/.gitignore b/.gitignore index f4306438..2888775d 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,7 @@ rethinkdb_data/ # Node modules node_modules/ +media/ pip-wheel-metadata/ staticfiles/ diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/home/urls.py index dacf0a3a..34ceda40 100644 --- a/pydis_site/apps/home/urls.py +++ b/pydis_site/apps/home/urls.py @@ -1,3 +1,5 @@ +from django.conf import settings +from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include from django.views.generic import TemplateView @@ -6,6 +8,7 @@ from django.views.generic import TemplateView app_name = 'home' urlpatterns = [ path('admin/', admin.site.urls), + path('notifications/', include('django_nyt.urls')), path('wiki/', include('wiki.urls')), path('', TemplateView.as_view(template_name='home/index.html'), name='home.index'), -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 6c9af3aa..46d49f44 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -120,7 +120,9 @@ TEMPLATES = [ 'context_processors': [ 'django.template.context_processors.debug', + 'django.template.context_processors.media', 'django.template.context_processors.request', + 'django.template.context_processors.static', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', @@ -181,6 +183,9 @@ STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'pydis_site', 'static')] STATIC_ROOT = env('STATIC_ROOT', default='staticfiles') +MEDIA_URL = '/media/' +MEDIA_ROOT = env('MEDIA_ROOT', default='media') + STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', diff --git a/pydis_site/templates/base/base.html b/pydis_site/templates/base/base.html index 5b124ded..7164ce47 100644 --- a/pydis_site/templates/base/base.html +++ b/pydis_site/templates/base/base.html @@ -1,6 +1,5 @@ {# Base template, with a few basic style definitions. #} -{% load django_simple_bulma %} -{% load static %} +{% load django_simple_bulma sekizai_tags static %} @@ -22,6 +21,8 @@ > {% block head %}{% endblock %} + + {% render_block "css" %} @@ -29,5 +30,6 @@ {{ block.super }} {% endblock %} +{% render_block "js" %} -- cgit v1.2.3 From 7992729e29a18f67c6b3324a64a8fc4e58f5acb8 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 14 Apr 2019 15:04:28 +0100 Subject: Remove attachments plugin, add plugin templates --- pydis_site/settings.py | 5 +- .../templates/wiki/plugins/images/index.html | 110 ++++++++++++ .../templates/wiki/plugins/images/purge.html | 33 ++++ .../templates/wiki/plugins/images/render.html | 22 +++ .../wiki/plugins/images/revision_add.html | 33 ++++ .../templates/wiki/plugins/images/sidebar.html | 188 +++++++++++++++++++++ .../templates/wiki/plugins/links/sidebar.html | 44 +++++ .../wiki/plugins/macros/article_list.html | 14 ++ .../templates/wiki/plugins/macros/sidebar.html | 20 +++ .../wiki/plugins/notifications/menubaritem.html | 25 +++ .../wiki/plugins/notifications/settings.html | 44 +++++ .../wiki/plugins/templatetags/article_list.html | 20 +++ 12 files changed, 556 insertions(+), 2 deletions(-) create mode 100644 pydis_site/templates/wiki/plugins/images/index.html create mode 100644 pydis_site/templates/wiki/plugins/images/purge.html create mode 100644 pydis_site/templates/wiki/plugins/images/render.html create mode 100644 pydis_site/templates/wiki/plugins/images/revision_add.html create mode 100644 pydis_site/templates/wiki/plugins/images/sidebar.html create mode 100644 pydis_site/templates/wiki/plugins/links/sidebar.html create mode 100644 pydis_site/templates/wiki/plugins/macros/article_list.html create mode 100644 pydis_site/templates/wiki/plugins/macros/sidebar.html create mode 100644 pydis_site/templates/wiki/plugins/notifications/menubaritem.html create mode 100644 pydis_site/templates/wiki/plugins/notifications/settings.html create mode 100644 pydis_site/templates/wiki/plugins/templatetags/article_list.html (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 46d49f44..f7cca777 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -87,9 +87,10 @@ INSTALLED_APPS = [ 'sorl.thumbnail', 'wiki.apps.WikiConfig', - 'wiki.plugins.attachments.apps.AttachmentsConfig', - 'wiki.plugins.notifications.apps.NotificationsConfig', + 'wiki.plugins.images.apps.ImagesConfig', + 'wiki.plugins.links.apps.LinksConfig', + 'wiki.plugins.redlinks.apps.RedlinksConfig', 'wiki.plugins.macros.apps.MacrosConfig', ] diff --git a/pydis_site/templates/wiki/plugins/images/index.html b/pydis_site/templates/wiki/plugins/images/index.html new file mode 100644 index 00000000..191d5533 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/index.html @@ -0,0 +1,110 @@ +{% extends "wiki/article.html" %} +{% load wiki_tags i18n humanize wiki_thumbnails %} + + +{% block wiki_pagetitle %}{% trans "Images" %}: {{ article.current_revision.title }}{% endblock %} + +{% block wiki_contents_tab %} +

{% trans "The following images are available for this article. Copy the markdown tag to directly refer to an image from the article text." %}

+

+ + + {% trans "Back to edit page" %} + +

+ + {% for image in images %} + {% with image.current_revision.imagerevision as revision %} + + + + + + + + + + + + + + + + + + + {% endwith %} + {% empty %} + + + {% endfor %} + +
{{ revision.get_filename|default:_("No file") }}{% trans "Markdown tag" %}{% trans "Uploaded by" %}{% trans "Size" %}
+

+ {% thumbnail revision.image "250x250" as thumb %} + {{ revision.get_filename }} + {% endthumbnail %} +

+ {% if image|can_write:user %} +

+ {% if revision.deleted %} + + + {% trans "Upload and publish new image" %} +
+ + + {% trans "Restore image" %} + + {% else %} + + + {% trans "Upload replacement" %} +
+ + + {% trans "Remove image" %} + + {% endif %} + {% if article|can_moderate:user %} +
+ + + {% trans "Completely delete" %} + + {% endif %} +

+ {% endif %} +
[image:{{ image.id }}] +

{% include "wiki/includes/revision_info.html" %}

+
{{ revision.get_size|filesizeformat }}
{{ revision.width }}x{{ revision.height }} pixels +
{% trans "History" %}
+ + {% for old_revision in image.revision_set.all %} + + + + + + + + {% endfor %} +
+ {% thumbnail old_revision.imagerevision.image "50x50" crop="center" as thumb %} + {{ revision.imagerevision.get_filename }} + {% endthumbnail %} + {% include "wiki/includes/revision_info.html" with current_revision=image.current_revision revision=old_revision %}{{ old_revision.imagerevision.get_size|filesizeformat }}{{ old_revision.imagerevision.width }}x{{ old_revision.imagerevision.height }} + {% if image|can_write:user and old_revision != image.current_revision %} + + + {% trans "Revert to this version" %} + + {% endif %} +
+
+

{% trans "There are no images for this article." %}

+
+ + {% include "wiki/includes/pagination.html" %} + +{% endblock %} diff --git a/pydis_site/templates/wiki/plugins/images/purge.html b/pydis_site/templates/wiki/plugins/images/purge.html new file mode 100644 index 00000000..28b8b476 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/purge.html @@ -0,0 +1,33 @@ +{% extends "wiki/article.html" %} +{% load wiki_tags i18n humanize wiki_thumbnails %} + + +{% block wiki_pagetitle %}{% trans "Purge deletion" %}: {{ image }}{% endblock %} + +{% block wiki_contents_tab %} + {% thumbnail image.current_revision.imagerevision.image "250x250" as thumb %} +

+ {{ revision.get_filename }} +

+ {% endthumbnail %} +

+ {% trans "Purge image: Completely remove image file and all revisions." %} +

+
+ {% wiki_form form %} +
+
+
+ + + {% trans "Go back" %} + + +
+
+
+ +{% endblock %} diff --git a/pydis_site/templates/wiki/plugins/images/render.html b/pydis_site/templates/wiki/plugins/images/render.html new file mode 100644 index 00000000..d4470d98 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/render.html @@ -0,0 +1,22 @@ +{% load wiki_thumbnails i18n %}{% comment %} + This template is used for the markdown extension that renders images and captions. + + NB! Watch out for line breaks, markdown might add
s and

s. +{% endcomment %}{% with image.current_revision.imagerevision as revision %}{% spaceless %} +

+ +{% if size %} + {% thumbnail revision.image size upscale=False as thumb %} + {{ revision.get_filename }} + {% empty %} +
+ {% trans "Image not found" %} +
+ {% endthumbnail %} +{% else %} + {{ revision.get_filename }} +{% endif %} +
+
{{ caption|safe }}
+
+{% endspaceless %}{% endwith %} diff --git a/pydis_site/templates/wiki/plugins/images/revision_add.html b/pydis_site/templates/wiki/plugins/images/revision_add.html new file mode 100644 index 00000000..87ca7a08 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/revision_add.html @@ -0,0 +1,33 @@ +{% extends "wiki/article.html" %} +{% load wiki_tags i18n humanize wiki_thumbnails %} + + +{% block wiki_pagetitle %}{% trans "Replace image" %}: {{ image }}{% endblock %} + +{% block wiki_contents_tab %} + {% thumbnail image.current_revision.imagerevision.image "250x250" as thumb %} +

+ {{ revision.get_filename }} +

+ {% endthumbnail %} +

+ {% trans "Choose an image file to replace current image." %} +

+
+ {% wiki_form form %} +
+
+
+ + + {% trans "Go back" %} + + +
+
+
+ +{% endblock %} diff --git a/pydis_site/templates/wiki/plugins/images/sidebar.html b/pydis_site/templates/wiki/plugins/images/sidebar.html new file mode 100644 index 00000000..909bf6c9 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/sidebar.html @@ -0,0 +1,188 @@ +{% load i18n wiki_tags wiki_images_tags humanize wiki_thumbnails sekizai_tags %} + + +{% addtoblock "js" %} + +{% endaddtoblock %} + +{% with article|images_for_article as images %} + +
+ + {% for image in images %} + {% with image.current_revision.imagerevision as revision %} + {% thumbnail revision.image "50x50" crop="center" as thumb %} + + + + + {% endthumbnail %} + {% endwith %} + {% empty %} + + + + {% endfor %} +
+

{% trans "Image id" %}: {{ image.id }}

+

+ {% trans "Insert" %}
+ {% if image|can_write:user %} + {% trans "Replace" %} + {% endif %} +

+
+
+ {{ revision.get_filename }} +
+
{% trans "No images found for this article" %}
+
+ +

+ + {% trans "Manage images" %} » + +

+
+ +

{% trans "Add new image" %}

+ +{% if article|images_can_add:user %} + {% if form.non_field_errors %} + {% if form_error_title %}

{{ form_error_title }}

{% endif %} + {% for error_message in form.non_field_errors %} +
+ {{ error_message }} +
+ {% endfor %} + {% endif %} + + {# Include the hidden fields #} + {% for hidden in form.hidden_fields %} + {{ hidden }} + {% endfor %} + +

+ {% for field in form.visible_fields %} +

+ {% if field.label %} + + {% endif %} + {{ field }} + {% if field.errors %} +
+ {% for error in field.errors %} +
{{ error }}
+ {% endfor %} +
+ {% endif %} +
+ {% if field.help_text %} +

{{ field.help_text|safe }}

+ {% endif %} + {% endfor %} +

+ +

+ +

+{% else %} + + {% if user.is_anonymous %} + {% include "wiki/includes/anonymous_blocked.html" %} + {% else %} +

{% trans "You do not have permissions to add images." %}

+ {% endif %} +{% endif %} + +
+ +

+ {% trans "How to use images" %} +

+ +

{% trans "After uploading an image, it is attached to this particular article and can be used only here. Other users may replace the image, but older versions are kept. To show the image press the Insert button and select the options you want to use. You can use Markdown in the caption. The Markdown code syntax for images looks like this" %}
+

[image:id align:right size:orig]
+    caption indented by 4 spaces
+{% trans "Possible values for align are" %}
left | right
+{% trans "Possible values for size are" %}
small | medium | large | orig | default
+

+{% endwith %} + + diff --git a/pydis_site/templates/wiki/plugins/links/sidebar.html b/pydis_site/templates/wiki/plugins/links/sidebar.html new file mode 100644 index 00000000..45096edd --- /dev/null +++ b/pydis_site/templates/wiki/plugins/links/sidebar.html @@ -0,0 +1,44 @@ +{% load i18n sekizai_tags static %} + +

{% trans "Link to another wiki page" %}

+ +

+ {% trans "Type in something from another wiki page's title and auto-complete will help you create a tag for your wiki link. Tags for links look like this:" %}
+

+ +
[Title of link](wiki:ArticleSlug)
+ +
+ + + + +
+ +
+ +

{% trans "An external link" %}

+ +

+ {% trans "You can link to another website simply by inserting an address example.com or http://example.com or by using the markdown syntax:" %}
+

+
[Clickable text](http://example.com)
+ +{% addtoblock "js" %}{% endaddtoblock %} +{% addtoblock "js" %} + +{% endaddtoblock %} diff --git a/pydis_site/templates/wiki/plugins/macros/article_list.html b/pydis_site/templates/wiki/plugins/macros/article_list.html new file mode 100644 index 00000000..c9261f1e --- /dev/null +++ b/pydis_site/templates/wiki/plugins/macros/article_list.html @@ -0,0 +1,14 @@ +{% load i18n wiki_macro_tags %} + +{% if article_children %} +
+
    + + {% for child in article_children %} + {% article_list child depth %} + {% empty %} + {% trans "Nothing below this level" %} + {% endfor %} +
+
+{% endif %} diff --git a/pydis_site/templates/wiki/plugins/macros/sidebar.html b/pydis_site/templates/wiki/plugins/macros/sidebar.html new file mode 100644 index 00000000..31b68520 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/macros/sidebar.html @@ -0,0 +1,20 @@ +{% load i18n wiki_macro_tags %} +{% allowed_macros as macros %} + +{% for macro in macros %} +

{{ macro.short_description }}

+{{ macro.help_text|safe|linebreaks }} +{% if macro.example_code %} +
{{ macro.example_code }}
+{% endif %} +{% if macro.args %} + +{% for arg,description in macro.args.items %} + + + + +{% endfor %} +
{{ arg }}{{ description }}
+{% endif %} +{% endfor %} diff --git a/pydis_site/templates/wiki/plugins/notifications/menubaritem.html b/pydis_site/templates/wiki/plugins/notifications/menubaritem.html new file mode 100644 index 00000000..6f1b6000 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/notifications/menubaritem.html @@ -0,0 +1,25 @@ +{% load i18n sekizai_tags static %} + +
  • +
  • {% trans "No notifications" %}
  • +
  • +
  • + + + {% trans "Clear notifications list" %} + +
  • +
  • + + + {% trans "Notification settings" %} + +
  • +{% addtoblock "js" %} + +{% endaddtoblock %} +{% addtoblock "js" %}{% endaddtoblock %} diff --git a/pydis_site/templates/wiki/plugins/notifications/settings.html b/pydis_site/templates/wiki/plugins/notifications/settings.html new file mode 100644 index 00000000..51b0245e --- /dev/null +++ b/pydis_site/templates/wiki/plugins/notifications/settings.html @@ -0,0 +1,44 @@ +{% extends "wiki/base.html" %} +{% load wiki_tags i18n humanize %} + + +{% block wiki_pagetitle %}{% trans "Notifications" %}: {{ article.current_revision.title }}{% endblock %} + +{% block wiki_contents %} + +

    {% trans "Your notification settings" %}

    +

    + {% trans "Manage how often you receive notifications" %} +

    + +
    + {% include "wiki/includes/formerrors.html" with form=formset.management_form %} + {% csrf_token %} + {{ formset.management_form }} + {% for form in formset %} +
    + {% trans "Settings for" %} {{ form.instance.articlesubscriptions.count }} {% trans "articles" %} + {% include "wiki/includes/formerrors.html" with form=form %} + {% for field in form %} + {% include "wiki/includes/formfield.html" %} + {% endfor %} +
    + {% empty %} + {% trans "You are not subscribed to any notifications yet." %} + {% endfor %} + {% if formset.forms %} +
    +
    +
    + +
    +
    + {% endif %} +
    + +
    +
    +{% endblock %} diff --git a/pydis_site/templates/wiki/plugins/templatetags/article_list.html b/pydis_site/templates/wiki/plugins/templatetags/article_list.html new file mode 100644 index 00000000..842ac3cb --- /dev/null +++ b/pydis_site/templates/wiki/plugins/templatetags/article_list.html @@ -0,0 +1,20 @@ +{% load wiki_macro_tags %} + + +
  • + + {{ parent.article.current_revision.title }} + {% if not parent.article.other_read %}{% endif %} + +{% if parent.article.other_read %} + {% with parent.children.active.default_order as children %} + {% if parent.level < depth and children.count %} +
      + {% for child in children %} + {% article_list child depth %} + {% endfor %} +
    + {% endif %} + {% endwith %} +{% endif %} +
  • -- cgit v1.2.3 From 0a2d2d51cde2d70ab9f366008539fbd97059850d Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 14 Apr 2019 18:59:30 +0100 Subject: More styling - breadcrumbs and messages --- pydis_site/settings.py | 13 +++-- .../templates/wiki/includes/article_menu.html | 9 ++-- .../templates/wiki/includes/breadcrumbs.html | 59 +++++++++++----------- pydis_site/templates/wiki/includes/messages.html | 10 ++-- 4 files changed, 51 insertions(+), 40 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index f7cca777..70ec0a84 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -15,6 +15,8 @@ import sys import environ +from django.contrib.messages import constants as messages + env = environ.Env( DEBUG=(bool, False) @@ -285,9 +287,6 @@ WIKI_ACCOUNT_HANDLING = False WIKI_ACCOUNT_SIGNUP_ALLOWED = False WIKI_ANONYMOUS = True -WIKI_ANONYMOUS_CREATE = DEBUG -WIKI_ANONYMOUS_UPLOAD = DEBUG -WIKI_ANONYMOUS_WRITE = DEBUG WIKI_MARKDOWN_KWARGS = { "extension_configs": { @@ -311,3 +310,11 @@ WIKI_MARKDOWN_KWARGS = { "wiki.plugins.macros.mdx.wikilinks", ] } + +WIKI_MESSAGE_TAG_CSS_CLASS = { + messages.DEBUG: "is-info", + messages.ERROR: "is-danger", + messages.INFO: "is-primary", + messages.SUCCESS: "is-success", + messages.WARNING: "is-warning", +} diff --git a/pydis_site/templates/wiki/includes/article_menu.html b/pydis_site/templates/wiki/includes/article_menu.html index 1d9d2a12..db62d28d 100644 --- a/pydis_site/templates/wiki/includes/article_menu.html +++ b/pydis_site/templates/wiki/includes/article_menu.html @@ -4,10 +4,6 @@ + {% endwith %} +{% endif %} diff --git a/pydis_site/templates/wiki/includes/breadcrumbs.html b/pydis_site/templates/wiki/includes/breadcrumbs.html index 708edb19..a2359f39 100644 --- a/pydis_site/templates/wiki/includes/breadcrumbs.html +++ b/pydis_site/templates/wiki/includes/breadcrumbs.html @@ -1,5 +1,5 @@ -{% if urlpath and article %} -
    +{% if urlpath and article and not user.is_anonymous %} +