mdn.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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[:rate_limit] = 200
  10. options[:trailing_slash] = false
  11. options[:skip_link] = ->(link) {
  12. link['title'].try(:include?, 'not yet been written'.freeze) && !link['href'].try(:include?, 'transform-function'.freeze)
  13. }
  14. options[:attribution] = <<-HTML
  15. &copy; 2005&ndash;2020 Mozilla and individual contributors.<br>
  16. Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
  17. HTML
  18. def get_latest_version(opts)
  19. get_latest_github_commit_date('mdn', 'content', opts)
  20. end
  21. private
  22. def process_response?(response)
  23. response.effective_url.host = 'developer.mozilla.org' if response.effective_url.host == 'wiki.developer.mozilla.org'
  24. super && response.effective_url.query == 'raw=1&macros=1'
  25. end
  26. end
  27. end