diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index d5a0957f..281d27da 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -203,7 +203,7 @@ credits = [ 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE' ], [ 'CSS
DOM
HTTP
HTML
JavaScript
SVG
XPath', - '2005-2020 Mozilla and individual contributors', + '2005-2021 MDN contributors', 'CC BY-SA', 'https://creativecommons.org/licenses/by-sa/2.5/' ], [ diff --git a/assets/stylesheets/pages/_mdn.scss b/assets/stylesheets/pages/_mdn.scss index fb2cce38..10e144f3 100644 --- a/assets/stylesheets/pages/_mdn.scss +++ b/assets/stylesheets/pages/_mdn.scss @@ -27,6 +27,7 @@ p > code, li > code { @extend %label; } > .note, + .notecard, // MDN 2021 .notice, .warning, .overheadIndicator, diff --git a/lib/docs/filters/mdn/clean_html.rb b/lib/docs/filters/mdn/clean_html.rb index 540be3e1..b78f1def 100644 --- a/lib/docs/filters/mdn/clean_html.rb +++ b/lib/docs/filters/mdn/clean_html.rb @@ -41,6 +41,18 @@ module Docs node.parent['id'] = node['name'] node.before(node.content).remove end + css('h2 > a, h3 > a').each do |node| + node.parent.content = node.content + end + + css('.notecard > h4').each do |node| + node.name = 'strong' + end + + css('svg.deprecated').each do |node| + node.name = 'span' + node.content = node.content + end css('dt > a[id]').each do |node| next if node['href'] @@ -64,6 +76,9 @@ module Docs end # New compatibility tables + # FIXME(2021): + # - fetched from external JSON: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/alignment-baseline/bcd.json + # - https://github.com/mdn/yari/blob/master/build/bcd-urls.js css('.bc-data #Legend + dl', '.bc-data #Legend', '.bc-data #Legend_2 + dl', '.bc-data #Legend_2', '.bc-browser-name').remove diff --git a/lib/docs/filters/mdn/contribute_link.rb b/lib/docs/filters/mdn/contribute_link.rb deleted file mode 100644 index 1444bdff..00000000 --- a/lib/docs/filters/mdn/contribute_link.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Docs - class Mdn - class ContributeLinkFilter < Filter - def call - return html if current_url.host != 'developer.mozilla.org' - - html << <<-HTML.strip_heredoc -
-

- Edit this page on MDN -

-
- HTML - - html - end - end - end -end diff --git a/lib/docs/filters/svg/clean_html.rb b/lib/docs/filters/svg/clean_html.rb index 4494e875..3468cfb7 100644 --- a/lib/docs/filters/svg/clean_html.rb +++ b/lib/docs/filters/svg/clean_html.rb @@ -11,7 +11,7 @@ module Docs end def other - css('.prevnext').remove + css('.prev-next').remove if at_css('p').content.include?("\u{00AB}") at_css('p').remove diff --git a/lib/docs/scrapers/http.rb b/lib/docs/scrapers/http.rb index ab9f1407..9d989c6a 100644 --- a/lib/docs/scrapers/http.rb +++ b/lib/docs/scrapers/http.rb @@ -7,8 +7,6 @@ module Docs html_filters.push 'http/clean_html', 'http/entries', 'title' - options[:mdn_tag] = 'HTTP' - 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 } diff --git a/lib/docs/scrapers/mdn/css.rb b/lib/docs/scrapers/mdn/css.rb index abb69b3a..4c44f1f1 100644 --- a/lib/docs/scrapers/mdn/css.rb +++ b/lib/docs/scrapers/mdn/css.rb @@ -6,8 +6,6 @@ module Docs html_filters.push 'css/clean_html', 'css/entries', 'title' - options[:mdn_tag] = 'CSS' - options[:root_title] = 'CSS' options[:skip] = %w(/CSS3 /Media/Visual /paged_media /Media/TV /Media/Tactile) diff --git a/lib/docs/scrapers/mdn/dom.rb b/lib/docs/scrapers/mdn/dom.rb index a2202929..d7e13dc7 100644 --- a/lib/docs/scrapers/mdn/dom.rb +++ b/lib/docs/scrapers/mdn/dom.rb @@ -1,92 +1,12 @@ module Docs class Dom < Mdn - prepend FixInternalUrlsBehavior - prepend FixRedirectionsBehavior self.name = 'DOM' self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/API' html_filters.push 'dom/clean_html', 'dom/entries', 'title' - options[:mdn_tag] = 'XSLT_Reference' - options[:root_title] = 'DOM' - options[:skip] = %w( - /Reference - /Index - /Document_Object_Model - /document/createProcessingInstruction - /document/documentURIObject - /document/loadOverlay - /document/tooltipNode - /Document/cookie/Simple_document.cookie_framework - /DOMErrorHandler - /DOMLocator - /DOMObject - /DOMStringList - /Event/Comparison_of_Event_Targets - /Format - /IDBDatabaseException - /IndexedDB_API/Using_JavaScript_Generators_in_Firefox - /Notation - /ProcessingInstruction - /TypeInfo - /window/getAttention - /window/messageManager - /window/updateCommands - /window/pkcs11 - /OES_texture_float) - - options[:skip_patterns] = [ - /NS/, - /XPC/, - /moz/i, - /gecko/i, - /webkit/i, - /gamepad/i, - /UserData/, - /Bluetooth/, - /FMRadio/i, - /XDomainRequest/i, - /\A\/Camera/, - /\A\/Data_Store_API/, - /\A\/DataStore/, - /\A\/DeviceStorage/, - /\A\/DocumentTouch/, - /\A\/document\/xml/, - /\A\/XMLDocument/, - /\A\/DOMCursor/, - /\A\/DOMRequest/, - /\A\/InstallTrigger/, - /\A\/Entity/, - /\A\/Settings/, - /telephony/i, - /\A\/NFC_API/, - /\A\/Window\/\w+bar/i, - /\A\/Apps/, - /\A\/Contact/, - /\A\/L10n/, - /\A\/Permission/] - - options[:fix_urls] = ->(url) do - return if url.include?('_') || url.include?('?') - url.sub! 'https://developer.mozilla.org/en-US/docs/DOM/', "#{Dom.base_url}/" - url.sub! 'https://developer.mozilla.org/en/DOM/', "#{Dom.base_url}/" - url.sub! 'https://developer.mozilla.org/Web/API/', "#{Dom.base_url}/" - url.sub! "#{Dom.base_url}/Console", "#{Dom.base_url}/console" - url.sub! "#{Dom.base_url}/Document\/", "#{Dom.base_url}/document\/" - url.sub! "#{Dom.base_url}/Element", "#{Dom.base_url}/element" - url.sub! "#{Dom.base_url}/History", "#{Dom.base_url}/history" - url.sub! "#{Dom.base_url}/Location", "#{Dom.base_url}/location" - url.sub! "#{Dom.base_url}/Navigator", "#{Dom.base_url}/navigator" - url.sub! "#{Dom.base_url}/Screen", "#{Dom.base_url}/screen" - url.sub! "#{Dom.base_url}/Window\/", "#{Dom.base_url}/window\/" - url.sub! "#{Dom.base_url}/notification", "#{Dom.base_url}/Notification" - url.sub! "#{Dom.base_url}/range", "#{Dom.base_url}/Range" - url.sub! "#{Dom.base_url}/event", "#{Dom.base_url}/Event" - url.sub! '/en/DOM/Manipulating_the_browser_history', "/en-US/docs/Web/API/History_API" - url - end end end diff --git a/lib/docs/scrapers/mdn/dom_events.rb b/lib/docs/scrapers/mdn/dom_events.rb deleted file mode 100644 index 258fbcd4..00000000 --- a/lib/docs/scrapers/mdn/dom_events.rb +++ /dev/null @@ -1,26 +0,0 @@ -module Docs - class DomEvents < Mdn - prepend FixInternalUrlsBehavior - - self.name = 'DOM Events' - self.slug = 'dom_events' - self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/Events' - - html_filters.insert_after 'clean_html', 'dom_events/clean_html' - html_filters.push 'dom_events/entries', 'title' - - options[:mdn_tag] = 'events' - - options[:root_title] = 'DOM Events' - - options[:skip] = %w(/MozOrientation) - options[:skip_patterns] = [/\A\/moz/i] - - options[:fix_urls] = ->(url) do - url.sub! 'https://developer.mozilla.org/en-US/Mozilla_event_reference', DomEvents.base_url - url.sub! 'https://developer.mozilla.org/en-US/docs/Mozilla_event_reference', DomEvents.base_url - url.sub! 'https://developer.mozilla.org/en-US/docs/Web/Reference/Events', DomEvents.base_url - url - end - end -end diff --git a/lib/docs/scrapers/mdn/html.rb b/lib/docs/scrapers/mdn/html.rb index f38432f1..4b28cefd 100644 --- a/lib/docs/scrapers/mdn/html.rb +++ b/lib/docs/scrapers/mdn/html.rb @@ -7,8 +7,6 @@ module Docs html_filters.push 'html/clean_html', 'html/entries', 'title' - options[:mdn_tag] = 'HTML' - options[:root_title] = 'HTML' options[:title] = ->(filter) do diff --git a/lib/docs/scrapers/mdn/javascript.rb b/lib/docs/scrapers/mdn/javascript.rb index cea55fc8..935df61c 100644 --- a/lib/docs/scrapers/mdn/javascript.rb +++ b/lib/docs/scrapers/mdn/javascript.rb @@ -8,8 +8,6 @@ module Docs html_filters.push 'javascript/clean_html', 'javascript/entries', 'title' - options[:mdn_tag] = 'JavaScript' - options[:root_title] = 'JavaScript' # Don't want diff --git a/lib/docs/scrapers/mdn/mdn.rb b/lib/docs/scrapers/mdn/mdn.rb index 128f850b..03a1d44b 100644 --- a/lib/docs/scrapers/mdn/mdn.rb +++ b/lib/docs/scrapers/mdn/mdn.rb @@ -3,13 +3,9 @@ module Docs self.abstract = true self.type = 'mdn' - params[:raw] = 1 - params[:macros] = 1 - html_filters.push 'mdn/clean_html' - text_filters.insert_before 'attribution', 'mdn/contribute_link' - options[:rate_limit] = 200 + options[:container] = '#content > .main-page-content' options[:trailing_slash] = false options[:skip_link] = ->(link) { @@ -17,19 +13,12 @@ module Docs } options[:attribution] = <<-HTML - © 2005–2020 Mozilla and individual contributors.
+ © 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later. HTML def get_latest_version(opts) get_latest_github_commit_date('mdn', 'content', opts) end - - private - - def process_response?(response) - response.effective_url.host = 'developer.mozilla.org' if response.effective_url.host == 'wiki.developer.mozilla.org' - super && response.effective_url.query == 'raw=1¯os=1' - end end end diff --git a/lib/docs/scrapers/mdn/svg.rb b/lib/docs/scrapers/mdn/svg.rb index 66baf60d..db9de7a1 100644 --- a/lib/docs/scrapers/mdn/svg.rb +++ b/lib/docs/scrapers/mdn/svg.rb @@ -8,8 +8,6 @@ module Docs html_filters.push 'svg/clean_html', 'svg/entries', 'title' - options[:mdn_tag] = 'XSLT_Reference' - options[:root_title] = 'SVG' options[:title] = ->(filter) do diff --git a/lib/docs/scrapers/mdn/xslt_xpath.rb b/lib/docs/scrapers/mdn/xslt_xpath.rb index 359eb755..2407f0c0 100644 --- a/lib/docs/scrapers/mdn/xslt_xpath.rb +++ b/lib/docs/scrapers/mdn/xslt_xpath.rb @@ -8,8 +8,6 @@ module Docs html_filters.push 'xslt_xpath/clean_html', 'xslt_xpath/entries', 'title' - options[:mdn_tag] = 'XSLT_Reference' - options[:root_title] = 'XSLT' options[:only_patterns] = [/\A\/XSLT/, /\A\/XPath/]