devdocs/lib/docs/scrapers/http.rb

43 lines
1.5 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
2013-10-24 20:25:52 +02:00
self.name = 'HTTP'
2017-01-22 23:09:54 +01:00
self.base_urls = ['https://developer.mozilla.org/en-US/docs/Web/HTTP', 'https://tools.ietf.org/html/']
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'
2017-07-16 22:54:58 +02:00
options[:title] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? false : filter.default_title }
options[:container] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? '.content' : nil }
options[:skip_links] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? true : false }
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
2017-01-22 23:09:54 +01:00
if filter.current_url.host == 'tools.ietf.org'
"&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
https://tools.ietf.org/html/rfc2616
https://tools.ietf.org/html/rfc4918
https://tools.ietf.org/html/rfc7230
https://tools.ietf.org/html/rfc7231
https://tools.ietf.org/html/rfc7232
https://tools.ietf.org/html/rfc7233
https://tools.ietf.org/html/rfc7234
2017-07-16 22:54:58 +02:00
https://tools.ietf.org/html/rfc7235
2020-11-18 23:14:48 +01:00
https://tools.ietf.org/html/rfc7540
2017-07-16 22:54:58 +02:00
https://tools.ietf.org/html/rfc5023)
2017-01-22 23:09:54 +01:00
end
2013-10-24 20:25:52 +02:00
end
end