diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index cc8675d3..fc4a8910 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -67,4 +67,5 @@ 'pages/sphinx', 'pages/underscore', 'pages/yard', + 'pages/elasticsearch', 'pages/yii'; diff --git a/assets/stylesheets/pages/_elasticsearch.scss b/assets/stylesheets/pages/_elasticsearch.scss new file mode 100644 index 00000000..4507212f --- /dev/null +++ b/assets/stylesheets/pages/_elasticsearch.scss @@ -0,0 +1,11 @@ +._elasticsearch { + + > h2 { @extend %block-heading; } + > h3 { @extend %block-label, %label-blue; } + > h4 { font-size: 1em; } + + .note { @extend %note; } +} + + + diff --git a/lib/docs/filters/elasticsearch/clean_html.rb b/lib/docs/filters/elasticsearch/clean_html.rb new file mode 100644 index 00000000..9e3df451 --- /dev/null +++ b/lib/docs/filters/elasticsearch/clean_html.rb @@ -0,0 +1,59 @@ +module Docs + class Elasticsearch + class CleanHtmlFilter < Filter + + def call + root_page? ? root : other + page + doc + end + + def root + # Remove the option block for allowing to change the version + css('#book_title').remove + + # Remove annoying hr + css('.titlepage>hr').remove + + end + + def page + css('.navheader, .navfooter').remove + css('.breadcrumbs').remove + + + end + + def other + css('a.edit_me').remove + + @doc = at_css('.titlepage').parent + + # Downgrade all headers. + headers = (2..6).map { |n| "h#{n}" }.join(',') + css(headers).each do |header| + level = header.name.last.to_i + + header.name = "h#{level-1}" + end + + + + # Move the h1 of the title to be underneath the document + at_css('.titlepage').replace at_css('.titlepage h1.title') + + # Remove the note icon + css('.icon').each(&:remove) + + # Remove table stylings + css('table').each do |table| + table.delete "cellpadding" + table.delete "border" + table.delete "cellpadding" + end + end + + end + end +end + diff --git a/lib/docs/filters/elasticsearch/entries.rb b/lib/docs/filters/elasticsearch/entries.rb new file mode 100644 index 00000000..0f565176 --- /dev/null +++ b/lib/docs/filters/elasticsearch/entries.rb @@ -0,0 +1,17 @@ +module Docs + class Elasticsearch + class EntriesFilter < Docs::EntriesFilter + def get_name + css('.breadcrumbs span').last.content.strip + end + + def get_type + # get the second breadcrumb for our type, + # the first is link to the main page (contents page) + at_css('.breadcrumbs span:nth-child(2)').content.strip + end + + end + end + +end diff --git a/lib/docs/scrapers/elasticsearch.rb b/lib/docs/scrapers/elasticsearch.rb new file mode 100644 index 00000000..641aab4d --- /dev/null +++ b/lib/docs/scrapers/elasticsearch.rb @@ -0,0 +1,21 @@ +module Docs + class Elasticsearch < UrlScraper + self.name = 'ElasticSearch' + self.slug = 'elasticsearch' + self.type = 'elasticsearch' + self.version = '1.6' + self.base_url = "https://www.elastic.co/guide/en/elasticsearch/reference/#{version}/" + self.root_path = 'index.html' + + html_filters.push 'elasticsearch/entries', 'elasticsearch/clean_html' + + options[:container] = '#guide' + + options[:attribution] = <<-HTML + © 2009–2015 Elasticsearch
+ Licensed under the Apache License, Version 2.0. + HTML + + end +end + diff --git a/public/icons/docs/elasticsearch/16.png b/public/icons/docs/elasticsearch/16.png new file mode 100644 index 00000000..2def2dfe Binary files /dev/null and b/public/icons/docs/elasticsearch/16.png differ diff --git a/public/icons/docs/elasticsearch/16@2x.png b/public/icons/docs/elasticsearch/16@2x.png new file mode 100644 index 00000000..74c280f0 Binary files /dev/null and b/public/icons/docs/elasticsearch/16@2x.png differ