Skip to content
Snippets Groups Projects
Commit b7c66240 authored by Štěpán Farka's avatar Štěpán Farka
Browse files

[ADD] donate external link handler

parent d396f659
Branches
No related tags found
2 merge requests!569Release,!567Feature/misc enhancements 12
Pipeline #8917 passed
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment