Closes #578.
Unified · Split
| @@ -6,9 +6,9 @@ module Docs · 5 unmodified lines | ||
| 6 | 6 | name = at_css('h1').content |
| 7 | 7 | name.remove! %r{\A.+\:} |
| 8 | 8 | name.remove! %r{\A.+\-\-} |
| 9 | − rfc = slug.sub('rfc', 'RFC ') | |
| 9 | + name = 'WebDAV' if name.include?('WebDAV') | |
| 10 | 10 | "#{rfc}: #{name.strip}" |
| 11 | − elsif slug.start_with?('Status') | |
| 11 | + elsif slug.start_with?('Status/') | |
| 12 | 12 | at_css('code').content |
| 13 | 13 | else |
| 14 | 14 | name = super |
| @@ -22,7 +22,7 @@ module Docs · 7 unmodified lines | ||
| 22 | 22 | end |
| 23 | 23 | |
| 24 | 24 | def get_type |
| 25 | − return 'RFC' if current_url.host == 'tools.ietf.org' | |
| 25 | + return name if current_url.host == 'tools.ietf.org' | |
| 26 | 26 | |
| 27 | 27 | if slug.start_with?('Headers/Content-Security-Policy') |
| 28 | 28 | 'CSP' |
| @@ -38,6 +38,94 @@ module Docs · 9 unmodified lines | ||
| 38 | 38 | 'Guides' |
| 39 | 39 | end |
| 40 | 40 | end |
| 41 | + | |
| 42 | + def rfc | |
| 43 | + slug.sub('rfc', 'RFC ') | |
| 44 | + end | |
| 45 | + | |
| 46 | + SECTIONS = { | |
| 47 | + 'rfc2616' => [ | |
| 48 | + [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15], | |
| 49 | + [14], | |
| 50 | + [] | |
| 51 | + ], | |
| 52 | + 'rfc4918' => [ | |
| 53 | + [], | |
| 54 | + [11], | |
| 55 | + [] | |
| 56 | + ], | |
| 57 | + 'rfc7230' => [ | |
| 58 | + (2..9).to_a, | |
| 59 | + [], | |
| 60 | + [] | |
| 61 | + ], | |
| 62 | + 'rfc7231' => [ | |
| 63 | + [3, 8, 9], | |
| 64 | + [], | |
| 65 | + [4, 5, 6, 7] | |
| 66 | + ], | |
| 67 | + 'rfc7232' => [ | |
| 68 | + [5, 6, 7, 8], | |
| 69 | + [2, 3, 4], | |
| 70 | + [] | |
| 71 | + ], | |
| 72 | + 'rfc7233' => [ | |
| 73 | + [5, 6], | |
| 74 | + [2, 3, 4], | |
| 75 | + [] | |
| 76 | + ], | |
| 77 | + 'rfc7234' => [ | |
| 78 | + [3, 6, 7, 8], | |
| 79 | + [4, 5], | |
| 80 | + [] | |
| 81 | + ], | |
| 82 | + 'rfc7235' => [ | |
| 83 | + [2, 5, 6], | |
| 84 | + [3, 4], | |
| 85 | + [] | |
| 86 | + ] | |
| 87 | + } | |
| 88 | + | |
| 89 | + LEVEL_1 = /\A(\d+)\z/ | |
| 90 | + LEVEL_2 = /\A(\d+)\.\d+\z/ | |
| 91 | + LEVEL_3 = /\A(\d+)\.\d+\.\d+\z/ | |
| 92 | + | |
| 93 | + def additional_entries | |
| 94 | + return [] unless current_url.host == 'tools.ietf.org' | |
| 95 | + type = nil | |
| 96 | + | |
| 97 | + css('a[href^="#section-"]').each_with_object([]) do |node, entries| | |
| 98 | + id = node['href'].remove('#') | |
| 99 | + break entries if entries.any? { |e| e[1] == id } | |
| 100 | + | |
| 101 | + content = node.next.content.strip | |
| 102 | + content.remove! %r{\s*\.+\d*\z} | |
| 103 | + content.remove! %r{\A[\.\s]+} | |
| 104 | + | |
| 105 | + name = "#{content} (#{rfc})" | |
| 106 | + number = node.content.strip | |
| 107 | + | |
| 108 | + if number =~ LEVEL_1 | |
| 109 | + if SECTIONS[slug][0].include?($1.to_i) | |
| 110 | + entries << [name, id, self.name] | |
| 111 | + end | |
| 112 | + | |
| 113 | + type = content.sub(/\ Definitions\z/, 's') | |
| 114 | + if type.include?('Header Fields') | |
| 115 | + type = 'Headers' | |
| 116 | + elsif type.include?('Status Codes') | |
| 117 | + type = 'Status' | |
| 118 | + elsif type.include?('Methods') | |
| 119 | + type = 'Methods' | |
| 120 | + else | |
| 121 | + type = self.name | |
| 122 | + end | |
| 123 | + elsif (number =~ LEVEL_2 && SECTIONS[slug][1].include?($1.to_i)) || | |
| 124 | + (number =~ LEVEL_3 && SECTIONS[slug][2].include?($1.to_i)) | |
| 125 | + entries << [name, id, (name =~ /\A\d\d\d/ ? 'Status' : type )] | |
| 126 | + end | |
| 127 | + end | |
| 128 | + end | |
| 41 | 129 | end |
| 42 | 130 | end |
| 43 | 131 | end |
| @@ -17,6 +17,10 @@ module Docs · 16 unmodified lines | ||
| 17 | 17 | options[:skip_links] = ->(filter) { |
| 18 | 18 | filter.current_url.host == 'tools.ietf.org' ? true : false |
| 19 | 19 | } |
| 20 | + options[:fix_urls] = ->(url) { | |
| 21 | + url.sub! %r{(Status/\d\d\d)_[A-Z].+}, '\1' | |
| 22 | + url | |
| 23 | + } | |
| 20 | 24 | options[:attribution] = ->(filter) { |
| 21 | 25 | if filter.current_url.host == 'tools.ietf.org' |
| 22 | 26 | "© document authors. All rights reserved." |