| @@ -1,38 +1,26 @@ |
| 1 | module Docs | 1 | module Docs |
| 2 | class Drupal < UrlScraper | 2 | class Drupal < UrlScraper |
| 3 | self.name = 'Drupal' | | |
| 4 | self.type = 'drupal' | 3 | self.type = 'drupal' |
| 5 | self.version = '7.37' | 4 | self.version = '7.38' |
| 6 | self.base_url = 'https://api.drupal.org/api/drupal/' | 5 | self.base_url = 'https://api.drupal.org/api/drupal/' |
| 7 | self.initial_paths = %w( | 6 | self.initial_paths = %w(groups groups?page=1) |
| 8 | groups | 7 | self.links = { |
| 9 | groups?page=1) | 8 | home: 'https://www.drupal.org/' |
| 10 | | 9 | } |
| 11 | html_filters.replace 'normalize_paths', 'drupal/normalize_paths' | | |
| 12 | html_filters.replace 'internal_urls', 'drupal/internal_urls' | | |
| 13 | | 10 | |
| 14 | html_filters.push 'drupal/entries', 'drupal/clean_html', 'title' | 11 | html_filters.push 'drupal/entries', 'drupal/clean_html', 'title' |
| 15 | | 12 | |
| 16 | options[:container] = '#page' | 13 | options[:decode_and_clean_paths] = true |
| | 14 | options[:container] = '#page-inner' |
| 17 | options[:title] = false | 15 | options[:title] = false |
| 18 | options[:root_title] = 'Drupal - Open Source CMS | Drupal.org' | 16 | options[:root_title] = 'Drupal' |
| 19 | | 17 | |
| 20 | options[:only_patterns] = [ | 18 | options[:only_patterns] = [ |
| | 19 | /\/class\/[^\/]+/, |
| 21 | /\/group\/[^\/]+/, | 20 | /\/group\/[^\/]+/, |
| 22 | /\/function\/[^\/]+/] | 21 | /\/function\/[^\/]+/] |
| 23 | | 22 | |
| 24 | options[:skip_link] = ->(link) { | 23 | options[:skip_link] = ->(link) { link['href'] =~ /[\?&]order/ } |
| 25 | begin | | |
| 26 | return unless q = URL.parse(link['href']).query | | |
| 27 | Hash[URI.decode_www_form(q)].has_key? "order" | | |
| 28 | rescue URI::InvalidURIError | | |
| 29 | false | | |
| 30 | end | | |
| 31 | } | | |
| 32 | | | |
| 33 | options[:skip] = %w( | | |
| 34 | 'modules-system-system.install/group/updates-7.x-extra/7', | | |
| 35 | 'modules-system-system.install/group/updates-6.x-to-7.x/7') | | |
| 36 | | 24 | |
| 37 | options[:skip_patterns] = [ | 25 | options[:skip_patterns] = [ |
| 38 | /\/group\/updates\-7/, | 26 | /\/group\/updates\-7/, |
| @@ -40,26 +28,25 @@ module Docs · 1 unmodified line |
| 40 | /_update_[0-9]{4}/, # Skip update functions | 28 | /_update_[0-9]{4}/, # Skip update functions |
| 41 | /\/[4-6](\.[0-9])*$/, # Skip previous versions | 29 | /\/[4-6](\.[0-9])*$/, # Skip previous versions |
| 42 | /\/[8-9](\.[0-9])*$/, # Skip future versions | 30 | /\/[8-9](\.[0-9])*$/, # Skip future versions |
| | 31 | /\/class\/hierarchy\//, # Skip class hierarchy listings |
| 43 | /\/function\/calls\//, # Skip function calls listings | 32 | /\/function\/calls\//, # Skip function calls listings |
| | 33 | /\/function\/invokes\//, # Skip function invokations listings |
| | 34 | /\/function\/overrides\//, # Skip function overrides listings |
| | 35 | /\/function\/references\//, # Skip function references listings |
| 44 | /\/function\/implementations\//, # Skip hook implementation listings | 36 | /\/function\/implementations\//, # Skip hook implementation listings |
| | 37 | /\/function\/theme_references\//, # Skip hook references listings |
| 45 | /\.test\/function\// # Skip test files | 38 | /\.test\/function\// # Skip test files |
| 46 | ] | 39 | ] |
| 47 | | 40 | |
| 48 | options[:fix_urls] = ->(url) do | 41 | options[:fix_urls] = ->(url) do |
| 49 | url.sub! /\/7$/, '' # Remove the version indicator from the current version | 42 | url.remove! %r{/7$} |
| 50 | url | 43 | url |
| 51 | end | 44 | end |
| 52 | | 45 | |
| 53 | options[:attribution] = <<-HTML | 46 | options[:attribution] = <<-HTML |
| 54 | © 2000–2015 by the individual contributors.<br> | 47 | © 2001–2015 by the original authors<br> |
| 55 | Licensed under the Creative Commons License, Attribution-ShareAlike2.0.<br> | 48 | Licensed under the GNU General Public License, version 2 and later.<br> |
| 56 | Drupal is a registered trademark of Dries Buytaert. | 49 | Drupal is a registered trademark of Dries Buytaert. |
| 57 | HTML | 50 | HTML |
| 58 | | | |
| 59 | # Method used at several places to fix special characters at urls from api.drupal.org | | |
| 60 | def self.fixUri(path) | | |
| 61 | p = path.gsub /%21|!|%2b|%3b|%3a/i, '-' # !+;: | | |
| 62 | end | | |
| 63 | | | |
| 64 | end | 51 | end |
| 65 | end | 52 | end |