M src/wiki/plugins/editsection/__init__.py => src/wiki/plugins/editsection/__init__.py +0 -2
@@ 1,3 1,1 @@
-from __future__ import unicode_literals
-
default_app_config = 'wiki.plugins.editsection.apps.EditSectionConfig'
M src/wiki/plugins/editsection/apps.py => src/wiki/plugins/editsection/apps.py +0 -2
@@ 1,5 1,3 @@
-from __future__ import unicode_literals
-
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
M src/wiki/plugins/editsection/markdown_extensions.py => src/wiki/plugins/editsection/markdown_extensions.py +2 -4
@@ 1,5 1,3 @@
-from __future__ import unicode_literals
-
import re
from markdown import Extension
from markdown.treeprocessors import Treeprocessor
@@ 97,8 95,8 @@ class EditSectionProcessor(Treeprocessor):
# Insert link to allow editing this section
link = etree.SubElement(child, 'a')
- link.text = "[edit]"
- link.attrib["class"] = "article-edit"
+ link.text = settings.LINK_TEXT
+ link.attrib["class"] = "article-edit-title-link"
link.attrib["href"] = self.markdown.article.get_absolute_url() \
+ "_plugin/editsection/" + location \
+ "/header/" + header_id + "/"
M src/wiki/plugins/editsection/settings.py => src/wiki/plugins/editsection/settings.py +5 -2
@@ 1,9 1,12 @@
-from __future__ import absolute_import, unicode_literals
-
from django.conf import settings as django_settings
+from django.utils.translation import gettext
SLUG = 'editsection'
#: Add "[edit]" links to all section headers till this level. By using
#: these links editing only the text from the selected section is possible.
MAX_LEVEL = getattr(django_settings, 'WIKI_EDITSECTION_MAX_LEVEL', 3)
+
+#: Text used for the section edit links which will appear next to section
+#: headers. These links allow editing only the text of one particular section.
+LINK_TEXT = getattr(django_settings, 'WIKI_EDITSECTION_LINK_TEXT', gettext("[edit]"))
M src/wiki/plugins/editsection/views.py => src/wiki/plugins/editsection/views.py +0 -2
@@ 1,5 1,3 @@
-from __future__ import absolute_import, unicode_literals
-
import re
from django.contrib import messages
from django.shortcuts import get_object_or_404, redirect
M src/wiki/plugins/editsection/wiki_plugin.py => src/wiki/plugins/editsection/wiki_plugin.py +0 -5
@@ 1,5 1,3 @@
-from __future__ import absolute_import, unicode_literals
-
from django.conf.urls import url
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
@@ 19,8 17,5 @@ class EditSectionPlugin(BasePlugin):
markdown_extensions = [EditSectionExtension()]
- def __init__(self):
- pass
-
registry.register(EditSectionPlugin)
M src/wiki/static/wiki/bootstrap/less/wiki/wiki.less => src/wiki/static/wiki/bootstrap/less/wiki/wiki.less +1 -1
@@ 21,7 21,7 @@
h1#article-title {font-size: 2.5em; margin-top: 0px;}
-.article-edit {font-size: @font-size-base; padding-left: 8px}
+.article-edit-title-link {font-size: @font-size-base; padding-left: 8px}
.wiki-label label { font-size: 16px; font-weight: normal; color: #777;}
M testproject/testproject/settings/base.py => testproject/testproject/settings/base.py +1 -1
@@ 47,7 47,7 @@ INSTALLED_APPS = [
"wiki.plugins.images.apps.ImagesConfig",
"wiki.plugins.attachments.apps.AttachmentsConfig",
"wiki.plugins.notifications.apps.NotificationsConfig",
- 'wiki.plugins.editsection.apps.GlobalHistoryConfig',
+ 'wiki.plugins.editsection.apps.EditSectionConfig',
'wiki.plugins.globalhistory.apps.GlobalHistoryConfig',
'mptt',
]
M tests/core/test_models.py => tests/core/test_models.py +3 -3
@@ 134,8 134,8 @@ class ArticleModelTest(TestCase):
ArticleRevision.objects.create(
article=a, title="test", content="# header"
)
- expected_markdown = (
+ expected = (
"""<h1 id="wiki-toc-header">header"""
- """<a class="article-edit" href="/1/_plugin/editsection/1-0-0/header/h/">[edit]</a></h1>"""
+ """.*</h1>"""
)
- self.assertEqual(a.get_cached_content(), expected_markdown)
+ self.assertRegexpMatches(a.get_cached_content(), expected)
M tests/core/test_template_tags.py => tests/core/test_template_tags.py +5 -5
@@ 195,10 195,10 @@ class WikiRenderTest(TemplateTestCase):
"""========\n"""
)
- expected_markdown = (
- """<p>This is a normal paragraph</p>\n"""
+ expected = (
+ """(?s).*<p>This is a normal paragraph</p>\n"""
"""<h1 id="wiki-toc-headline">Headline"""
- """<a class="article-edit" href="/1/_plugin/editsection/1-0-0/header/H/">[edit]</a></h1>"""
+ """.*</h1>.*"""
)
# monkey patch
@@ 208,14 208,14 @@ class WikiRenderTest(TemplateTestCase):
output = wiki_render({}, article, preview_content=content)
self.assertCountEqual(self.keys, output)
self.assertEqual(output['article'], article)
- self.assertMultiLineEqual(output['content'], expected_markdown)
+ self.assertRegexpMatches(output['content'], expected)
self.assertIs(output['preview'], True)
self.assertEqual(output['plugins'], {'spam': 'eggs'})
self.assertEqual(output['STATIC_URL'], django_settings.STATIC_URL)
self.assertEqual(output['CACHE_TIMEOUT'], settings.CACHE_TIMEOUT)
output = self.render({'article': article, 'pc': content})
- self.assertIn(expected_markdown, output)
+ self.assertRegexpMatches(output, expected)
def test_called_with_preview_content_and_article_dont_have_current_revision(
self):
M tests/plugins/editsection/test_editsection.py => tests/plugins/editsection/test_editsection.py +11 -11
@@ 29,12 29,12 @@ class EditSectionTests(RequireRootArticleMixin, DjangoClientTestBase):
output = urlpath.article.render()
expected = (
'(?s)'
- 'Title 1<a class="article-edit" href="/testedit/_plugin/editsection/1-0-0/header/T1/">\[edit\]</a>.*'
- 'Title 2<a class="article-edit" href="/testedit/_plugin/editsection/1-1-0/header/T2/">\[edit\]</a>.*'
- 'Title 3<a class="article-edit" href="/testedit/_plugin/editsection/1-2-0/header/T3/">\[edit\]</a>.*'
- 'Title 4<a class="article-edit" href="/testedit/_plugin/editsection/1-2-1/header/T4/">\[edit\]</a>.*'
- 'Title 5<a class="article-edit" href="/testedit/_plugin/editsection/1-3-0/header/T5/">\[edit\]</a>.*'
- 'Title 6<a class="article-edit" href="/testedit/_plugin/editsection/2-0-0/header/T6/">\[edit\]</a>.*'
+ 'Title 1<a class="article-edit-title-link" href="/testedit/_plugin/editsection/1-0-0/header/T1/">\[edit\]</a>.*'
+ 'Title 2<a class="article-edit-title-link" href="/testedit/_plugin/editsection/1-1-0/header/T2/">\[edit\]</a>.*'
+ 'Title 3<a class="article-edit-title-link" href="/testedit/_plugin/editsection/1-2-0/header/T3/">\[edit\]</a>.*'
+ 'Title 4<a class="article-edit-title-link" href="/testedit/_plugin/editsection/1-2-1/header/T4/">\[edit\]</a>.*'
+ 'Title 5<a class="article-edit-title-link" href="/testedit/_plugin/editsection/1-3-0/header/T5/">\[edit\]</a>.*'
+ 'Title 6<a class="article-edit-title-link" href="/testedit/_plugin/editsection/2-0-0/header/T6/">\[edit\]</a>.*'
)
self.assertRegexpMatches(output, expected)
@@ 84,12 84,12 @@ class EditSectionEditTests(EditSectionEditBase, WebTestBase):
self.submit('#id_save')
expected = (
'(?s)'
- 'Title 1<a class="article-edit" href="/testedit/_plugin/editsection/1-0-0/header/T1/">\[edit\]</a>.*'
- 'Title 2<a class="article-edit" href="/testedit/_plugin/editsection/1-1-0/header/T2/">\[edit\]</a>.*'
- 'Header 1<a class="article-edit" href="/testedit/_plugin/editsection/2-0-0/header/H1/">\[edit\]</a>.*'
+ 'Title 1<a class="article-edit-title-link" href="/testedit/_plugin/editsection/1-0-0/header/T1/">\[edit\]</a>.*'
+ 'Title 2<a class="article-edit-title-link" href="/testedit/_plugin/editsection/1-1-0/header/T2/">\[edit\]</a>.*'
+ 'Header 1<a class="article-edit-title-link" href="/testedit/_plugin/editsection/2-0-0/header/H1/">\[edit\]</a>.*'
'Content of the new section.*'
- 'Title 5<a class="article-edit" href="/testedit/_plugin/editsection/2-1-0/header/T5/">\[edit\]</a>.*'
- 'Title 6<a class="article-edit" href="/testedit/_plugin/editsection/3-0-0/header/T6/">\[edit\]</a>.*'
+ 'Title 5<a class="article-edit-title-link" href="/testedit/_plugin/editsection/2-1-0/header/T5/">\[edit\]</a>.*'
+ 'Title 6<a class="article-edit-title-link" href="/testedit/_plugin/editsection/3-0-0/header/T6/">\[edit\]</a>.*'
)
self.assertRegexpMatches(self.last_response.content.decode('utf-8'), expected)