mdn.rb 811 B

1234567891011121314151617181920212223242526272829
  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', 'images'
  8. text_filters.insert_before 'attribution', 'mdn/contribute_link'
  9. options[:trailing_slash] = false
  10. options[:skip_link] = ->(link) {
  11. link['title'].try(:include?, 'not yet been written'.freeze) && !link['href'].try(:include?, 'transform-function'.freeze)
  12. }
  13. options[:attribution] = <<-HTML
  14. &copy; 2005&ndash;2017 Mozilla Developer Network and individual contributors.<br>
  15. Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
  16. HTML
  17. private
  18. def process_response?(response)
  19. super && response.effective_url.query == 'raw=1&macros=1'
  20. end
  21. end
  22. end