History

Refactor GitHub scraper code

Thibaut Courouble committed 10 years ago

Commit c5caeff1 parent ac3aaea9 files · +13 −31Browse files

Unified · Split

9 files
  1. assets/javascripts/views/pages/github.coffee +4 −1
  2. assets/javascripts/views/pages/javascript.coffee +0 −1
  3. assets/stylesheets/application-dark.css.scss +1 −1
  4. assets/stylesheets/application.css.scss +1 −1
  5. assets/stylesheets/pages/_base.scss +0 −1
  6. assets/stylesheets/pages/_github.scss +5 −0
  7. assets/stylesheets/pages/_q.scss +0 −5
  8. lib/docs/filters/q/clean_html.rb +0 −18
  9. lib/docs/scrapers/q.rb +2 −3
assets/javascripts/views/pages/github.coffee+4−1
@@ -1,6 +1,9 @@
11 #= require views/pages/base
22
33 class app.views.GithubPage extends app.views.BasePage
4+ LANGUAGE_RGX = /highlight-source-(\w+)/
5+
46 prepare: ->
5− @highlightCode @findAll('pre.highlight-source-lua'), 'lua'
7+ for el in @findAll('pre.highlight')
8+ @highlightCode(el, el.className.match(LANGUAGE_RGX)[1])
69 return
assets/javascripts/views/pages/javascript.coffee+0−1
@@ -26,7 +26,6 @@ app.views.MomentPage = · 25 unmodified lines
2626 app.views.MongoosePage =
2727 app.views.NodePage =
2828 app.views.PhaserPage =
29−app.views.QPage =
3029 app.views.RamdaPage =
3130 app.views.RethinkdbPage =
3231 app.views.SinonPage =
assets/stylesheets/application-dark.css.scss+1−1
@@ -45,6 +45,7 @@ · 44 unmodified lines
4545 'pages/erlang',
4646 'pages/express',
4747 'pages/git',
48+ 'pages/github',
4849 'pages/go',
4950 'pages/haskell',
5051 'pages/jquery',
@@ -63,7 +64,6 @@ · 12 unmodified lines
6364 'pages/php',
6465 'pages/phpunit',
6566 'pages/postgres',
66− 'pages/q',
6767 'pages/ramda',
6868 'pages/rdoc',
6969 'pages/react',
assets/stylesheets/application.css.scss+1−1
@@ -45,6 +45,7 @@ · 44 unmodified lines
4545 'pages/erlang',
4646 'pages/express',
4747 'pages/git',
48+ 'pages/github',
4849 'pages/go',
4950 'pages/haskell',
5051 'pages/jquery',
@@ -63,7 +64,6 @@ · 12 unmodified lines
6364 'pages/php',
6465 'pages/phpunit',
6566 'pages/postgres',
66− 'pages/q',
6767 'pages/ramda',
6868 'pages/rdoc',
6969 'pages/react',
assets/stylesheets/pages/_base.scss+0−1
@@ -17,7 +17,6 @@ · 16 unmodified lines
1717 }
1818
1919 ._cordova,
20−._github,
2120 ._grunt,
2221 ._less,
2322 ._lodash,
assets/stylesheets/pages/_github.scss+5−0
@@ -0,0 +1,5 @@
1+._github {
2+ @extend %simple;
3+
4+ h4 { @extend %block-label; }
5+}
assets/stylesheets/pages/_q.scss+0−5
@@ -1,5 +0,0 @@
1−._q {
2− > h2, > h3 { @extend %block-heading; }
3− > h4 { @extend %block-label, %label-blue; }
4− code { @extend %label; }
5−}
lib/docs/filters/q/clean_html.rb+0−18
@@ -1,18 +0,0 @@
1−module Docs
2− class Q
3− class CleanHtmlFilter < Filter
4− def call
5− css('.anchor').each do |node|
6− node.parent['id'] = node['href'].remove('#')
7− node.remove
8− end
9−
10− css('.highlight > pre').each do |node|
11− node.content = node.content.gsub(' ', ' ')
12− end
13−
14− doc
15− end
16− end
17− end
18−end
lib/docs/scrapers/q.rb+2−3
@@ -1,7 +1,6 @@
11 module Docs
2− class Q < UrlScraper
2+ class Q < Github
33 self.name = 'Q'
4− self.type = 'q'
54 self.release = '1.4.1'
65 self.base_url = 'https://github.com/kriskowal/q/wiki/'
76 self.root_path = 'API-Reference'
@@ -10,7 +9,7 @@ module Docs · 2 unmodified lines
109 code: 'https://github.com/kriskowal/q'
1110 }
1211
13− html_filters.push 'q/clean_html', 'q/entries', 'title'
12+ html_filters.push 'q/entries', 'title'
1413
1514 options[:container] = '.markdown-body'
1615 options[:title] = 'Q'