diff --git a/CHANGES b/CHANGES index f5bc97a..74ca270 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +0.3.5 2018-08-24 +- FootnoteBase as FilesystemTemplateRendererPlugin. + 0.3.4 2018-08-24 - prepared_richtext, get_prepared_richtext API. diff --git a/content_plugins/base.py b/content_plugins/base.py index 0a9f31b..187ae0d 100644 --- a/content_plugins/base.py +++ b/content_plugins/base.py @@ -1,7 +1,7 @@ import re +from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db import models -from django.template import Template from django.utils.html import mark_safe, strip_tags from django.utils.text import Truncator from django.utils.translation import ugettext_lazy as _ @@ -124,14 +124,23 @@ class FilesystemTemplateRendererPlugin(TemplateRendererPlugin): ] -class RichTextBase(StyleMixin, FilesystemTemplateRendererPlugin): +class PrepareRichtextMixin: + @property + def prepared_richtext(self): + return mark_safe(self.get_prepared_richtext(self.richtext)) + + def get_prepared_richtext(self, richtext): + return richtext + + +class RichTextBase(PrepareRichtextMixin, StyleMixin, FilesystemTemplateRendererPlugin): if USE_TRANSLATABLE_FIELDS: richtext = TranslatableCleansedRichTextField(_("text"), blank=True) else: richtext = CleansedRichTextField(_("text"), blank=True) admin_inline_baseclass = RichTextInlineBase - template_name = '_richtext.html' + template_name = 'plugins/_richtext.html' class Meta: abstract = True @@ -141,13 +150,6 @@ class RichTextBase(StyleMixin, FilesystemTemplateRendererPlugin): def __str__(self): return Truncator(strip_tags(self.richtext)).words(10, truncate=" ...") - @property - def prepared_richtext(self): - return mark_safe(self.get_prepared_richtext(self.richtext)) - - def get_prepared_richtext(self, richtext): - return richtext - # TODO Rename to SectionBreakBase class SectionBase(StyleMixin, FilesystemTemplateRendererPlugin): @@ -167,6 +169,7 @@ class SectionBase(StyleMixin, FilesystemTemplateRendererPlugin): def __str__(self): return Truncator(strip_tags(self.subheading)).words(10, truncate=" ...") + # FIXME Not need, members are accessible through {{ content.slug }} etc. def get_plugin_context(self, context=None, **kwargs): context = super().get_plugin_context(context=None, **kwargs) context['slug'] = self.slug @@ -223,7 +226,7 @@ class DownloadBase(StyleMixin, StringRendererPlugin): )) -class FootnoteBase(StringRendererPlugin): +class FootnoteBase(PrepareRichtextMixin, FilesystemTemplateRendererPlugin): # TODO Validators: index might only contain alphanumeric characters index = models.CharField(_("footnote index"), max_length=10) if USE_TRANSLATABLE_FIELDS: @@ -231,7 +234,9 @@ class FootnoteBase(StringRendererPlugin): else: richtext = CleansedRichTextField(_("footnote text"), null=True, blank=True) - html_tag = '