diff --git a/mainpage/settings.py b/mainpage/settings.py index ba9787c0..60978d21 100644 --- a/mainpage/settings.py +++ b/mainpage/settings.py @@ -174,6 +174,16 @@ WIKI_LOCK_DURATION = 30 WIKI_URL_RE = r"[:\-\w ]+" WIKI_WORD_RE = r"[:\-\w ]+" +# List pages below the URL '/wiki/...' here if they are dynamically created +WIKI_SPECIAL_PAGES = [ + "list", + "search", + "history", + "feeds", + "observe", + "edit", + "tag_list", +] ###################### # User configuration # @@ -203,9 +213,14 @@ #################### # threadedcomments # #################### - DEFAULT_MARKUP = 1 # "markdown" +################## +# django-tagging # +################## +FORCE_LOWERCASE_TAGS = True +MAX_TAG_LENGTH = 20 + ################################## # Uploading files and validation # ################################## diff --git a/mainpage/templatetags/wl_markdown.py b/mainpage/templatetags/wl_markdown.py index b3f720d8..ceb0569e 100644 --- a/mainpage/templatetags/wl_markdown.py +++ b/mainpage/templatetags/wl_markdown.py @@ -142,7 +142,7 @@ def _classify_link(tag): return # Wiki special pages are also not counted - if article_name in ["list", "search", "history", "feeds", "observe", "edit"]: + if article_name in settings.WIKI_SPECIAL_PAGES: tag["class"] = "specialLink" return diff --git a/wiki/models.py b/wiki/models.py index 97cfca83..90cd5b8b 100644 --- a/wiki/models.py +++ b/wiki/models.py @@ -13,7 +13,7 @@ from django.contrib.contenttypes.fields import GenericRelation, GenericForeignKey from tagging.fields import TagField -from tagging.models import Tag + from wlimages.models import Image try: diff --git a/wiki/static/css/wiki.css b/wiki/static/css/wiki.css index 5216b900..bb356889 100644 --- a/wiki/static/css/wiki.css +++ b/wiki/static/css/wiki.css @@ -9,7 +9,7 @@ float: right; max-width: 20em; } - + .toc ul { padding-left: 1.8em; } @@ -59,7 +59,7 @@ text-align: left; } -#edit_wiki_page_form #id_title,#id_comment { +#edit_wiki_page_form #id_title, #id_comment, #id_tags { width: 100%; } diff --git a/wiki/templates/wiki/edit.html b/wiki/templates/wiki/edit.html index d336525f..7a32e320 100644 --- a/wiki/templates/wiki/edit.html +++ b/wiki/templates/wiki/edit.html @@ -16,19 +16,19 @@ $(document).ready(function() { // Insert rendered markup for preview - $("#id_preview").click(function(){ + $("#id_preview").click(function(){ // Activate preview $("#preview").html("

Preview

\n
\n
Loading...
\n
"); - $("#content_preview").load( "{% url 'wiki_preview' %}", + $("#content_preview").load( "{% url 'wiki_preview' %}", {"body": $("#id_content").val()}); }); - {% ifequal new_article 0 %} - // Insert diff - $("#id_diff").click(function(){ + {% ifequal new_article 0 %} + // Insert diff + $("#id_diff").click(function(){ // Activate preview $("#diff").html("

Diff

\n
\n
Loading...
\n
"); - $("#content_diff").load( "{% url 'wiki_preview_diff' %}", + $("#content_diff").load( "{% url 'wiki_preview_diff' %}", {"body": $("#id_content").val(), "article": {{ object_id }} }); }); {%endifequal%} @@ -54,6 +54,7 @@

{% trans "Editing" %} {{ article.title }}

{% endif %}

You can edit the wiki pages contents using the syntax described on the WikiSyntax. + For a description of the input fields see: WikiHelp

@@ -70,6 +71,17 @@

{% trans "Editing" %} {{ article.title }}

{{ form.content.errors }}{{ form.content }} + + + + + + Help for tags + Help for Tags + + + + {{ form.tags.errors }}{{ form.tags }} {{ form.summary.errors }}{{ form.summary }} @@ -91,7 +103,7 @@

{% trans "Editing" %} {{ article.title }}

{% csrf_token %} - +

Images

{% if new_article %} diff --git a/wiki/templates/wiki/index.html b/wiki/templates/wiki/index.html index 7996f4f1..05cadcc8 100644 --- a/wiki/templates/wiki/index.html +++ b/wiki/templates/wiki/index.html @@ -18,6 +18,7 @@

