mdn.rb 952 B

12345678910111213141516171819202122232425262728293031323334
  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. options[:rate_limit] = 200
  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;2021 MDN contributors.<br>
  15. Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
  16. HTML
  17. def get_latest_version(opts)
  18. get_latest_github_commit_date('mdn', 'content', opts)
  19. end
  20. private
  21. def process_response?(response)
  22. response.effective_url.host = 'developer.mozilla.org' if response.effective_url.host == 'wiki.developer.mozilla.org'
  23. super && response.effective_url.query == 'raw=1&macros=1'
  24. end
  25. end
  26. end