[devdocsgjs/main: 1821/1867] Update HTTP documentation




commit c34bbc965c8ebac78c551939e74266cffb0596e9
Author: Simon Legner <Simon Legner gmail com>
Date:   Fri Oct 22 19:07:00 2021 +0200

    Update HTTP documentation

 assets/javascripts/vendor/raven.js  |  2 +-
 lib/docs/filters/http/clean_html.rb |  4 ++--
 lib/docs/filters/http/entries.rb    |  6 +++---
 lib/docs/scrapers/http.rb           | 40 +++++++++++++++++++++++--------------
 4 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/assets/javascripts/vendor/raven.js b/assets/javascripts/vendor/raven.js
index 176ea361..9aadd5db 100644
--- a/assets/javascripts/vendor/raven.js
+++ b/assets/javascripts/vendor/raven.js
@@ -2222,7 +2222,7 @@ function urlencode(o) {
   return pairs.join('&');
 }
 
-// borrowed from https://tools.ietf.org/html/rfc3986#appendix-B
+// borrowed from https://datatracker.ietf.org/doc/html/rfc3986#appendix-B
 // intentionally using regex and not <a/> href parsing trick because React Native and other
 // environments where DOM might not be available
 function parseUrl(url) {
diff --git a/lib/docs/filters/http/clean_html.rb b/lib/docs/filters/http/clean_html.rb
index 956233f4..6f93a7fc 100644
--- a/lib/docs/filters/http/clean_html.rb
+++ b/lib/docs/filters/http/clean_html.rb
@@ -2,7 +2,7 @@ module Docs
   class Http
     class CleanHtmlFilter < Filter
       def call
-        current_url.host == 'tools.ietf.org' ? ietf : mdn
+        current_url.host == 'datatracker.ietf.org' ? ietf : mdn
         doc
       end
 
@@ -43,7 +43,7 @@ module Docs
         end
 
         css('.selflink').each do |node|
-          node.parent['id'] = node['name']
+          node.parent['id'] = node['id']
           node.before(node.children).remove
         end
 
diff --git a/lib/docs/filters/http/entries.rb b/lib/docs/filters/http/entries.rb
index 94a17849..83106efa 100644
--- a/lib/docs/filters/http/entries.rb
+++ b/lib/docs/filters/http/entries.rb
@@ -2,7 +2,7 @@ module Docs
   class Http
     class EntriesFilter < Docs::EntriesFilter
       def get_name
-        if current_url.host == 'tools.ietf.org'
+        if current_url.host == 'datatracker.ietf.org'
           name = at_css('h1').content
           name.remove! %r{\A.+\:}
           name.remove! %r{\A.+\-\-}
@@ -22,7 +22,7 @@ module Docs
       end
 
       def get_type
-        return name if current_url.host == 'tools.ietf.org'
+        return name if current_url.host == 'datatracker.ietf.org'
 
         if slug.start_with?('Headers/Content-Security-Policy')
           'CSP'
@@ -101,7 +101,7 @@ module Docs
       LEVEL_3 = /\A(\d+)\.\d+\.\d+\z/
 
       def additional_entries
-        return [] unless current_url.host == 'tools.ietf.org'
+        return [] unless current_url.host == 'datatracker.ietf.org'
         type = nil
 
         css('a[href^="#section-"]').each_with_object([]) do |node, entries|
diff --git a/lib/docs/scrapers/http.rb b/lib/docs/scrapers/http.rb
index 9d989c6a..f1fb5ab5 100644
--- a/lib/docs/scrapers/http.rb
+++ b/lib/docs/scrapers/http.rb
@@ -2,15 +2,25 @@ module Docs
   class Http < Mdn
     include MultipleBaseUrls
 
+    # release = '2021-10-22'
     self.name = 'HTTP'
-    self.base_urls = ['https://developer.mozilla.org/en-US/docs/Web/HTTP', 'https://tools.ietf.org/html/']
+    self.base_urls = [
+      'https://developer.mozilla.org/en-US/docs/Web/HTTP',
+      'https://datatracker.ietf.org/doc/html/',
+    ]
 
     html_filters.push 'http/clean_html', 'http/entries', 'title'
 
     options[:root_title] = 'HTTP'
-    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 }
+    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
     options[:replace_paths] = { '/Access_control_CORS' => '/CORS' }
     options[:fix_urls] = ->(url) do
       url.sub! %r{(Status/\d\d\d)_[A-Z].+}, '\1'
@@ -18,7 +28,7 @@ module Docs
     end
 
     options[:attribution] = ->(filter) do
-      if filter.current_url.host == 'tools.ietf.org'
+      if filter.current_url.host == 'datatracker.ietf.org'
         "&copy; document authors. All rights reserved."
       else
         Docs::Mdn.options[:attribution]
@@ -27,16 +37,16 @@ module Docs
 
     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
-         https://tools.ietf.org/html/rfc7235
-         https://tools.ietf.org/html/rfc7540
-         https://tools.ietf.org/html/rfc5023)
+         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)
     end
   end
 end


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]