diff --git a/donate/wagtail_hooks.py b/donate/wagtail_hooks.py new file mode 100644 index 0000000000000000000000000000000000000000..5b812d9b59591b195e366a06881c8c71525c10c6 --- /dev/null +++ b/donate/wagtail_hooks.py @@ -0,0 +1,17 @@ +from django.utils.html import escape +from wagtail.core import hooks +from wagtail.core.rich_text import LinkHandler + + +class ExternalLinkHandler(LinkHandler): + identifier = "external" + + @classmethod + def expand_db_attributes(cls, attrs): + href = attrs["href"] + return '<a href="%s" target="_blank" rel="noopener nofollower">' % escape(href) + + +@hooks.register("register_rich_text_features") +def register_external_link(features): + features.register_link_type(ExternalLinkHandler)