Finish Leaflet scraper

pull/822/merge
Thibaut Courouble 7 years ago
parent 4bd451a4db
commit 15f79fa488

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 41 KiB

@ -1,5 +1,8 @@
[ [
[ [
"2018-07-08",
"New documentation: <a href=\"/leaflet/\">Leaflet</a>"
], [
"2018-03-26", "2018-03-26",
"DevDocs is joining the freeCodeCamp community. Read the announcement <a href=\"https://medium.freecodecamp.org/devdocs-is-joining-the-freecodecamp-community-ae185a1c14a6\" target=\"_blank\">here</a>." "DevDocs is joining the freeCodeCamp community. Read the announcement <a href=\"https://medium.freecodecamp.org/devdocs-is-joining-the-freecodecamp-community-ae185a1c14a6\" target=\"_blank\">here</a>."
], [ ], [

@ -375,6 +375,11 @@ credits = [
'Taylor Otwell', 'Taylor Otwell',
'MIT', 'MIT',
'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt' 'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt'
], [
'Leaflet',
'2010-2018 Vladimir Agafonkin<br>&copy; 2010-2011, CloudMade<br>Maps &copy; OpenStreetMap contributors.',
'BSD',
'https://raw.githubusercontent.com/Leaflet/Leaflet/master/LICENSE'
], [ ], [
'Less', 'Less',
'2009-2016 The Core Less Team', '2009-2016 The Core Less Team',

@ -170,3 +170,4 @@
._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; } ._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; }
._icon-jekyll:before { background-position: -1rem -3rem; @extend %doc-icon-2; } ._icon-jekyll:before { background-position: -1rem -3rem; @extend %doc-icon-2; }
._icon-babel:before { background-position: -2rem -3rem; @extend %doc-icon-2; } ._icon-babel:before { background-position: -2rem -3rem; @extend %doc-icon-2; }
._icon-leaflet:before { background-position: -3rem -3rem; @extend %doc-icon-2; }

@ -2,18 +2,35 @@ module Docs
class Leaflet class Leaflet
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
css('#toc', '.expander').remove css('#toc', '.expander', '.footer').remove
css('h1').each do |node|
node.name = 'h2'
end
at_css('> h2:first-child').name = 'h1'
# remove "This reference reflects Leaflet 1.2.0." # remove "This reference reflects Leaflet 1.2.0."
css('h2 ~ p').each do |node| css('h1 ~ p').each do |node|
node.remove node.remove
break break
end end
# syntax highlighting css('section', 'code b', '.accordion', '.accordion-overflow', '.accordion-content').each do |node|
css('code.lang-js').each do |node| node.before(node.children).remove
node.parent['data-language'] = 'javascript' end
node.parent.content = node.content
css('pre > code').each do |node|
node['class'] ||= ''
lang = if node['class'].include?('lang-html') || node.content =~ /\A</
'html'
elsif node['class'].include?('lang-css')
'css'
elsif node['class'].include?('lang-js') || node['class'].include?('lang-javascript')
'javascript'
end
node.parent['data-language'] = lang if lang
node.before(node.children).remove
end end
doc doc

@ -1,10 +1,10 @@
module Docs module Docs
class Leaflet < UrlScraper class Leaflet < UrlScraper
self.name = 'Leaflet' self.name = 'Leaflet'
self.type = 'leaflet' self.type = 'simple'
self.slug = 'leaflet' self.slug = 'leaflet'
self.links = { self.links = {
home: 'http://leafletjs.com/', home: 'https://leafletjs.com/',
code: 'https://github.com/Leaflet/Leaflet' code: 'https://github.com/Leaflet/Leaflet'
} }
@ -14,23 +14,29 @@ module Docs
options[:skip_links] = true options[:skip_links] = true
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2017 <a href="http://agafonkin.com/en">Vladimir Agafonkin</a>. &copy; 2010&ndash;2018 Vladimir Agafonkin<br>
Maps &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors.</p> &copy; 2010&ndash;2011, CloudMade<br>
Maps &copy; OpenStreetMap contributors.
HTML HTML
version '1.3' do
self.release = '1.3.0'
self.base_url = "https://leafletjs.com/reference-#{release}.html"
end
version '1.2' do version '1.2' do
self.release = '1.2.0' self.release = '1.2.0'
self.base_url = "http://leafletjs.com/reference-#{release}.html" self.base_url = "https://leafletjs.com/reference-#{release}.html"
end end
version '1.1' do version '1.1' do
self.release = '1.1.0' self.release = '1.1.0'
self.base_url = "http://leafletjs.com/reference-#{release}.html" self.base_url = "https://leafletjs.com/reference-#{release}.html"
end end
version '1.0' do version '1.0' do
self.release = '1.0.3' self.release = '1.0.3'
self.base_url = "http://leafletjs.com/reference-#{release}.html" self.base_url = "https://leafletjs.com/reference-#{release}.html"
end end
end end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 826 B

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Loading…
Cancel
Save