diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 26ca8e7e..7e5f7505 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -190,6 +190,11 @@ credits = [ '2009-2018 Jeremy Ashkenas', 'MIT', 'https://raw.githubusercontent.com/jashkenas/coffeescript/master/LICENSE' + ], [ + 'Composer', + '2012-2018 Nils Adermann, Jordi Boggiano', + 'MIT', + 'https://github.com/composer/composer/blob/master/LICENSE' ], [ 'Cordova', '2012-2017 The Apache Software Foundation', diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index fe36579d..8293bed0 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -21,6 +21,7 @@ ._bower, ._chai, ._codeceptjs, +._composer, ._docker, ._electron, ._fish, diff --git a/lib/docs/filters/composer/clean_html.rb b/lib/docs/filters/composer/clean_html.rb new file mode 100644 index 00000000..b4abce49 --- /dev/null +++ b/lib/docs/filters/composer/clean_html.rb @@ -0,0 +1,25 @@ +module Docs + class Composer + class CleanHtmlFilter < Filter + def call + # Remove unneeded elements + css('#searchbar, .toc, .fork-and-edit, .anchor').remove + + # Code blocks + css('pre').each do |node| + code = node.at_css('code[class]') + + unless code.nil? + node['data-language'] = 'javascript' if code['class'].include?('javascript') + node['data-language'] = 'php' if code['class'].include?('php') + end + + node.content = node.content.strip + node.remove_attribute('class') + end + + doc + end + end + end +end diff --git a/lib/docs/filters/composer/entries.rb b/lib/docs/filters/composer/entries.rb new file mode 100644 index 00000000..7547dd38 --- /dev/null +++ b/lib/docs/filters/composer/entries.rb @@ -0,0 +1,39 @@ +module Docs + class Composer + class EntriesFilter < Docs::EntriesFilter + def get_name + title = at_css('h1').content + + title = "#{Integer(subpath[1]) + 1}. #{title}" if type == 'Book' + + title + end + + def get_type + return 'Articles' if subpath.start_with?('articles/') + + 'Book' + end + + def additional_entries + entries = [] + + if subpath == '04-schema.md' # JSON Schema + css('h3').each do |node| + name = node.content.strip + name.remove!(' (root-only)') + entries << [name, node['id'], 'JSON Schema'] + end + end + + if subpath == '06-config.md' # Composer config + css('h2').each do |node| + entries << [node.content.strip, node['id'], 'Configuration Options'] + end + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/composer.rb b/lib/docs/scrapers/composer.rb new file mode 100644 index 00000000..e62aab43 --- /dev/null +++ b/lib/docs/scrapers/composer.rb @@ -0,0 +1,27 @@ +module Docs + class Composer < UrlScraper + self.name = 'Composer' + self.type = 'composer' + + self.links = { + home: 'https://getcomposer.org', + code: 'https://github.com/composer/composer' + } + + html_filters.push 'composer/clean_html', 'composer/entries' + + self.release = '1.7.2' + self.base_url = 'https://getcomposer.org/doc/' + + options[:container] = '#main' + + options[:skip_patterns] = [ + /^faqs/ + ] + + options[:attribution] = <<-HTML + © Nils Adermann, Jordi Boggiano
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/composer/16.png b/public/icons/docs/composer/16.png new file mode 100644 index 00000000..bfbdb4d9 Binary files /dev/null and b/public/icons/docs/composer/16.png differ diff --git a/public/icons/docs/composer/16@2x.png b/public/icons/docs/composer/16@2x.png new file mode 100644 index 00000000..0dea6b00 Binary files /dev/null and b/public/icons/docs/composer/16@2x.png differ diff --git a/public/icons/docs/composer/SOURCE b/public/icons/docs/composer/SOURCE new file mode 100644 index 00000000..ea9acaa7 --- /dev/null +++ b/public/icons/docs/composer/SOURCE @@ -0,0 +1 @@ +https://github.com/composer/getcomposer.org/blob/master/web/img/logo-composer-transparent.png