History

Finish Leaflet scraper

Thibaut Courouble committed 8 years ago

Commit 15f79fa1 parent 4bd451a11 files · +39 −7Browse files

Unified · Split

11 files
  1. assets/images/docs-2.png +0 −0
  2. assets/images/docs-2@2x.png +0 −0
  3. assets/javascripts/news.json +3 −0
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/global/_icons.scss +1 −0
  6. lib/docs/filters/leaflet/clean_html.rb +23 −6
  7. lib/docs/scrapers/leaflet.rb +13 −7
  8. public/icons/docs-2.pxm +0 −0
  9. public/icons/docs-2@2x.pxm +0 −0
  10. public/icons/docs/leaflet/16.png +0 −0
  11. public/icons/docs/leaflet/16@2x.png +0 −0
assets/images/docs-2.png+0−0

Binary file not shown.

assets/images/docs-2@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+3−0
@@ -1,5 +1,8 @@
1[1[
2 [2 [
3 "2018-07-08",
4 "New documentation: <a href=\"/leaflet/\">Leaflet</a>"
5 ], [
3 "2018-03-26",6 "2018-03-26",
4 "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>."7 "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>."
5 ], [8 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -375,6 +375,11 @@ credits = [ · 374 unmodified lines
375 'Taylor Otwell',375 'Taylor Otwell',
376 'MIT',376 'MIT',
377 'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt'377 'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt'
378 ], [
379 'Leaflet',
380 '2010-2018 Vladimir Agafonkin<br>&copy; 2010-2011, CloudMade<br>Maps &copy; OpenStreetMap contributors.',
381 'BSD',
382 'https://raw.githubusercontent.com/Leaflet/Leaflet/master/LICENSE'
378 ], [383 ], [
379 'Less',384 'Less',
380 '2009-2016 The Core Less Team',385 '2009-2016 The Core Less Team',
assets/stylesheets/global/_icons.scss+1−0
@@ -170,3 +170,4 @@ · 169 unmodified lines
170._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; }170._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; }
171._icon-jekyll:before { background-position: -1rem -3rem; @extend %doc-icon-2; }171._icon-jekyll:before { background-position: -1rem -3rem; @extend %doc-icon-2; }
172._icon-babel:before { background-position: -2rem -3rem; @extend %doc-icon-2; }172._icon-babel:before { background-position: -2rem -3rem; @extend %doc-icon-2; }
173._icon-leaflet:before { background-position: -3rem -3rem; @extend %doc-icon-2; }
lib/docs/filters/leaflet/clean_html.rb+23−6
@@ -2,18 +2,35 @@ module Docs · 1 unmodified line
2 class Leaflet2 class Leaflet
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 css('#toc', '.expander').remove5 css('#toc', '.expander', '.footer').remove
6
7 css('h1').each do |node|
8 node.name = 'h2'
9 end
10
11 at_css('> h2:first-child').name = 'h1'
6 12
7 # remove "This reference reflects Leaflet 1.2.0."13 # remove "This reference reflects Leaflet 1.2.0."
8 css('h2 ~ p').each do |node|14 css('h1 ~ p').each do |node|
9 node.remove15 node.remove
10 break16 break
11 end17 end
12 18
13 # syntax highlighting19 css('section', 'code b', '.accordion', '.accordion-overflow', '.accordion-content').each do |node|
14 css('code.lang-js').each do |node|20 node.before(node.children).remove
15 node.parent['data-language'] = 'javascript'21 end
16 node.parent.content = node.content22
23 css('pre > code').each do |node|
24 node['class'] ||= ''
25 lang = if node['class'].include?('lang-html') || node.content =~ /\A</
26 'html'
27 elsif node['class'].include?('lang-css')
28 'css'
29 elsif node['class'].include?('lang-js') || node['class'].include?('lang-javascript')
30 'javascript'
31 end
32 node.parent['data-language'] = lang if lang
33 node.before(node.children).remove
17 end34 end
18 35
19 doc36 doc
lib/docs/scrapers/leaflet.rb+13−7
@@ -1,10 +1,10 @@
1module Docs1module Docs
2 class Leaflet < UrlScraper2 class Leaflet < UrlScraper
3 self.name = 'Leaflet'3 self.name = 'Leaflet'
4 self.type = 'leaflet'4 self.type = 'simple'
5 self.slug = 'leaflet'5 self.slug = 'leaflet'
6 self.links = {6 self.links = {
7 home: 'http://leafletjs.com/',7 home: 'https://leafletjs.com/',
8 code: 'https://github.com/Leaflet/Leaflet'8 code: 'https://github.com/Leaflet/Leaflet'
9 }9 }
10 10
@@ -14,23 +14,29 @@ module Docs · 3 unmodified lines
14 options[:skip_links] = true14 options[:skip_links] = true
15 15
16 options[:attribution] = <<-HTML16 options[:attribution] = <<-HTML
17 &copy; 2017 <a href="http://agafonkin.com/en">Vladimir Agafonkin</a>.17 &copy; 2010&ndash;2018 Vladimir Agafonkin<br>
18 Maps &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors.</p>18 &copy; 2010&ndash;2011, CloudMade<br>
19 Maps &copy; OpenStreetMap contributors.
19 HTML20 HTML
20 21
22 version '1.3' do
23 self.release = '1.3.0'
24 self.base_url = "https://leafletjs.com/reference-#{release}.html"
25 end
26
21 version '1.2' do27 version '1.2' do
22 self.release = '1.2.0'28 self.release = '1.2.0'
23 self.base_url = "http://leafletjs.com/reference-#{release}.html"29 self.base_url = "https://leafletjs.com/reference-#{release}.html"
24 end30 end
25 31
26 version '1.1' do32 version '1.1' do
27 self.release = '1.1.0'33 self.release = '1.1.0'
28 self.base_url = "http://leafletjs.com/reference-#{release}.html"34 self.base_url = "https://leafletjs.com/reference-#{release}.html"
29 end35 end
30 36
31 version '1.0' do37 version '1.0' do
32 self.release = '1.0.3'38 self.release = '1.0.3'
33 self.base_url = "http://leafletjs.com/reference-#{release}.html"39 self.base_url = "https://leafletjs.com/reference-#{release}.html"
34 end40 end
35 41
36 end42 end
public/icons/docs-2.pxm+0−0

Binary file not shown.

public/icons/docs-2@2x.pxm+0−0

Binary file not shown.

public/icons/docs/leaflet/16.png+0−0

Binary file not shown.

public/icons/docs/leaflet/16@2x.png+0−0

Binary file not shown.