html-pipeline-linuxfr 0.15.6 → 0.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/html/pipeline.rb +1 -0
- data/lib/html/pipeline/linuxfr.rb +4 -4
- data/lib/html/pipeline/no_follow_links_filter.rb +20 -0
- data/lib/html/pipeline/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d50e451ccb25eb9b8af0b5534a5bbf1e5c3796f0434ccaeddb4448b13574ad7
|
4
|
+
data.tar.gz: 50c040372dd5afc3aca740c4e11207f04374206dad133094ac08b697a90fcbd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2b5fe6755e75b11c426985822ff8fd84e6ecdf2c7148c5a6f25722433f702813154c8e554025fbbdc5179404f1a292fa884b47d0b8490719cf263949cac3b10
|
7
|
+
data.tar.gz: d48d0301c4ea3d569b3497d9eb641c5ef3abcfe88ead396d70c128c6a53c43abbf1f084403f8f4c3562a98d99a0aab98a44fa19331021aae6778b016045680b8
|
data/lib/html/pipeline.rb
CHANGED
@@ -31,6 +31,7 @@ module HTML
|
|
31
31
|
autoload :TableOfContentsFilter, 'html/pipeline/toc_filter'
|
32
32
|
autoload :SVGTeX, 'html/pipeline/svgtex'
|
33
33
|
autoload :SyntaxHighlightFilter, 'html/pipeline/syntax_highlight_filter'
|
34
|
+
autoload :NoFollowLinksFilter, 'html/pipeline/no_follow_links_filter'
|
34
35
|
autoload :RelativeLinksFilter, 'html/pipeline/relative_links_filter'
|
35
36
|
autoload :CustomLinksFilter, 'html/pipeline/custom_links_filter'
|
36
37
|
autoload :SanitizationFilter, 'html/pipeline/sanitization_filter'
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module HTML
|
3
2
|
class Pipeline
|
4
3
|
|
@@ -8,9 +7,9 @@ module HTML
|
|
8
7
|
toc_header: "<h2 class=\"sommaire\">Sommaire</h2>\n",
|
9
8
|
svgtex_url: "http://localhost:16000",
|
10
9
|
host: "linuxfr.org"
|
11
|
-
}
|
10
|
+
}.freeze
|
12
11
|
|
13
|
-
def self.render(text)
|
12
|
+
def self.render(text, context = {})
|
14
13
|
pipeline = HTML::Pipeline.new [
|
15
14
|
HTML::Pipeline::SVGTeX::PreFilter,
|
16
15
|
HTML::Pipeline::MarkdownFilter,
|
@@ -18,10 +17,11 @@ module HTML
|
|
18
17
|
HTML::Pipeline::TableOfContentsFilter,
|
19
18
|
HTML::Pipeline::SVGTeX::PostFilter,
|
20
19
|
HTML::Pipeline::SyntaxHighlightFilter,
|
20
|
+
HTML::Pipeline::NoFollowLinksFilter,
|
21
21
|
HTML::Pipeline::RelativeLinksFilter,
|
22
22
|
HTML::Pipeline::CustomLinksFilter,
|
23
23
|
], CONTEXT
|
24
|
-
result = pipeline.call text
|
24
|
+
result = pipeline.call text, context
|
25
25
|
result[:output].to_s
|
26
26
|
end
|
27
27
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module HTML
|
2
|
+
class Pipeline
|
3
|
+
|
4
|
+
# Add rel="nofollow" to <a> links if enabled in the context to avoid giving
|
5
|
+
# SEO juice to potential spam links.
|
6
|
+
class NoFollowLinksFilter < Filter
|
7
|
+
|
8
|
+
def call
|
9
|
+
return doc unless context[:nofollow]
|
10
|
+
|
11
|
+
doc.css("a[href]").each do |element|
|
12
|
+
element['rel'] = 'nofollow'
|
13
|
+
end
|
14
|
+
doc
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-pipeline-linuxfr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-05-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/html/pipeline/filter.rb
|
147
147
|
- lib/html/pipeline/linuxfr.rb
|
148
148
|
- lib/html/pipeline/markdown_filter.rb
|
149
|
+
- lib/html/pipeline/no_follow_links_filter.rb
|
149
150
|
- lib/html/pipeline/relative_links_filter.rb
|
150
151
|
- lib/html/pipeline/sanitization_filter.rb
|
151
152
|
- lib/html/pipeline/svgtex.rb
|