Forráskód Böngészése

Add nginx documentation

Thibaut 11 éve
szülő
commit
78beda8974

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


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

@@ -207,6 +207,11 @@ credits = [
     '2011-2014 Tim Wood, Iskren Chernev, Moment.js contributors',
     'MIT',
     'https://raw.github.com/moment/moment/master/LICENSE'
+  ], [
+    'nginx',
+    '2002-2014 Igor Sysoev<br>&copy; 2011-2014 Nginx, Inc.',
+    'BSD',
+    'http://nginx.org/LICENSE'
   ], [
     'Node.js',
     'Joyent, Inc. and other Node contributors<br>Node.js is a trademark of Joyent, Inc.',

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

@@ -33,7 +33,10 @@ newsItem = (date, news) ->
   result
 
 app.news = [
-  [ 1413158400000, # October 13, 2014
+  [ 1413590400000, # October 18, 2014
+    """ New <a href="/nginx/">nginx</a> documentation """,
+  ], [
+    1413158400000, # October 13, 2014
     """ New <a href="/xpath/">XPath</a> documentation """,
   ], [
     1410048000000, # September 7, 2014

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

@@ -49,6 +49,7 @@
         'pages/maxcdn',
         'pages/mdn',
         'pages/moment',
+        'pages/nginx',
         'pages/node',
         'pages/php',
         'pages/postgres',

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

@@ -65,3 +65,4 @@
 ._icon-markdown:before      { background-position: -1rem -10rem; }
 ._icon-django:before        { background-position: -2rem -10rem; }
 ._icon-xpath:before         { background-position: -3rem -10rem; }
+._icon-nginx:before         { background-position: -4rem -10rem; }

+ 5 - 0
assets/stylesheets/pages/_nginx.scss

@@ -0,0 +1,5 @@
+._nginx {
+  h4 { @extend %block-heading; }
+  .note { @extend %note; }
+  .directive { margin: 2.5em 0 1em; }
+}

+ 29 - 0
lib/docs/filters/nginx/clean_html.rb

@@ -0,0 +1,29 @@
+module Docs
+  class Nginx
+    class CleanHtmlFilter < Filter
+      def call
+        at_css('h2').name = 'h1'
+
+        css('center').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('blockquote > pre', 'blockquote > table:only-child').each do |node|
+          node.parent.before(node).remove
+        end
+
+        css('a[name]').each do |node|
+          node.next_element['id'] = node['name']
+          node.remove
+        end
+
+        links = css('h1 + table > tr:only-child > td:only-child > a').map(&:to_html)
+        if links.present?
+          at_css('h1 + table').replace("<ul><li>#{links.join('</li><li>')}</li></ul>")
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 33 - 0
lib/docs/filters/nginx/entries.rb

@@ -0,0 +1,33 @@
+module Docs
+  class Nginx
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('h1').content.strip
+        name.sub! %r{\AModule ngx}, 'ngx'
+        name
+      end
+
+      def get_type
+        if name.starts_with?('ngx_')
+          name
+        elsif slug == 'ngx_core_module'
+          'Core'
+        else
+          'Guides'
+        end
+      end
+
+      def additional_entries
+        css('h1 + ul a').each_with_object [] do |node, entries|
+          name = node.content.strip
+          next if name =~ /\A[A-Z]/
+
+          id = node['href'].remove('#')
+          next if id.blank?
+
+          entries << [name, id]
+        end
+      end
+    end
+  end
+end

+ 25 - 0
lib/docs/scrapers/nginx.rb

@@ -0,0 +1,25 @@
+module Docs
+  class Nginx < UrlScraper
+    self.name = 'nginx'
+    self.type = 'nginx'
+    self.version = '1.7.6'
+    self.base_url = 'http://nginx.org/en/docs/'
+
+    html_filters.push 'nginx/clean_html', 'nginx/entries'
+
+    options[:container] = '#content'
+
+    options[:skip] = %w(
+      contributing_changes.html
+      dirindex.html
+      varindex.html)
+
+    options[:skip_patterns] = [/\/faq\//]
+
+    options[:attribution] = <<-HTML
+      &copy; 2002-2014 Igor Sysoev<br>
+      &copy; 2011-2014 Nginx, Inc.<br>
+      Licensed under the BSD License.
+    HTML
+  end
+end

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


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


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

@@ -0,0 +1 @@
+http://nginx.org/