mdn.rb 672 B

123456789101112131415161718192021222324252627
  1. module Docs
  2. class Mdn < UrlScraper
  3. self.abstract = true
  4. self.type = 'mdn'
  5. params[:raw] = 1
  6. params[:macros] = 1
  7. html_filters.push 'mdn/clean_html'
  8. text_filters.insert_before 'attribution', 'mdn/contribute_link'
  9. options[:trailing_slash] = false
  10. options[:skip_link] = ->(link) { link['title'].try(:include?, 'written'.freeze) }
  11. options[:attribution] = <<-HTML
  12. &copy; 2015 Mozilla Contributors<br>
  13. Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
  14. HTML
  15. private
  16. def process_response?(response)
  17. super && response.effective_url.query == 'raw=1&macros=1'
  18. end
  19. end
  20. end