Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Commits
b7c66240
Commit
b7c66240
authored
2 years ago
by
Štěpán Farka
Browse files
Options
Downloads
Patches
Plain Diff
[ADD] donate external link handler
parent
d396f659
Branches
Branches containing commit
No related tags found
2 merge requests
!569
Release
,
!567
Feature/misc enhancements 12
Pipeline
#8917
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
donate/wagtail_hooks.py
+17
-0
17 additions, 0 deletions
donate/wagtail_hooks.py
with
17 additions
and
0 deletions
donate/wagtail_hooks.py
0 → 100644
+
17
−
0
View file @
b7c66240
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment