Unified · Split
| @@ -154,6 +154,15 @@ module Docs · 153 unmodified lines | ||
| 154 | 154 | Parser.new(string).html |
| 155 | 155 | end |
| 156 | 156 | |
| 157 | + def with_filters(*filters) | |
| 158 | + stack = FilterStack.new | |
| 159 | + stack.push(*filters) | |
| 160 | + pipeline.instance_variable_set :@filters, stack.to_a.freeze | |
| 161 | + yield | |
| 162 | + ensure | |
| 163 | + @pipeline = nil | |
| 164 | + end | |
| 165 | + | |
| 157 | 166 | module StubRootPage |
| 158 | 167 | private |
| 159 | 168 | |
| @@ -42,11 +42,9 @@ module Docs · 41 unmodified lines | ||
| 42 | 42 | end |
| 43 | 43 | |
| 44 | 44 | module ClassMethods |
| 45 | − attr_accessor :fix_redirections | |
| 46 | 45 | attr_reader :redirections |
| 47 | 46 | |
| 48 | 47 | def store_pages(store) |
| 49 | − return super unless fix_redirections | |
| 50 | 48 | instrument 'info.doc', msg: 'Fetching redirections...' |
| 51 | 49 | with_redirections do |
| 52 | 50 | instrument 'info.doc', msg: 'Building pages...' |
| @@ -84,17 +82,6 @@ module Docs · 31 unmodified lines | ||
| 84 | 82 | def additional_options |
| 85 | 83 | { redirections: self.class.redirections } |
| 86 | 84 | end |
| 87 | − | |
| 88 | − def with_filters(*filters) | |
| 89 | − stack = FilterStack.new | |
| 90 | − stack.push(*filters) | |
| 91 | − pipeline.instance_variable_set :@filters, stack.to_a.freeze | |
| 92 | − yield | |
| 93 | − ensure | |
| 94 | − @pipeline = nil | |
| 95 | − end | |
| 96 | 85 | end |
| 97 | − | |
| 98 | − include FixRedirectionsBehavior | |
| 99 | 86 | end |
| 100 | 87 | end |
| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Dom < Mdn |
| 3 | + include FixRedirectionsBehavior | |
| 4 | + | |
| 3 | 5 | self.name = 'DOM' |
| 4 | 6 | self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/API' |
| 5 | − self.fix_redirections = true | |
| 6 | 7 | |
| 7 | 8 | html_filters.push 'dom/clean_html', 'dom/entries', 'title' |
| 8 | 9 | |
| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Svg < Mdn |
| 3 | + include FixRedirectionsBehavior | |
| 4 | + | |
| 3 | 5 | self.name = 'SVG' |
| 4 | 6 | self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/SVG' |
| 5 | − self.fix_redirections = true | |
| 6 | 7 | |
| 7 | 8 | html_filters.push 'svg/clean_html', 'svg/entries', 'title' |
| 8 | 9 | |