History

wordpress: finish scraper and filters

Jasper van Merle committed 7 years ago

Commit 78168361 parent a7a38646 files · +18 −15Browse files

Unified · Split

6 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +6 −0
  2. lib/docs/filters/wordpress/clean_html.rb +8 −1
  3. lib/docs/filters/wordpress/entries.rb +1 −11
  4. lib/docs/scrapers/wordpress.rb +5 −5
  5. public/icons/docs/wordpress/16.png +0 −0
  6. public/icons/docs/wordpress/16@2x.png +0 −0
assets/javascripts/templates/pages/about_tmpl.coffee+6−0
@@ -728,6 +728,12 @@ credits = [ · 727 unmodified lines
728728 'CC BY',
729729 'https://creativecommons.org/licenses/by/4.0/'
730730 ], [
731+ 'Wordpress',
732+ '2003-2019 WordPress Foundation',
733+ 'GPLv2+',
734+ 'https://wordpress.org/about/license/'
735+ ],
736+ [
731737 'Yarn',
732738 '2016-present Yarn Contributors',
733739 'BSD',
lib/docs/filters/wordpress/clean_html.rb+8−1
@@ -7,12 +7,19 @@ module Docs · 6 unmodified lines
77 return doc
88 end
99
10+ article = at_css('article[id^="post-"]')
11+ @doc = at_css('article[id^="post-"]') unless article.nil?
12+
1013 css('hr', '.screen-reader-text', '.table-of-contents',
1114 '.anchor', '.toc-jump', '.source-code-links', '.user-notes',
1215 '.show-more', '.hide-more').remove
1316
1417 br = /<br\s?\/?>/i
1518
19+ header = at_css('h1')
20+ header.content = header.content.strip
21+ doc.prepend_child header
22+
1623 # Add PHP code highlighting
1724 css('pre').each do |node|
1825 node['data-language'] = 'php'
@@ -29,4 +36,4 @@ module Docs · 10 unmodified lines
2936 end
3037 end
3138 end
32−end
39+end
lib/docs/filters/wordpress/entries.rb+1−11
@@ -1,12 +1,6 @@
11 module Docs
22 class Wordpress
33 class EntriesFilter < Docs::EntriesFilter
4− def breadcrumbs
5− @breadcrumbs ||= css('.breadcrumbs .trail-inner a')
6− .map(&:content)
7− .map(&:strip)
8− end
9−
104 def get_name
115 at_css('.breadcrumbs .trail-end').content
126 end
@@ -18,12 +12,8 @@ module Docs · 5 unmodified lines
1812 'Hooks'
1913 elsif subpath.starts_with?('functions')
2014 'Functions'
21− elsif breadcrumbs.size > 1
22− breadcrumbs.drop(1).join(': ')
23− else
24− at_css('.breadcrumbs .trail-end').content
2515 end
2616 end
2717 end
2818 end
29−end
19+end
lib/docs/scrapers/wordpress.rb+5−5
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
22 class Wordpress < UrlScraper
33 self.name = 'WordPress'
44 self.type = 'wordpress'
5− self.release = '4.9.4'
5+ self.release = '5.2.2'
66 self.base_url = 'https://developer.wordpress.org/reference/'
77 self.initial_paths = %w(
88 functions/
@@ -15,10 +15,10 @@ module Docs · 6 unmodified lines
1515 code: 'https://github.com/WordPress/WordPress'
1616 }
1717
18− html_filters.push 'wordpress/clean_html', 'wordpress/entries'
18+ html_filters.push 'wordpress/entries', 'wordpress/clean_html'
1919
2020 options[:container] = '#content-area'
21− options[:trailing_slash] = true
21+ options[:trailing_slash] = false
2222 options[:only_patterns] = [
2323 /\Afunctions\//,
2424 /\Ahooks\//,
@@ -32,8 +32,8 @@ module Docs · 7 unmodified lines
3232 ]
3333
3434 options[:attribution] = <<-HTML
35− &copy; 2003&ndash;2018 WordPress Foundation<br>
35+ &copy; 2003&ndash;2019 WordPress Foundation<br>
3636 Licensed under the GNU GPLv2+ License.
3737 HTML
3838 end
39−end
39+end
public/icons/docs/wordpress/16.png+0−0

Binary file not shown.

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

Binary file not shown.