mirror of https://github.com/freeCodeCamp/devdocs
parent
cce7c49152
commit
21443dc914
@ -0,0 +1,14 @@
|
||||
module Docs
|
||||
class WebExtensions
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
|
||||
# Remove all the cruft.
|
||||
content = at_css('main#content')
|
||||
content.at_css('aside.metadata').remove
|
||||
|
||||
content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,28 @@
|
||||
module Docs
|
||||
class WebExtensions
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
at_css('main#content h1').text
|
||||
end
|
||||
|
||||
def get_type
|
||||
slug_parts = slug.split('/')
|
||||
if slug_parts[0] == 'API' and slug_parts.length() > 1
|
||||
if slug_parts[1] == 'WebRequest'
|
||||
return 'webRequest'
|
||||
else
|
||||
return slug_parts[1]
|
||||
end
|
||||
elsif slug_parts[0] == 'manifest.json'
|
||||
return slug_parts[0]
|
||||
elsif slug_parts[0] == 'user_interface'
|
||||
return 'User Interface'
|
||||
elsif slug_parts.length() > 1
|
||||
return slug_parts[0]
|
||||
else
|
||||
return 'Miscellaneous'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
module Docs
|
||||
class WebExtensions < UrlScraper
|
||||
self.name = 'Web Extensions'
|
||||
self.slug = 'web_extensions'
|
||||
self.type = 'simple'
|
||||
self.links = {
|
||||
home: 'https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions'
|
||||
}
|
||||
|
||||
self.base_url = 'https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions'
|
||||
|
||||
html_filters.push 'web_extensions/entries', 'web_extensions/clean_html'
|
||||
|
||||
options[:skip_patterns] = [
|
||||
/\/contributors\.txt$/
|
||||
]
|
||||
|
||||
options[:attribution] = -> (filter) {
|
||||
<<-HTML
|
||||
<a href="#{filter.current_url}">#{filter.result()[:entries][0].name}</a> © 2005-2021 Mozilla and individual contributors.<br>
|
||||
Licensed under the <a href="https://creativecommons.org/licenses/by-sa/2.5/">Creative Commons Attribution-ShareAlike license</a>
|
||||
HTML
|
||||
}
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in new issue