Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
howto-cards
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Annegrät Daujeumont
howto-cards
Commits
cda0a677
Verified
Commit
cda0a677
authored
4 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
add email obfuscator plugin
parent
745ff3db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
_plugins/hook_email_protect.rb
+15
-0
15 additions, 0 deletions
_plugins/hook_email_protect.rb
with
15 additions
and
0 deletions
_plugins/hook_email_protect.rb
0 → 100644
+
15
−
0
View file @
cda0a677
Jekyll
::
Hooks
.
register
([
:pages
,
:posts
,
:documents
],
:pre_render
)
do
|
post
|
# This will run every time the website is built
# Include a plugin (needs to be in gemfile)
include
Jekyll
::
EmailProtect
::
EmailProtectionFilter
# Using a simpler version of email regexp
email_regexp
=
/mailto\:(?:[\'\"]*)(?:[\w+\-]\.?)+@[a-z\d\-]+(?:\.[a-z]+)*\.[a-z]+(?:[\'\"]*)/i
# Take post's content, and transform every occurence of the following regexp (an email)
post
.
content
=
post
.
content
.
gsub
(
email_regexp
)
{
# For every occurence, apply protection function:
|
param
|
"mailto:"
+
Jekyll
::
EmailProtect
::
EmailProtectionFilter
::
encode_email
(
param
[
7
..-
1
].
delete
(
"'"
).
delete
(
'"'
))
}
end
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