mirror of https://github.com/freeCodeCamp/devdocs
parent
422d3779e2
commit
dac9b9b03c
@ -0,0 +1,10 @@
|
|||||||
|
._drupal {
|
||||||
|
h1#page-subtitle {
|
||||||
|
margin-top: 0;
|
||||||
|
@extend %lined-heading;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 { @extend %block-heading; }
|
||||||
|
|
||||||
|
.signature { @extend %note, %note-blue; }
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
module Docs
|
||||||
|
class Drupal
|
||||||
|
class CleanHtmlFilter < Filter
|
||||||
|
def call
|
||||||
|
root_page? ? root : other
|
||||||
|
doc
|
||||||
|
end
|
||||||
|
|
||||||
|
def root
|
||||||
|
doc.inner_html = ' '
|
||||||
|
end
|
||||||
|
|
||||||
|
def other
|
||||||
|
css('#page-title-tools', '.element-invisible', '.breadcrumb', '#sidebar-first', '#api-alternatives').remove
|
||||||
|
css('#aside', '#api-function-signature tr:not(.active)', '.comments').remove
|
||||||
|
# Replaces the signature table from api.drupal.org with a simple pre tag
|
||||||
|
css('#api-function-signature').each do |table|
|
||||||
|
signature = table.css('.signature').first.inner_html
|
||||||
|
table.replace '<pre class="signature">' + signature + '</pre>'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,25 @@
|
|||||||
|
module Docs
|
||||||
|
class Drupal
|
||||||
|
class EntriesFilter < Docs::EntriesFilter
|
||||||
|
|
||||||
|
def get_name
|
||||||
|
name = css('#page-subtitle').first.content
|
||||||
|
name.remove! 'function '
|
||||||
|
name
|
||||||
|
end
|
||||||
|
|
||||||
|
def path
|
||||||
|
Drupal::fixUri(result[:path])
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_type
|
||||||
|
type = css('dl[api-related-topics] dt')
|
||||||
|
type.first ? type.first.content : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_default_entry?
|
||||||
|
!initial_page?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,12 @@
|
|||||||
|
module Docs
|
||||||
|
class Drupal
|
||||||
|
class InternalUrlsFilter < Docs::InternalUrlsFilter
|
||||||
|
def internal_path_to(url)
|
||||||
|
url = index_url if url == root_url
|
||||||
|
path = effective_url.relative_path_to(url)
|
||||||
|
URL.new(path: Drupal::fixUri(path), query: url.query, fragment: url.fragment).to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,11 @@
|
|||||||
|
module Docs
|
||||||
|
class Drupal
|
||||||
|
class NormalizePathsFilter < Docs::NormalizePathsFilter
|
||||||
|
|
||||||
|
def store_path
|
||||||
|
p = Drupal::fixUri(@path)
|
||||||
|
File.extname(p) != '.html' ? "#{p}.html" : p
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,65 @@
|
|||||||
|
module Docs
|
||||||
|
class Drupal < UrlScraper
|
||||||
|
self.name = 'Drupal'
|
||||||
|
self.type = 'drupal'
|
||||||
|
self.version = '7.37'
|
||||||
|
self.base_url = 'https://api.drupal.org/api/drupal/'
|
||||||
|
self.initial_paths = %w(
|
||||||
|
groups
|
||||||
|
groups?page=1)
|
||||||
|
|
||||||
|
html_filters.replace 'normalize_paths', 'drupal/normalize_paths'
|
||||||
|
html_filters.replace 'internal_urls', 'drupal/internal_urls'
|
||||||
|
|
||||||
|
html_filters.push 'drupal/entries', 'drupal/clean_html', 'title'
|
||||||
|
|
||||||
|
options[:container] = '#page'
|
||||||
|
options[:title] = false
|
||||||
|
options[:root_title] = 'Drupal - Open Source CMS | Drupal.org'
|
||||||
|
|
||||||
|
options[:only_patterns] = [
|
||||||
|
/\/group\/[^\/]+/,
|
||||||
|
/\/function\/[^\/]+/]
|
||||||
|
|
||||||
|
options[:skip_link] = ->(link) {
|
||||||
|
begin
|
||||||
|
return unless q = URL.parse(link['href']).query
|
||||||
|
Hash[URI.decode_www_form(q)].has_key? "order"
|
||||||
|
rescue URI::InvalidURIError
|
||||||
|
false
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
options[:skip] = %w(
|
||||||
|
'modules-system-system.install/group/updates-7.x-extra/7',
|
||||||
|
'modules-system-system.install/group/updates-6.x-to-7.x/7')
|
||||||
|
|
||||||
|
options[:skip_patterns] = [
|
||||||
|
/\/group\/updates\-7/,
|
||||||
|
/\/group\/updates\-6/,
|
||||||
|
/_update_[0-9]{4}/, # Skip update functions
|
||||||
|
/\/[4-6](\.[0-9])*$/, # Skip previous versions
|
||||||
|
/\/[8-9](\.[0-9])*$/, # Skip future versions
|
||||||
|
/\/function\/calls\//, # Skip function calls listings
|
||||||
|
/\/function\/implementations\//, # Skip hook implementation listings
|
||||||
|
/\.test\/function\// # Skip test files
|
||||||
|
]
|
||||||
|
|
||||||
|
options[:fix_urls] = ->(url) do
|
||||||
|
url.sub! /\/7$/, '' # Remove the version indicator from the current version
|
||||||
|
url
|
||||||
|
end
|
||||||
|
|
||||||
|
options[:attribution] = <<-HTML
|
||||||
|
© 2000–2015 by the individual contributors.<br>
|
||||||
|
Licensed under the Creative Commons License, Attribution-ShareAlike2.0.<br>
|
||||||
|
Drupal is a registered trademark of Dries Buytaert.
|
||||||
|
HTML
|
||||||
|
|
||||||
|
# Method used at several places to fix special characters at urls from api.drupal.org
|
||||||
|
def self.fixUri(path)
|
||||||
|
p = path.gsub /%21|!|%2b|%3b|%3a/i, '-' # !+;:
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
After Width: | Height: | Size: 704 B |
After Width: | Height: | Size: 1.7 KiB |
@ -0,0 +1 @@
|
|||||||
|
https://www.drupal.org/node/9068
|
Loading…
Reference in new issue