devdocs/lib/docs/scrapers/http.rb

53 lines
1.8 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-09-20 22:58:26 +02:00
# release = '2022-09-20'
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/',
]
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 .draftcontent' : Docs::Mdn.options[:container]
end
options[:skip_links] = ->(filter) do
filter.current_url.host == 'datatracker.ietf.org' ? true : false
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/rfc2616
https://datatracker.ietf.org/doc/html/rfc4918
https://datatracker.ietf.org/doc/html/rfc7230
https://datatracker.ietf.org/doc/html/rfc7231
https://datatracker.ietf.org/doc/html/rfc7232
https://datatracker.ietf.org/doc/html/rfc7233
https://datatracker.ietf.org/doc/html/rfc7234
https://datatracker.ietf.org/doc/html/rfc7235
https://datatracker.ietf.org/doc/html/rfc7540
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