History

Add XSLT to XPath doc

Thibaut Courouble committed 10 years ago

Commit 9b4f4c21 parent a5ed2719 files · +56 −43Browse files

Unified · Split

9 files
  1. assets/javascripts/app/app.coffee +1 −0
  2. assets/stylesheets/global/_icons.scss +1 −1
  3. lib/app.rb +2 −1
  4. lib/docs/filters/mdn/clean_html.rb +2 −1
  5. lib/docs/filters/xpath/entries.rb +0 −22
  6. lib/docs/filters/xslt_xpath/clean_html.rb +2 −2
  7. lib/docs/filters/xslt_xpath/entries.rb +27 −0
  8. lib/docs/scrapers/mdn/xpath.rb +0 −16
  9. lib/docs/scrapers/mdn/xslt_xpath.rb +21 −0
assets/javascripts/app/app.coffee+1−0
@@ -101,6 +101,7 @@ · 100 unmodified lines
101 for slug in @settings.getDocs() when not @docs.findBy('slug', slug)101 for slug in @settings.getDocs() when not @docs.findBy('slug', slug)
102 needsSaving = true102 needsSaving = true
103 doc = @disabledDocs.findBy('slug', 'node~4_lts') if slug == 'node~4.2_lts'103 doc = @disabledDocs.findBy('slug', 'node~4_lts') if slug == 'node~4.2_lts'
104 doc = @disabledDocs.findBy('slug', 'xslt_xpath') if slug == 'xpath'
104 doc ||= @disabledDocs.findBy('slug_without_version', slug)105 doc ||= @disabledDocs.findBy('slug_without_version', slug)
105 if doc106 if doc
106 @disabledDocs.remove(doc)107 @disabledDocs.remove(doc)
assets/stylesheets/global/_icons.scss+1−1
@@ -75,7 +75,7 @@ · 74 unmodified lines
75._icon-cordova:before { background-position: 0 -5rem; }75._icon-cordova:before { background-position: 0 -5rem; }
76._icon-markdown:before { background-position: -1rem -5rem; @extend %darkIconFix !optional; }76._icon-markdown:before { background-position: -1rem -5rem; @extend %darkIconFix !optional; }
77._icon-django:before { background-position: -2rem -5rem; }77._icon-django:before { background-position: -2rem -5rem; }
78._icon-xpath:before { background-position: -3rem -5rem; }78._icon-xslt_xpath:before { background-position: -3rem -5rem; }
79._icon-nginx:before,79._icon-nginx:before,
80._icon-nginx_lua_module:before { background-position: -4rem -5rem; }80._icon-nginx_lua_module:before { background-position: -4rem -5rem; }
81._icon-svg:before { background-position: -5rem -5rem; }81._icon-svg:before { background-position: -5rem -5rem; }
lib/app.rb+2−1
@@ -273,7 +273,8 @@ class App < Sinatra::Application · 272 unmodified lines
273 DOC_REDIRECTS = {273 DOC_REDIRECTS = {
274 'iojs' => 'node',274 'iojs' => 'node',
275 'yii1' => 'yii~1.1',275 'yii1' => 'yii~1.1',
276 'python2' => 'python~2.7'276 'python2' => 'python~2.7',
277 'xpath' => 'xslt_xpath'
277 }278 }
278 279
279 get %r{\A/([\w~\.]+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest|280 get %r{\A/([\w~\.]+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest|
lib/docs/filters/mdn/clean_html.rb+2−1
@@ -9,7 +9,8 @@ module Docs · 8 unmodified lines
9 '.todo',9 '.todo',
10 '.draftHeader',10 '.draftHeader',
11 '.hidden',11 '.hidden',
12 '.button.section-edit']12 '.button.section-edit',
13 'hr']
13 14
14 def call15 def call
15 css(*REMOVE_NODES).remove16 css(*REMOVE_NODES).remove
lib/docs/filters/xpath/entries.rb+0−22
@@ -1,22 +0,0 @@
1module Docs
2 class Xpath
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 name = super
6 name.remove!('Axes.')
7 name << '()' if name.gsub!('Functions.', '')
8 name
9 end
10
11 def get_type
12 if slug.start_with?('Axes')
13 'Axes'
14 elsif slug.start_with?('Functions')
15 'Functions'
16 else
17 'Miscellaneous'
18 end
19 end
20 end
21 end
22end
lib/docs/filters/xslt_xpath/clean_html.rbrenamed from lib/docs/filters/xpath/clean_html.rb+2−2
@@ -1,8 +1,8 @@
1module Docs1module Docs
2 class Xpath2 class XsltXpath
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 root_page? ? root : other5 initial_page? ? root : other
6 doc6 doc
7 end7 end
8 8
lib/docs/filters/xslt_xpath/entries.rb+27−0
@@ -0,0 +1,27 @@
1module Docs
2 class XsltXpath
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 name = super
6 name.remove! 'XPath.'
7 name.remove! 'XSLT.'
8 name.remove! 'Axes.'
9 name.prepend 'xsl:' if slug =~ /\AXSLT\/[a-z]/
10 name << '()' if name.gsub!('Functions.', '')
11 name
12 end
13
14 def get_type
15 if slug =~ /\AXSLT\/[a-z]/
16 'XSLT Elements'
17 elsif slug.start_with?('XPath/Axes')
18 'XPath Axes'
19 elsif slug.start_with?('XPath/Functions')
20 'XPath Functions'
21 else
22 'Miscellaneous'
23 end
24 end
25 end
26 end
27end
lib/docs/scrapers/mdn/xpath.rb+0−16
@@ -1,16 +0,0 @@
1module Docs
2 class Xpath < Mdn
3 self.name = 'XPath'
4 self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/XPath'
5
6 html_filters.push 'xpath/clean_html', 'xpath/entries', 'title'
7
8 options[:root_title] = 'XPath'
9
10 options[:fix_urls] = ->(url) do
11 url.sub! 'https://developer.mozilla.org/en/XPath', Xpath.base_url
12 url.sub! 'https://developer.mozilla.org/en-US/docs/XPath', Xpath.base_url
13 url
14 end
15 end
16end
lib/docs/scrapers/mdn/xslt_xpath.rb+21−0
@@ -0,0 +1,21 @@
1module Docs
2 class XsltXpath < Mdn
3 self.name = 'XSLT & XPath'
4 self.slug = 'xslt_xpath'
5 self.base_url = 'https://developer.mozilla.org/en-US/docs/Web'
6 self.root_path = '/XSLT'
7 self.initial_paths = %w(/XPath)
8
9 html_filters.push 'xslt_xpath/clean_html', 'xslt_xpath/entries', 'title'
10
11 options[:only_patterns] = [/\A\/XSLT/, /\A\/XPath/]
12
13 options[:fix_urls] = ->(url) do
14 url.sub! 'https://developer.mozilla.org/en/XPath', "#{XsltXpath.base_url}/XPath"
15 url.sub! 'https://developer.mozilla.org/en/XSLT', "#{XsltXpath.base_url}/XSLT"
16 url.sub! 'https://developer.mozilla.org/en-US/docs/XPath', "#{XsltXpath.base_url}/XPath"
17 url.sub! 'https://developer.mozilla.org/en-US/docs/XSLT', "#{XsltXpath.base_url}/XSLT"
18 url
19 end
20 end
21end