Browse Source

Add Cordova documentation

Thibaut 11 years ago
parent
commit
405e263172

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -100,6 +100,11 @@ credits = [
     '2009-2014 Jeremy Ashkenas',
     'MIT',
     'https://raw.github.com/jashkenas/coffee-script/master/LICENSE'
+  ], [
+    'Cordova',
+    '2012 The Apache Software Foundation',
+    'Apache',
+    'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'
   ], [
     'CSS<br>DOM<br>HTML<br>JavaScript',
     '2005-2013 Mozilla Developer Network and individual contributors',

+ 4 - 1
assets/javascripts/templates/pages/news_tmpl.coffee

@@ -24,7 +24,10 @@ newsItem = (date, news) ->
   result
 
 app.news = [
-  [ 1404172800000, # July 1, 2014
+  [ 1404518400000, # July 5, 2014
+    """ New <a href="/cordova/">Cordova</a> documentation """,
+  ], [
+    1404172800000, # July 1, 2014
     """ New <a href="/chai/">Chai</a> and <a href="/sinon/">Sinon</a> documentations """,
   ], [
     1402790400000, # June 15, 2014

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -32,6 +32,7 @@
         'pages/c',
         'pages/chai',
         'pages/coffeescript',
+        'pages/cordova',
         'pages/d3',
         'pages/ember',
         'pages/express',

+ 2 - 1
assets/stylesheets/global/_icons.scss

@@ -4,7 +4,7 @@
   width: 1rem;
   height: 1rem;
   background-image: image-url('icons.png');
-  background-size: 5rem 10rem;
+  background-size: 5rem 11rem;
 }
 
 @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@@ -61,3 +61,4 @@
 ._icon-requirejs:before     { background-position: -2rem -9rem; }
 ._icon-chai:before          { background-position: -3rem -9rem; }
 ._icon-sinon:before         { background-position: -4rem -9rem; }
+._icon-cordova:before       { background-position: 0 -10rem; }

+ 10 - 0
assets/stylesheets/pages/_cordova.scss

@@ -0,0 +1,10 @@
+._cordova {
+  padding-left: 1rem;
+
+  > h1, > h2 { margin-left: -1rem; }
+  > h2 { @extend %block-heading; }
+  > h3 { font-size: 1rem; }
+
+  code { @extend %label; }
+  blockquote { @extend %note; }
+}

+ 34 - 0
lib/docs/filters/cordova/clean_html.rb

@@ -0,0 +1,34 @@
+module Docs
+  class Cordova
+    class CleanHtmlFilter < Filter
+      def call
+        if root_page? || slug == 'cordova_events_events.md'
+          css('h1, h2').each do |node|
+            node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
+          end
+          at_css('h2').name = 'h1' if slug == 'cordova_events_events.md'
+        end
+
+        if root_page?
+          css('li > h3').each do |node|
+            node.name = 'div'
+          end
+        end
+
+        css('hr').remove
+
+        css('a[name]').each do |node|
+          node.parent['id'] = node['name']
+          node.before(node.children).remove
+        end
+
+        # Remove code highlighting
+        css('pre').each do |node|
+          node.content = node.content.remove(/^\ {4,5}/)
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 25 - 0
lib/docs/filters/cordova/entries.rb

@@ -0,0 +1,25 @@
+module Docs
+  class Cordova
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('h1').content.remove(' Guide')
+      end
+
+      def get_type
+        if subpath.start_with?('guide_platforms')
+          name[/Amazon\ Fire\ OS|Android|BlackBerry|Firefox OS|iOS|Windows/] || 'Platform Guides'
+        else
+          'Guides'
+        end
+      end
+
+      def additional_entries
+        return [] unless slug == 'cordova_events_events.md'
+
+        css('h2').map do |node|
+          [node.content, node['id'], 'Events']
+        end
+      end
+    end
+  end
+end

+ 21 - 0
lib/docs/scrapers/cordova.rb

@@ -0,0 +1,21 @@
+module Docs
+  class Cordova < UrlScraper
+    self.name = 'Cordova'
+    self.type = 'cordova'
+    self.version = '3.5.0'
+    self.base_url = 'http://cordova.apache.org/docs/en/3.5.0/'
+    self.root_path = 'index.html'
+
+    html_filters.push 'cordova/clean_html', 'cordova/entries', 'title'
+
+    options[:container] = ->(filter) { filter.root_page? ? '#home' : '#content' }
+    options[:title] = false
+    options[:root_title] = 'Apache Cordova'
+    options[:skip] = %w(_index.html guide_support_index.md.html)
+
+    options[:attribution] = <<-HTML
+      &copy; 2012 The Apache Software Foundation<br>
+      Licensed under the Apache License 2.0.
+    HTML
+  end
+end

BIN
public/icons/docs/cordova/16.png


BIN
public/icons/docs/cordova/16@2x.png


+ 1 - 0
public/icons/docs/cordova/SOURCE

@@ -0,0 +1 @@
+http://cordova.apache.org/artwork.html