Skip to content

Commit 7816836

Browse files
committed
wordpress: finish scraper and filters
1 parent a7a3864 commit 7816836

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,12 @@ credits = [
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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ def call
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 @@ def call
2936
end
3037
end
3138
end
32-
end
39+
end

lib/docs/filters/wordpress/entries.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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 @@ def get_type
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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Docs
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 @@ class Wordpress < UrlScraper
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 @@ class Wordpress < UrlScraper
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

555 Bytes
Loading
-1.54 KB
Loading

0 commit comments

Comments
 (0)