1
0

http.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. module Docs
  2. class Http < Mdn
  3. include MultipleBaseUrls
  4. # release = '2022-11-17'
  5. self.name = 'HTTP'
  6. self.base_urls = [
  7. 'https://developer.mozilla.org/en-US/docs/Web/HTTP',
  8. 'https://datatracker.ietf.org/doc/html/',
  9. ]
  10. self.links = {
  11. home: 'https://developer.mozilla.org/en-US/docs/Web/HTTP',
  12. code: 'https://github.com/mdn/content/tree/main/files/en-us/web/http'
  13. }
  14. options[:attribution] = <<-HTML
  15. &copy; 2005&ndash;2023 MDN contributors.<br>
  16. Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
  17. HTML
  18. html_filters.push 'http/clean_html', 'http/entries', 'title'
  19. options[:root_title] = 'HTTP'
  20. options[:title] = ->(filter) do
  21. filter.current_url.host == 'datatracker.ietf.org' ? false : filter.default_title
  22. end
  23. options[:container] = ->(filter) do
  24. filter.current_url.host == 'datatracker.ietf.org' ? '.content' : Docs::Mdn.options[:container]
  25. end
  26. options[:skip_links] = ->(filter) do
  27. filter.current_url.host == 'datatracker.ietf.org'
  28. end
  29. options[:replace_paths] = { '/Access_control_CORS' => '/CORS' }
  30. options[:fix_urls] = ->(url) do
  31. url.sub! %r{(Status/\d\d\d)_[A-Z].+}, '\1'
  32. url
  33. end
  34. options[:attribution] = ->(filter) do
  35. if filter.current_url.host == 'datatracker.ietf.org'
  36. "&copy; document authors. All rights reserved."
  37. else
  38. Docs::Mdn.options[:attribution]
  39. end
  40. end
  41. def initial_urls
  42. %w(https://developer.mozilla.org/en-US/docs/Web/HTTP
  43. https://datatracker.ietf.org/doc/html/rfc4918
  44. https://datatracker.ietf.org/doc/html/rfc9110
  45. https://datatracker.ietf.org/doc/html/rfc9111
  46. https://datatracker.ietf.org/doc/html/rfc9112
  47. https://datatracker.ietf.org/doc/html/rfc9113
  48. https://datatracker.ietf.org/doc/html/rfc9114
  49. https://datatracker.ietf.org/doc/html/rfc5023)
  50. end
  51. end
  52. end