html-pipeline-linuxfr 0.15.6 → 0.15.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9df546d02280ac064e0543fb19e5d92b21de5d1daf9a2b479ba248b19cf41bb9
4
- data.tar.gz: aeec21c31f8d5d37f47eba19a216ad419a9cf143321feb1529908a979621dbad
3
+ metadata.gz: 0d50e451ccb25eb9b8af0b5534a5bbf1e5c3796f0434ccaeddb4448b13574ad7
4
+ data.tar.gz: 50c040372dd5afc3aca740c4e11207f04374206dad133094ac08b697a90fcbd6
5
5
  SHA512:
6
- metadata.gz: 339b6301d9e2d24e917abcb41931300f686e7cbc1311ee1adc65cfeae0ff28555de1d2933bc772c8a98c444e13621611ad017c13bc9898a1fe0642101f27ab99
7
- data.tar.gz: 408d0b77c2a8511826997f353f439ac2caf36b784634003a02a474253fcb47c8422eb0cff9bf7e6768680e9c832c8ae1ebf753899fbabd33ad6e584d87279d6b
6
+ metadata.gz: d2b5fe6755e75b11c426985822ff8fd84e6ecdf2c7148c5a6f25722433f702813154c8e554025fbbdc5179404f1a292fa884b47d0b8490719cf263949cac3b10
7
+ data.tar.gz: d48d0301c4ea3d569b3497d9eb641c5ef3abcfe88ead396d70c128c6a53c43abbf1f084403f8f4c3562a98d99a0aab98a44fa19331021aae6778b016045680b8
@@ -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
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class Pipeline
3
- VERSION = "0.15.6"
3
+ VERSION = "0.15.7"
4
4
  end
5
5
  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.6
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-02-25 00:00:00.000000000 Z
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