wordpress: finish scraper and filters

pull/773/head
Jasper van Merle 6 years ago
parent a7a3864f9a
commit 78168366cf

@ -728,6 +728,12 @@ credits = [
'CC BY',
'https://creativecommons.org/licenses/by/4.0/'
], [
'Wordpress',
'2003-2019 WordPress Foundation',
'GPLv2+',
'https://wordpress.org/about/license/'
],
[
'Yarn',
'2016-present Yarn Contributors',
'BSD',

@ -7,12 +7,19 @@ module Docs
return doc
end
article = at_css('article[id^="post-"]')
@doc = at_css('article[id^="post-"]') unless article.nil?
css('hr', '.screen-reader-text', '.table-of-contents',
'.anchor', '.toc-jump', '.source-code-links', '.user-notes',
'.show-more', '.hide-more').remove
br = /<br\s?\/?>/i
header = at_css('h1')
header.content = header.content.strip
doc.prepend_child header
# Add PHP code highlighting
css('pre').each do |node|
node['data-language'] = 'php'

@ -1,12 +1,6 @@
module Docs
class Wordpress
class EntriesFilter < Docs::EntriesFilter
def breadcrumbs
@breadcrumbs ||= css('.breadcrumbs .trail-inner a')
.map(&:content)
.map(&:strip)
end
def get_name
at_css('.breadcrumbs .trail-end').content
end
@ -18,10 +12,6 @@ module Docs
'Hooks'
elsif subpath.starts_with?('functions')
'Functions'
elsif breadcrumbs.size > 1
breadcrumbs.drop(1).join(': ')
else
at_css('.breadcrumbs .trail-end').content
end
end
end

@ -2,7 +2,7 @@ module Docs
class Wordpress < UrlScraper
self.name = 'WordPress'
self.type = 'wordpress'
self.release = '4.9.4'
self.release = '5.2.2'
self.base_url = 'https://developer.wordpress.org/reference/'
self.initial_paths = %w(
functions/
@ -15,10 +15,10 @@ module Docs
code: 'https://github.com/WordPress/WordPress'
}
html_filters.push 'wordpress/clean_html', 'wordpress/entries'
html_filters.push 'wordpress/entries', 'wordpress/clean_html'
options[:container] = '#content-area'
options[:trailing_slash] = true
options[:trailing_slash] = false
options[:only_patterns] = [
/\Afunctions\//,
/\Ahooks\//,
@ -32,7 +32,7 @@ module Docs
]
options[:attribution] = <<-HTML
&copy; 2003&ndash;2018 WordPress Foundation<br>
&copy; 2003&ndash;2019 WordPress Foundation<br>
Licensed under the GNU GPLv2+ License.
HTML
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Loading…
Cancel
Save