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",
"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',
'MIT',
'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',
'2009-2016 The Core Less Team',

@ -170,3 +170,4 @@
._icon-homebrew:before { background-position: 0 -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-leaflet:before { background-position: -3rem -3rem; @extend %doc-icon-2; }

@ -2,18 +2,35 @@ module Docs
class Leaflet
class CleanHtmlFilter < Filter
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."
css('h2 ~ p').each do |node|
css('h1 ~ p').each do |node|
node.remove
break
end
# syntax highlighting
css('code.lang-js').each do |node|
node.parent['data-language'] = 'javascript'
node.parent.content = node.content
css('section', 'code b', '.accordion', '.accordion-overflow', '.accordion-content').each do |node|
node.before(node.children).remove
end
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
doc

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

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