History

Finish Vagrant scraper

Thibaut committed 11 years ago

Commit de1c8791 parent e6c909314 files · +48 −55Browse files

Unified · Split

14 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/news.json +1 −1
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/javascripts/views/pages/vagrant.coffee +5 −0
  6. assets/stylesheets/application-dark.css.scss +1 −0
  7. assets/stylesheets/application.css.scss +1 −0
  8. assets/stylesheets/global/_icons.scss +1 −0
  9. assets/stylesheets/pages/_vagrant.scss +9 −0
  10. lib/docs/filters/vagrant/clean_html.rb +4 −6
  11. lib/docs/filters/vagrant/entries.rb +21 −48
  12. lib/docs/scrapers/vagrant.rb +4 −4
  13. public/icons/docs/vagrant/16.png +0 −0
  14. public/icons/docs/vagrant/16@2x.png +0 −0
assets/images/icons.png+0−0

Binary file not shown.

assets/images/icons@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+1−1
@@ -1,7 +1,7 @@
1[1[
2 [2 [
3 "2015-11-08",3 "2015-11-08",
4 "New documentation: <a href=\"/elixir/\">Elixir</a>"4 "New documentations: <a href=\"/elixir/\">Elixir</a> and <a href=\"/vagrant/\">Vagrant</a>"
5 ], [5 ], [
6 "2015-10-18",6 "2015-10-18",
7 "Added a \"Copy to clipboard\" button inside each code block."7 "Added a \"Copy to clipboard\" button inside each code block."
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -379,6 +379,11 @@ credits = [ · 378 unmodified lines
379 '2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',379 '2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
380 'MIT',380 'MIT',
381 'https://raw.github.com/jashkenas/underscore/master/LICENSE'381 'https://raw.github.com/jashkenas/underscore/master/LICENSE'
382 ], [
383 'Vagrant',
384 '2010-2015 Mitchell Hashimoto',
385 'MIT',
386 'https://raw.githubusercontent.com/mitchellh/vagrant/master/LICENSE'
382 ], [387 ], [
383 'Vue.js',388 'Vue.js',
384 '2013-2015 Evan You, Vue.js contributors',389 '2013-2015 Evan You, Vue.js contributors',
assets/javascripts/views/pages/vagrant.coffee+5−0
@@ -0,0 +1,5 @@
1#= require views/pages/base
2
3class app.views.VagrantPage extends app.views.BasePage
4 prepare: ->
5 @highlightCode @findAll('pre.ruby'), 'ruby'
assets/stylesheets/application-dark.css.scss+1−0
@@ -72,6 +72,7 @@ · 71 unmodified lines
72 'pages/socketio',72 'pages/socketio',
73 'pages/sphinx',73 'pages/sphinx',
74 'pages/underscore',74 'pages/underscore',
75 'pages/vagrant',
75 'pages/vue',76 'pages/vue',
76 'pages/yard',77 'pages/yard',
77 'pages/yii';78 'pages/yii';
assets/stylesheets/application.css.scss+1−0
@@ -72,6 +72,7 @@ · 71 unmodified lines
72 'pages/socketio',72 'pages/socketio',
73 'pages/sphinx',73 'pages/sphinx',
74 'pages/underscore',74 'pages/underscore',
75 'pages/vagrant',
75 'pages/vue',76 'pages/vue',
76 'pages/yard',77 'pages/yard',
77 'pages/yii';78 'pages/yii';
assets/stylesheets/global/_icons.scss+1−0
@@ -117,3 +117,4 @@ · 116 unmodified lines
117%icon-clipboard { background-position: -2rem -9rem; }117%icon-clipboard { background-position: -2rem -9rem; }
118%icon-clipboard-white { background-position: -3rem -9rem; }118%icon-clipboard-white { background-position: -3rem -9rem; }
119._icon-elixir:before { background-position: -4rem -9rem; @extend %darkIconFix !optional; }119._icon-elixir:before { background-position: -4rem -9rem; @extend %darkIconFix !optional; }
120._icon-vagrant:before { background-position: -5rem -9rem; }
assets/stylesheets/pages/_vagrant.scss+9−0
@@ -0,0 +1,9 @@
1._vagrant {
2 @extend %simple;
3
4 .alert { @extend %note; }
5 .prev-button { float: left; }
6 .prev-button:before { content: '\2190 '; }
7 .next-button { float: right; }
8 .next-button:after { content: ' \2192'; }
9}
lib/docs/filters/vagrant/clean_html.rb+4−6
@@ -2,14 +2,12 @@ module Docs · 1 unmodified line
2 class Vagrant2 class Vagrant
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 if root_page?5 @doc = at_css('.page-contents .span8')
6 doc.children = css('h1, .category')
7 return doc
8 end
9 6
10 css('nav', '.sidebar', 'footer').remove7 css('hr').remove
11 8
12 css('.wrapper', '.page', '.container', '.row', '.page-contents', '.span8').each do |node|9 css('pre > code').each do |node|
10 node.parent['class'] = node['class']
13 node.before(node.children).remove11 node.before(node.children).remove
14 end12 end
15 13
lib/docs/filters/vagrant/entries.rb+21−48
@@ -3,59 +3,32 @@ module Docs · 2 unmodified lines
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 if slug.start_with?('push/')5 if slug.start_with?('push/')
6 if at_css('h2')6 name = at_css('h2').try(:content)
7 name = at_css('h2').content.strip7 elsif slug.start_with?('cli/')
8 else8 name = at_css('h1 + p > strong > code').try(:content).try(:[], /\s*vagrant\s+[\w\-]+/)
9 name = at_css('h1').content.strip
10 end
11 name
12 else
13 name = at_css('h1').content.strip
14 name
15 end9 end
10
11 name || at_css('h1').content
16 end12 end
17 13
18 def get_type14 def get_type
19 if slug.start_with?('why-vagrant')15 at_css('.sidebar-nav li.current').content
20 'Why Vagrant?'16 end
21 elsif slug.start_with?('installation')17
22 'Installation'18 def additional_entries
23 elsif slug.start_with?('getting-started')19 case at_css('h1 + p > strong > code').try(:content)
24 'Getting Started'20 when /config\./
25 elsif slug.start_with?('cli')21 h2 = nil
26 'Command-Line Interface'22 css('.page-contents .span8 > *').each_with_object [] do |node, entries|
27 elsif slug.start_with?('share')23 if node.name == 'h2'
28 'Vagrant Share'24 h2 = node.content
29 elsif slug.start_with?('vagrantfile')25 elsif h2 == 'Available Settings' && (code = node.at_css('code')) && (name = code.content) && name.start_with?('config.')
30 'Vagrantfile'26 id = code.parent['id'] = name.parameterize
31 elsif slug.start_with?('boxes')27 entries << [name, id, 'Config']
32 'Boxes'28 end
33 elsif slug.start_with?('provisioning')29 end
34 'Provisioning'
35 elsif slug.start_with?('networking')
36 'Networking'
37 elsif slug.start_with?('synced-folders')
38 'Synced Folders'
39 elsif slug.start_with?('multi-machine')
40 'Multi-Machine'
41 elsif slug.start_with?('providers')
42 'Providers'
43 elsif slug.start_with?('plugins')
44 'Plugins'
45 elsif slug.start_with?('push')
46 'Push'
47 elsif slug.start_with?('other')
48 'Other'
49 elsif slug.start_with?('vmware')
50 'VMware'
51 elsif slug.start_with?('docker')
52 'Docker'
53 elsif slug.start_with?('virtualbox')
54 'VirtualBox'
55 elsif slug.start_with?('hyperv')
56 'Hyper-V'
57 else30 else
58 'Overview'31 []
59 end32 end
60 end33 end
61 end34 end
lib/docs/scrapers/vagrant.rb+4−4
@@ -1,15 +1,15 @@
1module Docs1module Docs
2 class Vagrant < UrlScraper2 class Vagrant < UrlScraper
3 self.name = 'Vagrant'3 self.name = 'Vagrant'
4 self.slug = 'vagrant'
5 self.type = 'vagrant'4 self.type = 'vagrant'
6 self.version = '1.7.4'5 self.version = '1.7.4'
7 self.base_url = 'http://docs.vagrantup.com/v2/'6 self.base_url = 'https://docs.vagrantup.com/v2/'
8 self.links = {7 self.links = {
9 home: 'http://www.vagrantup.com/'8 home: 'https://www.vagrantup.com/',
9 code: 'https://github.com/mitchellh/vagrant'
10 }10 }
11 11
12 html_filters.push 'vagrant/clean_html', 'vagrant/entries'12 html_filters.push 'vagrant/entries', 'vagrant/clean_html'
13 13
14 options[:attribution] = <<-HTML14 options[:attribution] = <<-HTML
15 &copy; 2010&ndash;2015 Mitchell Hashimoto<br>15 &copy; 2010&ndash;2015 Mitchell Hashimoto<br>
public/icons/docs/vagrant/16.png+0−0

Binary file not shown.

public/icons/docs/vagrant/16@2x.png+0−0

Binary file not shown.