devdocs/lib/docs/scrapers/http.rb

59 lines
1.9 KiB
Ruby
Raw Normal View History

2013-10-24 20:25:52 +02:00
module Docs
2017-01-22 23:09:54 +01:00
class Http < Mdn
include MultipleBaseUrls
2022-11-17 22:25:03 +01:00
# release = '2022-11-17'
2013-10-24 20:25:52 +02:00
self.name = 'HTTP'
2021-10-22 19:07:00 +02:00
self.base_urls = [
'https://developer.mozilla.org/en-US/docs/Web/HTTP',
'https://datatracker.ietf.org/doc/html/',
]
2023-04-13 16:14:01 +02:00
self.links = {
home: 'https://developer.mozilla.org/en-US/docs/Web/HTTP',
code: 'https://github.com/mdn/content/tree/main/files/en-us/web/http'
}
options[:attribution] = <<-HTML
&copy; 2005&ndash;2023 MDN contributors.<br>
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
HTML
2017-01-22 23:09:54 +01:00
html_filters.push 'http/clean_html', 'http/entries', 'title'
2013-10-24 20:25:52 +02:00
2017-01-22 23:09:54 +01:00
options[:root_title] = 'HTTP'
2021-10-22 19:07:00 +02:00
options[:title] = ->(filter) do
filter.current_url.host == 'datatracker.ietf.org' ? false : filter.default_title
end
options[:container] = ->(filter) do
filter.current_url.host == 'datatracker.ietf.org' ? '.content' : Docs::Mdn.options[:container]
2021-10-22 19:07:00 +02:00
end
options[:skip_links] = ->(filter) do
2022-11-17 22:25:03 +01:00
filter.current_url.host == 'datatracker.ietf.org'
2021-10-22 19:07:00 +02:00
end
2018-01-15 03:41:59 +01:00
options[:replace_paths] = { '/Access_control_CORS' => '/CORS' }
2017-07-16 22:54:58 +02:00
options[:fix_urls] = ->(url) do
url.sub! %r{(Status/\d\d\d)_[A-Z].+}, '\1'
url
2017-07-16 22:54:58 +02:00
end
options[:attribution] = ->(filter) do
2021-10-22 19:07:00 +02:00
if filter.current_url.host == 'datatracker.ietf.org'
2017-01-22 23:09:54 +01:00
"&copy; document authors. All rights reserved."
else
Docs::Mdn.options[:attribution]
end
2017-07-16 22:54:58 +02:00
end
2013-10-24 20:25:52 +02:00
2017-01-22 23:09:54 +01:00
def initial_urls
%w(https://developer.mozilla.org/en-US/docs/Web/HTTP
2021-10-22 19:07:00 +02:00
https://datatracker.ietf.org/doc/html/rfc4918
https://datatracker.ietf.org/doc/html/rfc9110
https://datatracker.ietf.org/doc/html/rfc9111
https://datatracker.ietf.org/doc/html/rfc9112
https://datatracker.ietf.org/doc/html/rfc9113
https://datatracker.ietf.org/doc/html/rfc9114
2021-10-22 19:07:00 +02:00
https://datatracker.ietf.org/doc/html/rfc5023)
2017-01-22 23:09:54 +01:00
end
2013-10-24 20:25:52 +02:00
end
end