Skip to content

Commit

Permalink
Merge branch 'master' into support-multiple-references-to-footnotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsma committed Aug 23, 2022
2 parents 001bdab + 21a3ad5 commit e1bf09c
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 18 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Wagtail Footnotes Changelog

## 0.8.0

- Add support for Wagtail 3.0 and drop support for all Wagtail versions
before 2.15
- Dropped support for all Django versions
before 3.2
- Removed support for Python 3.6
- Fix previews https://github.com/torchbox/wagtail-footnotes/pull/24 - [@jsma](https://github.com/jsma)

## 0.7.0

- Clean up old step from README - It is no longer recommended to define footnotes in `WAGTAILADMIN_RICH_TEXT_EDITORS`
Expand Down
9 changes: 4 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = wagtail-footnotes
author = Cameron Lamb
author_email = cameron.lamb@torchbox.com
description = Add footnotes to rich text in your wagtail pages
version = 0.7.0
description = Add footnotes to rich text in your Wagtail pages
version = 0.8.1
url = https://github.com/torchbox/wagtail-footnotes
keywords =
wagtail
Expand All @@ -14,12 +14,11 @@ license_files =
LICENSE.txt

[options]
python_requires = >= 3.6
python_requires = >= 3.7
setup_requires =
setuptools >= 40.6
pip >= 10
include_package_data = true
packages = find:
install_requires =
Django>=2.2, <3.3
wagtail>=2.5, <3
wagtail>=2.15, <4.0
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from setuptools import setup

setup()
# Redefine `name` here so GitHub’s "Used By" can detect the package.
setup(name="wagtail-footnotes")
16 changes: 13 additions & 3 deletions wagtail_footnotes/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@

from django.core.exceptions import ValidationError
from django.utils.safestring import mark_safe
from wagtail.core.blocks import RichTextBlock
from wagtail.core.models import Page

try:
from wagtail.blocks import RichTextBlock
except ImportError:
# Wagtail<3.0
from wagtail.core.blocks import RichTextBlock

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page


FIND_FOOTNOTE_TAG = re.compile(r'<footnote id="(.*?)">.*?</footnote>')

Expand Down Expand Up @@ -40,7 +50,7 @@ def replace_footnote_tags(self, value, html, context=None):
page.footnotes_list = []
if not hasattr(page, "footnotes_references"):
page.footnotes_references = defaultdict(list)
self.footnotes = {footnote.uuid: footnote for footnote in page.footnotes.all()}
self.footnotes = {str(footnote.uuid): footnote for footnote in page.footnotes.all()}

def replace_tag(match):
footnote_uuid = match.group(1)
Expand Down
13 changes: 10 additions & 3 deletions wagtail_footnotes/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

import django.db.models.deletion
import modelcluster.fields
import wagtail.core.fields
import wagtail_footnotes.fields

try:
import wagtail.fields as wagtail_fields
except ImportError:
# Wagtail<3.0
import wagtail.core.fields as wagtail_fields

from django.db import migrations, models

import wagtail_footnotes.fields


class Migration(migrations.Migration):

Expand Down Expand Up @@ -36,7 +43,7 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
("text", wagtail.core.fields.RichTextField()),
("text", wagtail_fields.RichTextField()),
(
"page",
modelcluster.fields.ParentalKey(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Django 3.2.4 on 2021-06-24 10:18

from django.db import migrations

import wagtail_footnotes.fields


Expand Down
14 changes: 12 additions & 2 deletions wagtail_footnotes/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
from django.conf import settings
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel
from wagtail.core.fields import RichTextField

try:
from wagtail.admin.panels import FieldPanel, InlinePanel
except ImportError:
# Wagtail<3.0
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel

try:
from wagtail.fields import RichTextField
except ImportError:
# Wagtail<3.0
from wagtail.core.fields import RichTextField

from .fields import CustomUUIDField
from .widgets import ReadonlyUUIDInput
Expand Down
12 changes: 8 additions & 4 deletions wagtail_footnotes/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
from django.templatetags.static import static
from django.utils.html import format_html_join
from draftjs_exporter.dom import DOM
from wagtail.admin.rich_text.converters.html_to_contentstate import (
InlineEntityElementHandler,
)
from wagtail.core import hooks
from wagtail.admin.rich_text.converters.html_to_contentstate import \
InlineEntityElementHandler

try:
from wagtail import hooks
except ImportError:
# Wagtail<3.0
from wagtail.core import hooks


@hooks.register("register_rich_text_features")
Expand Down

0 comments on commit e1bf09c

Please sign in to comment.