diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 753c0058..26ca8e7e 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -310,6 +310,11 @@ credits = [ 'GruntJS Team', 'MIT', 'https://github.com/gruntjs/grunt-docs/blob/master/package.json#L10' + ], [ + 'Handlebars', + '2011-2017 Yehuda Katz', + 'MIT', + 'https://raw.githubusercontent.com/wycats/handlebars.js/master/LICENSE' ], [ 'Haskell', 'The University of Glasgow', diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index fe36579d..078a5055 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -27,6 +27,7 @@ ._flow, ._gnu, ._grunt, +._handlebars, ._haxe, ._immutable, ._influxdata, diff --git a/lib/docs/filters/handlebars/clean_html.rb b/lib/docs/filters/handlebars/clean_html.rb new file mode 100644 index 00000000..f99aa1df --- /dev/null +++ b/lib/docs/filters/handlebars/clean_html.rb @@ -0,0 +1,44 @@ +module Docs + class Handlebars + class CleanHtmlFilter < Filter + def call + # Remove the t-shirt shop advertisement + css('#callout').remove + + # The title filter is used to add titles to pages without one, remove original headers + css('h1').remove + + # Remove the link to the issue tracker + css('.issue-tracker').remove + + css('pre').each do |node| + # Remove nested nodes inside pre tags + node.content = node.content + + # Add syntax highlighting + node['data-language'] = 'html' + end + + # Transform 'Learn More' links to headers in the "Getting Started" part of the homepage + # If this step is skipped, that section looks cluttered with 4 sub-sections without any dividers + css('#getting-started + .contents a.more-info').each do |node| + clone = node.clone + + # Move it to the top of the sub-section + node.parent.prepend_child(clone) + + # Turn it into a header + clone.name = 'h3' + + # Remove the "Learn More: " part + clone.content = clone.content[12..-1] + end + + # Remove class attributes from div elements to reduce file size + css('div').remove_attr('class') + + doc + end + end + end +end diff --git a/lib/docs/filters/handlebars/entries.rb b/lib/docs/filters/handlebars/entries.rb new file mode 100644 index 00000000..24d46c6c --- /dev/null +++ b/lib/docs/filters/handlebars/entries.rb @@ -0,0 +1,19 @@ +module Docs + class Handlebars + class EntriesFilter < Docs::EntriesFilter + def get_name + subpath[0..-6].titleize + end + + def get_type + name + end + + def additional_entries + css('h2, h3').to_a.map do |node| + [node.content.strip, node['id'], root_page? ? 'Manual' : nil] + end + end + end + end +end diff --git a/lib/docs/scrapers/handlebars.rb b/lib/docs/scrapers/handlebars.rb new file mode 100644 index 00000000..b7712f6f --- /dev/null +++ b/lib/docs/scrapers/handlebars.rb @@ -0,0 +1,23 @@ +module Docs + class Handlebars < UrlScraper + self.name = 'Handlebars.js' + self.slug = 'handlebars' + self.type = 'handlebars' + self.release = '4.0.11' + self.base_url = 'https://handlebarsjs.com/' + self.links = { + home: 'https://handlebarsjs.com/', + code: 'https://github.com/wycats/handlebars.js/' + } + + html_filters.push 'handlebars/entries', 'handlebars/clean_html', 'title' + + options[:container] = '#contents' + options[:root_title] = 'Handlebars.js' + + options[:attribution] = <<-HTML + © 2011-2017 by Yehuda Katz
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/handlebars/16.png b/public/icons/docs/handlebars/16.png new file mode 100644 index 00000000..1b877783 Binary files /dev/null and b/public/icons/docs/handlebars/16.png differ diff --git a/public/icons/docs/handlebars/16@2x.png b/public/icons/docs/handlebars/16@2x.png new file mode 100644 index 00000000..426288c7 Binary files /dev/null and b/public/icons/docs/handlebars/16@2x.png differ diff --git a/public/icons/docs/handlebars/SOURCE b/public/icons/docs/handlebars/SOURCE new file mode 100644 index 00000000..aa446ef6 --- /dev/null +++ b/public/icons/docs/handlebars/SOURCE @@ -0,0 +1 @@ +https://github.com/yahoo/formatjs-site/tree/master/public/img