http.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. module Docs
  2. class Http < Mdn
  3. include MultipleBaseUrls
  4. self.name = 'HTTP'
  5. self.base_urls = ['https://developer.mozilla.org/en-US/docs/Web/HTTP', 'https://tools.ietf.org/html/']
  6. html_filters.push 'http/clean_html', 'http/entries', 'title'
  7. options[:root_title] = 'HTTP'
  8. options[:title] = ->(filter) {
  9. filter.current_url.host == 'tools.ietf.org' ? false : filter.default_title
  10. }
  11. options[:container] = ->(filter) {
  12. filter.current_url.host == 'tools.ietf.org' ? '.content' : nil
  13. }
  14. options[:skip_links] = ->(filter) {
  15. filter.current_url.host == 'tools.ietf.org' ? true : false
  16. }
  17. options[:fix_urls] = ->(url) {
  18. url.sub! %r{(Status/\d\d\d)_[A-Z].+}, '\1'
  19. url
  20. }
  21. options[:attribution] = ->(filter) {
  22. if filter.current_url.host == 'tools.ietf.org'
  23. "&copy; document authors. All rights reserved."
  24. else
  25. Docs::Mdn.options[:attribution]
  26. end
  27. }
  28. def initial_urls
  29. %w(https://developer.mozilla.org/en-US/docs/Web/HTTP
  30. https://tools.ietf.org/html/rfc2616
  31. https://tools.ietf.org/html/rfc4918
  32. https://tools.ietf.org/html/rfc7230
  33. https://tools.ietf.org/html/rfc7231
  34. https://tools.ietf.org/html/rfc7232
  35. https://tools.ietf.org/html/rfc7233
  36. https://tools.ietf.org/html/rfc7234
  37. https://tools.ietf.org/html/rfc7235)
  38. end
  39. end
  40. end