diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index c9e466e9..99cb1ada 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -35,6 +35,7 @@ 'pages/c', 'pages/cakephp', 'pages/chai', + 'pages/chef', 'pages/clojure', 'pages/coffeescript', 'pages/d3', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 66a0e359..2352df26 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -35,6 +35,7 @@ 'pages/c', 'pages/cakephp', 'pages/chai', + 'pages/chef', 'pages/clojure', 'pages/coffeescript', 'pages/d3', diff --git a/assets/stylesheets/pages/_chef.scss b/assets/stylesheets/pages/_chef.scss new file mode 100644 index 00000000..42c15758 --- /dev/null +++ b/assets/stylesheets/pages/_chef.scss @@ -0,0 +1,4 @@ +._chef { + @extend %simple; + +} \ No newline at end of file diff --git a/lib/docs/filters/chef/clean_html.rb b/lib/docs/filters/chef/clean_html.rb new file mode 100644 index 00000000..5d79623b --- /dev/null +++ b/lib/docs/filters/chef/clean_html.rb @@ -0,0 +1,10 @@ +module Docs + class Chef + class CleanHtmlFilter < Filter + def call + css('h1 a', 'h2 a', 'h3 a','div.footer').remove + doc + end + end + end +end diff --git a/lib/docs/filters/chef/entries.rb b/lib/docs/filters/chef/entries.rb new file mode 100644 index 00000000..0c52fcf9 --- /dev/null +++ b/lib/docs/filters/chef/entries.rb @@ -0,0 +1,10 @@ +module Docs + class Chef + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('div.body h1 a').remove + at_css('div.body h1').content + end + end + end +end diff --git a/lib/docs/filters/chefclient/clean_html.rb b/lib/docs/filters/chefclient/clean_html.rb new file mode 100644 index 00000000..58726cc7 --- /dev/null +++ b/lib/docs/filters/chefclient/clean_html.rb @@ -0,0 +1,11 @@ +module Docs + class Chefclient + class CleanHtmlFilter < Filter + def call + css('h1 a, h2 a, h3 a').remove + doc = at_css('div.body[role="main"]') + doc + end + end + end +end diff --git a/lib/docs/filters/chefclient/entries.rb b/lib/docs/filters/chefclient/entries.rb new file mode 100644 index 00000000..af1f62f2 --- /dev/null +++ b/lib/docs/filters/chefclient/entries.rb @@ -0,0 +1,63 @@ +module Docs + class Chefclient + class EntriesFilter < Docs::EntriesFilter + + ADDITIONAL_URLS = [ + { + slug: 'knife_common_options', + type: 'Miscellaneous/Knife', + name: 'Common options' + }, + { + slug: 'knife_using', + type: 'Miscellaneous/Knife', + name: 'Using knife' + }, + { + slug: 'config_rb_knife_optional_settings', + type: 'Miscellaneous/Knife', + name: 'Optional settings' + }, + { + slug: 'resource_common', + name: 'About resources' + } + ] + + def get_name + ADDITIONAL_URLS.each do |url| + next unless slug == url[:slug] + return url[:name] + end + + css('.main-item a').map do |node| + next unless node.attributes['href'].to_s == slug + + return node.attributes['title'].to_s + end + #css('h1').try(:content) + return 'adsf' + end + + def get_type + ADDITIONAL_URLS.each do |url| + next unless slug == url[:slug] + next unless url[:type].nil? + return url[:type] + end + + css('.main-item a').map do |node| + next unless node.attributes['href'].to_s == slug + if node.ancestors('.sub-items')[0].attributes['class'].to_s.include? 'level-2' + level2 = node.ancestors('.sub-items')[0].previous_element['title'].to_s + level1 = node.ancestors('.sub-items')[0].ancestors('.sub-items')[0].previous_element['title'].to_s + return "#{level1}/#{level2}" + end + + return node.ancestors('.sub-items')[0].previous_element['title'].to_s + end + 'Miscellaneous' + end + end + end +end diff --git a/lib/docs/scrapers/chef.rb b/lib/docs/scrapers/chef.rb new file mode 100644 index 00000000..9ed4ae3c --- /dev/null +++ b/lib/docs/scrapers/chef.rb @@ -0,0 +1,27 @@ +module Docs + class Chef < UrlScraper + self.name = 'Chef' + self.slug = 'chef' + self.type = 'chef' + self.version = '12.5' + self.base_url = 'https://docs.chef.io/' + self.links = { + home: 'https://www.chef.io/', + docs: 'https://docs.chef.io/' + } + + html_filters.push 'chef/entries', 'chef/clean_html' + + options[:container] = '.bodywrapper' + + options[:only_patterns] = [/resource_.*.html/] + options[:skip_patterns] = [/resource_common\.html/] + + options[:trailing_slash] = false + + options[:attribution] = <<-HTML + © 2015 Chef Software, Inc.
+ Creative Commons Attribution 3.0 Unported License. + HTML + end +end diff --git a/lib/docs/scrapers/chefclient.rb b/lib/docs/scrapers/chefclient.rb new file mode 100644 index 00000000..8eff8b68 --- /dev/null +++ b/lib/docs/scrapers/chefclient.rb @@ -0,0 +1,28 @@ +module Docs + class Chefclient < UrlScraper + self.name = 'Chef Client' + self.slug = 'chefclient' + self.type = 'chefclient' + self.version = '12.5' + self.base_url = "https://docs.chef.io/release/#{version.sub '.', '-'}/" + self.links = { + home: 'https://www.chef.io/', + docs: 'https://docs.chef.io/' + } + + html_filters.push 'chefclient/entries', 'chefclient/clean_html' + + options[:fix_urls] = ->(url) do + url.remove! %r{/release/[0-9\-+]/} + url + end + + options[:skip_patterns] = [/_images\//] + options[:trailing_slash] = false + + options[:attribution] = <<-HTML + © 2015 Chef Software, Inc.
+ Creative Commons Attribution 3.0 Unported License. + HTML + end +end diff --git a/public/icons/docs/chef/16.png b/public/icons/docs/chef/16.png new file mode 100644 index 00000000..e7792f94 Binary files /dev/null and b/public/icons/docs/chef/16.png differ diff --git a/public/icons/docs/chef/16@2x.png b/public/icons/docs/chef/16@2x.png new file mode 100644 index 00000000..5c8d5c30 Binary files /dev/null and b/public/icons/docs/chef/16@2x.png differ diff --git a/public/icons/docs/chef/SOURCE b/public/icons/docs/chef/SOURCE new file mode 100644 index 00000000..8d21f1f4 --- /dev/null +++ b/public/icons/docs/chef/SOURCE @@ -0,0 +1 @@ +http://style.chef.io/assets/images/downloads/Chef_Regular.png \ No newline at end of file