[devdocsgjs/main: 781/1867] wordpress: finish scraper and filters




commit 78168366cf67c0fc3dbff9e6c64425fbc74a5a1e
Author: Jasper van Merle <jaspervmerle gmail com>
Date:   Mon Aug 12 00:32:37 2019 +0200

    wordpress: finish scraper and filters

 assets/javascripts/templates/pages/about_tmpl.coffee |   6 ++++++
 lib/docs/filters/wordpress/clean_html.rb             |   9 ++++++++-
 lib/docs/filters/wordpress/entries.rb                |  12 +-----------
 lib/docs/scrapers/wordpress.rb                       |  10 +++++-----
 public/icons/docs/wordpress/16.png                   | Bin 958 -> 1513 bytes
 public/icons/docs/wordpress/16 2x png                | Bin 3284 -> 1703 bytes
 6 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee 
b/assets/javascripts/templates/pages/about_tmpl.coffee
index 81e1e5b7..37d14eea 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -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',
diff --git a/lib/docs/filters/wordpress/clean_html.rb b/lib/docs/filters/wordpress/clean_html.rb
index 42ca5f29..32cf3b3f 100644
--- a/lib/docs/filters/wordpress/clean_html.rb
+++ b/lib/docs/filters/wordpress/clean_html.rb
@@ -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'
@@ -29,4 +36,4 @@ module Docs
       end
     end
   end
-end
\ No newline at end of file
+end
diff --git a/lib/docs/filters/wordpress/entries.rb b/lib/docs/filters/wordpress/entries.rb
index bfcd10b3..ba539d67 100644
--- a/lib/docs/filters/wordpress/entries.rb
+++ b/lib/docs/filters/wordpress/entries.rb
@@ -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,12 +12,8 @@ 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
   end
-end
\ No newline at end of file
+end
diff --git a/lib/docs/scrapers/wordpress.rb b/lib/docs/scrapers/wordpress.rb
index 472013ac..58e42cb8 100644
--- a/lib/docs/scrapers/wordpress.rb
+++ b/lib/docs/scrapers/wordpress.rb
@@ -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,8 +32,8 @@ 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
-end
\ No newline at end of file
+end
diff --git a/public/icons/docs/wordpress/16.png b/public/icons/docs/wordpress/16.png
index 13f3fa64..0b3dc1cd 100644
Binary files a/public/icons/docs/wordpress/16.png and b/public/icons/docs/wordpress/16.png differ
diff --git a/public/icons/docs/wordpress/16 2x png b/public/icons/docs/wordpress/16 2x png
index dd7147c7..9de430fe 100644
Binary files a/public/icons/docs/wordpress/16 2x png and b/public/icons/docs/wordpress/16 2x png differ


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]