Wiki: Index

{% trans "Page" %} {% trans "Summary" %} {% trans "Last update" %} + {% trans "Tagged with" %} @@ -26,6 +27,7 @@

Wiki: Index

{{ article.title }} {{ article.summary }} {{ article.last_update|custom_date:user }} + {% include "wiki/inlines/tag_urls.html" %} {% endfor %} diff --git a/wiki/templates/wiki/inlines/tag_urls.html b/wiki/templates/wiki/inlines/tag_urls.html new file mode 100644 index 00000000..4097726f --- /dev/null +++ b/wiki/templates/wiki/inlines/tag_urls.html @@ -0,0 +1,11 @@ +{% load tagging_tags %} + +{% tags_for_object article as tag_list %} + {% for t in tag_list %} + {% if t != tag %} + {% comment %}the forloop.last needs to be in every line to prevent a space after the tag {% endcomment %} + {{t.name}}{% if not forloop.last %},{% endif %} + {% else %} + {{ t.name }}{% if not forloop.last %},{% endif %} + {% endif %} + {% endfor %} diff --git a/wiki/templates/wiki/tag_view.html b/wiki/templates/wiki/tag_view.html new file mode 100644 index 00000000..e777bae8 --- /dev/null +++ b/wiki/templates/wiki/tag_view.html @@ -0,0 +1,33 @@ +{% extends 'wiki/base.html' %} +{% load i18n %} +{% load wiki_extras %} + +{% block title %} +{{ article.title }} - {{block.super}} +{% endblock %} + + +{% block content_header %} +

Articles with tag '{{ tag.name }}'

+{% endblock %} + +{% block content_main %} +
+ + + + + + + + + {% for article in object_list %} + + + + + + {% endfor %} +
Article nameTagged with
{{ article }}{% include "wiki/inlines/tag_urls.html" %}
+{% endblock %} + diff --git a/wiki/templates/wiki/view.html b/wiki/templates/wiki/view.html index b5308dc1..6234a30b 100644 --- a/wiki/templates/wiki/view.html +++ b/wiki/templates/wiki/view.html @@ -1,6 +1,7 @@ {% extends 'wiki/base.html' %} {% load i18n %} {% load wiki_extras %} +{% load tagging_tags %} {% block title %} {{ article.title }} - {{block.super}} @@ -43,7 +44,18 @@

{{ article.title }}

({% trans "Viewing revision " %} {{ revision }})

{% endif %} + {% if outdated %} +

Outdated

+

This article is marked as outdated. + If you are familiar with this topic, please consider updating and improving this page. + In case of any questions, please ask in the forum! For pointers see WikiHelp in our wiki. + After finishing your work remove the 'outdated' tag.

+ {% endif %} {% render_content article %} + {% tags_for_object article as tag_list %} + {% if tag_list %} +
Tagged with: {% include "wiki/inlines/tag_urls.html" %}
+ {% endif %}
{% endblock %} diff --git a/wiki/urls.py b/wiki/urls.py index 9863cd5f..00214e10 100644 --- a/wiki/urls.py +++ b/wiki/urls.py @@ -11,6 +11,9 @@ RssArticleHistoryFeed, AtomArticleHistoryFeed, ) +from wiki.models import Article +from tagging.views import TaggedObjectList + urlpatterns = [ # Redirects @@ -96,4 +99,13 @@ views.backlinks, name="backlinks", ), + url( + r"^tag_list/(?P[^/]+(?u))/$", + TaggedObjectList.as_view( + model=Article, + allow_empty=True, + template_name="wiki/tag_view.html", + ), + name="article_tag_detail", + ), ] diff --git a/wiki/views.py b/wiki/views.py index cca7c027..98822808 100644 --- a/wiki/views.py +++ b/wiki/views.py @@ -27,6 +27,8 @@ from mainpage.wl_utils import get_real_ip from mainpage.wl_utils import get_valid_cache_key +from tagging.models import Tag + import re import urllib.request, urllib.parse, urllib.error @@ -226,11 +228,16 @@ def view_article( changeset = get_object_or_404(article.changeset_set, revision=revision) article.content = changeset.get_content() + outdated = False + tags = [x.name for x in Tag.objects.get_for_object(article)] + if "outdated" in tags: + outdated = True template_params = { "article": article, "revision": revision, "redirected_from": redirected_from, "allow_write": allow_write, + "outdated": outdated, } if notification is not None: