Unified · Split
| @@ -91,17 +91,6 @@ module Docs · 90 unmodified lines | |||
| 91 | super | 91 | super |
| 92 | end | 92 | end |
| 93 | 93 | ||
| 94 | def decode_cloudflare_email(str) | ||
| 95 | mask = "0x#{str[0..1]}".hex | 0 | ||
| 96 | result = '' | ||
| 97 | |||
| 98 | str.chars.drop(2).each_slice(2) do |slice| | ||
| 99 | result += "%" + "0#{("0x#{slice.join}".hex ^ mask).to_s(16)}"[-2..-1] | ||
| 100 | end | ||
| 101 | |||
| 102 | URI.decode(result) | ||
| 103 | end | ||
| 104 | |||
| 105 | def clean_path(path) | 94 | def clean_path(path) |
| 106 | path = path.gsub %r{[!;:]}, '-' | 95 | path = path.gsub %r{[!;:]}, '-' |
| 107 | path = path.gsub %r{\+}, '_plus_' | 96 | path = path.gsub %r{\+}, '_plus_' |
| @@ -4,10 +4,6 @@ module Docs · 3 unmodified lines | |||
| 4 | def call | 4 | def call |
| 5 | @doc = at_css('#page-content') | 5 | @doc = at_css('#page-content') |
| 6 | 6 | ||
| 7 | css('.__cf_email__').each do |node| | ||
| 8 | node.replace(decode_cloudflare_email(node['data-cfemail'])) | ||
| 9 | end | ||
| 10 | |||
| 11 | doc | 7 | doc |
| 12 | end | 8 | end |
| 13 | end | 9 | end |
| @@ -39,10 +39,6 @@ module Docs · 38 unmodified lines | |||
| 39 | node['class'] = 'col' | 39 | node['class'] = 'col' |
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | css('.__cf_email__').each do |node| | ||
| 43 | node.replace(decode_cloudflare_email(node['data-cfemail'])) | ||
| 44 | end | ||
| 45 | |||
| 46 | css('figure.highlight').each do |node| | 42 | css('figure.highlight').each do |node| |
| 47 | code = node.at_css('code') | 43 | code = node.at_css('code') |
| 48 | node['data-language'] = code['data-lang'] | 44 | node['data-language'] = code['data-lang'] |
| @@ -40,10 +40,6 @@ module Docs · 39 unmodified lines | |||
| 40 | node['class'] = 'col' | 40 | node['class'] = 'col' |
| 41 | end | 41 | end |
| 42 | 42 | ||
| 43 | css('.__cf_email__').each do |node| | ||
| 44 | node.replace(decode_cloudflare_email(node['data-cfemail'])) | ||
| 45 | end | ||
| 46 | |||
| 47 | css('.highlight').each do |node| | 43 | css('.highlight').each do |node| |
| 48 | code = node.at_css('code') | 44 | code = node.at_css('code') |
| 49 | node['data-language'] = code['data-lang'] | 45 | node['data-language'] = code['data-lang'] |
| @@ -0,0 +1,21 @@ | |||
| 1 | # frozen_string_literal: true | ||
| 2 | |||
| 3 | module Docs | ||
| 4 | class ParseCfEmailFilter < Filter | ||
| 5 | def call | ||
| 6 | css('.__cf_email__').each do |node| | ||
| 7 | str = node['data-cfemail'] | ||
| 8 | mask = "0x#{str[0..1]}".hex | 0 | ||
| 9 | result = '' | ||
| 10 | |||
| 11 | str.chars.drop(2).each_slice(2) do |slice| | ||
| 12 | result += "%" + "0#{("0x#{slice.join}".hex ^ mask).to_s(16)}"[-2..-1] | ||
| 13 | end | ||
| 14 | |||
| 15 | node.replace(URI.decode(result)) | ||
| 16 | end | ||
| 17 | |||
| 18 | doc | ||
| 19 | end | ||
| 20 | end | ||
| 21 | end | ||
| @@ -45,10 +45,6 @@ module Docs · 44 unmodified lines | |||
| 45 | end | 45 | end |
| 46 | end | 46 | end |
| 47 | 47 | ||
| 48 | css('.__cf_email__').each do |node| | ||
| 49 | node.replace(decode_cloudflare_email(node['data-cfemail'])) | ||
| 50 | end | ||
| 51 | |||
| 52 | css('.editor').each do |node| | 48 | css('.editor').each do |node| |
| 53 | pre = node.at_css('.editor-code > pre') | 49 | pre = node.at_css('.editor-code > pre') |
| 54 | pre['data-language'] = 'javascript' | 50 | pre['data-language'] = 'javascript' |
| @@ -8,10 +8,6 @@ module Docs · 7 unmodified lines | |||
| 8 | other | 8 | other |
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | css('a.__cf_email__').each do |node| | ||
| 12 | node.replace(decode_cloudflare_email(node['data-cfemail'])) | ||
| 13 | end | ||
| 14 | |||
| 15 | # Remove code highlighting | 11 | # Remove code highlighting |
| 16 | css('pre').each do |node| | 12 | css('pre').each do |node| |
| 17 | node.content = node.content | 13 | node.content = node.content |
| @@ -22,10 +22,6 @@ module Docs · 21 unmodified lines | |||
| 22 | node.content = node.content | 22 | node.content = node.content |
| 23 | end | 23 | end |
| 24 | 24 | ||
| 25 | css('.__cf_email__').each do |node| | ||
| 26 | node.replace(decode_cloudflare_email(node['data-cfemail'])) | ||
| 27 | end | ||
| 28 | |||
| 29 | doc | 25 | doc |
| 30 | end | 26 | end |
| 31 | end | 27 | end |
| @@ -9,10 +9,6 @@ module Docs · 8 unmodified lines | |||
| 9 | 9 | ||
| 10 | css('.demo', '.guide-links', '.footer', '#ad').remove | 10 | css('.demo', '.guide-links', '.footer', '#ad').remove |
| 11 | 11 | ||
| 12 | css('.__cf_email__').each do |node| | ||
| 13 | node.replace(decode_cloudflare_email(node['data-cfemail'])) | ||
| 14 | end | ||
| 15 | |||
| 16 | # Remove code highlighting | 12 | # Remove code highlighting |
| 17 | css('figure').each do |node| | 13 | css('figure').each do |node| |
| 18 | node.name = 'pre' | 14 | node.name = 'pre' |
| @@ -43,10 +43,6 @@ module Docs · 42 unmodified lines | |||
| 43 | end | 43 | end |
| 44 | end | 44 | end |
| 45 | 45 | ||
| 46 | css('.__cf_email__').each do |node| | ||
| 47 | node.replace(decode_cloudflare_email(node['data-cfemail'])) | ||
| 48 | end | ||
| 49 | |||
| 50 | css('div.highlighter-rouge').each do |node| | 46 | css('div.highlighter-rouge').each do |node| |
| 51 | node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] | 47 | node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] |
| 52 | node.content = node.content.strip | 48 | node.content = node.content.strip |
| @@ -7,7 +7,7 @@ module Docs · 6 unmodified lines | |||
| 7 | code: 'https://github.com/ansible/ansible' | 7 | code: 'https://github.com/ansible/ansible' |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | html_filters.push 'ansible/entries', 'ansible/clean_html', 'sphinx/clean_html' | 10 | html_filters.push 'ansible/entries', 'sphinx/clean_html', 'parse_cf_email' |
| 11 | 11 | ||
| 12 | options[:skip] = %w( | 12 | options[:skip] = %w( |
| 13 | glossary.html | 13 | glossary.html |
| @@ -15,6 +15,8 @@ module Docs · 14 unmodified lines | |||
| 15 | Documentation licensed under the Creative Commons Attribution License v3.0. | 15 | Documentation licensed under the Creative Commons Attribution License v3.0. |
| 16 | HTML | 16 | HTML |
| 17 | 17 | ||
| 18 | html_filters.push 'parse_cf_email' | ||
| 19 | |||
| 18 | version '4' do | 20 | version '4' do |
| 19 | self.release = '4.0.0' | 21 | self.release = '4.0.0' |
| 20 | self.base_url = 'https://getbootstrap.com/docs/4.0/' | 22 | self.base_url = 'https://getbootstrap.com/docs/4.0/' |
| @@ -8,7 +8,7 @@ module Docs · 7 unmodified lines | |||
| 8 | code: 'https://github.com/facebook/flow' | 8 | code: 'https://github.com/facebook/flow' |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | html_filters.push 'flow/entries', 'flow/clean_html', 'title' | 11 | html_filters.push 'flow/entries', 'flow/clean_html', 'title', 'parse_cf_email' |
| 12 | 12 | ||
| 13 | options[:trailing_slash] = false | 13 | options[:trailing_slash] = false |
| 14 | options[:root_title] = 'Flow' | 14 | options[:root_title] = 'Flow' |
| @@ -7,7 +7,7 @@ module Docs · 6 unmodified lines | |||
| 7 | code: 'https://github.com/laravel/laravel' | 7 | code: 'https://github.com/laravel/laravel' |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | html_filters.push 'laravel/entries', 'laravel/clean_html' | 10 | html_filters.push 'laravel/entries', 'laravel/clean_html', 'parse_cf_email' |
| 11 | 11 | ||
| 12 | options[:container] = ->(filter) { | 12 | options[:container] = ->(filter) { |
| 13 | filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper' | 13 | filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper' |
| @@ -8,7 +8,7 @@ module Docs · 7 unmodified lines | |||
| 8 | code: 'https://github.com/nodejs/node' | 8 | code: 'https://github.com/nodejs/node' |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | html_filters.push 'node/clean_html', 'node/entries', 'title' | 11 | html_filters.push 'node/clean_html', 'node/entries', 'title', 'parse_cf_email' |
| 12 | 12 | ||
| 13 | options[:title] = false | 13 | options[:title] = false |
| 14 | options[:root_title] = 'Node.js' | 14 | options[:root_title] = 'Node.js' |
| @@ -8,7 +8,7 @@ module Docs · 7 unmodified lines | |||
| 8 | code: 'https://github.com/vuejs/vue' | 8 | code: 'https://github.com/vuejs/vue' |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | html_filters.push 'vue/entries', 'vue/clean_html' | 11 | html_filters.push 'vue/entries', 'vue/clean_html', 'parse_cf_email' |
| 12 | 12 | ||
| 13 | options[:only_patterns] = [/guide\//, /api\//] | 13 | options[:only_patterns] = [/guide\//, /api\//] |
| 14 | options[:skip] = %w(guide/team.html) | 14 | options[:skip] = %w(guide/team.html) |
| @@ -8,7 +8,7 @@ module Docs · 7 unmodified lines | |||
| 8 | code: 'https://github.com/yarnpkg/yarn' | 8 | code: 'https://github.com/yarnpkg/yarn' |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | html_filters.push 'yarn/entries', 'yarn/clean_html', 'title' | 11 | html_filters.push 'yarn/entries', 'yarn/clean_html', 'title', 'parse_cf_email' |
| 12 | 12 | ||
| 13 | options[:root_title] = 'Yarn' | 13 | options[:root_title] = 'Yarn' |
| 14 | options[:trailing_slash] = false | 14 | options[:trailing_slash] = false |