Bläddra i källkod

Add Moment.js Timezone (0.5.37)

Tim Lim 3 år sedan
förälder
incheckning
850366459b

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

@@ -581,6 +581,11 @@ credits = [
     'JS Foundation and other contributors',
     'MIT',
     'https://raw.githubusercontent.com/moment/moment/master/LICENSE'
+  ], [
+    'Moment.js Timezone',
+    'JS Foundation and other contributors',
+    'MIT',
+    'https://raw.githubusercontent.com/moment/moment-timezone/master/LICENSE'
   ], [
     'Mongoose',
     '2010 LearnBoost',

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

@@ -87,6 +87,7 @@
         'pages/mkdocs',
         'pages/modernizr',
         'pages/moment',
+        'pages/moment_timezone',
         'pages/nginx',
         'pages/node',
         'pages/npm',

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

@@ -0,0 +1,5 @@
+._moment_timezone {
+  > h2 { @extend %block-heading; }
+  > h3 { @extend %block-label, %label-blue; }
+  code { @extend %label; }
+}

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

@@ -0,0 +1,29 @@
+module Docs
+  class MomentTimezone
+    class CleanHtmlFilter < Filter
+      def call
+        # Set id attributes on headings
+        css('a.docs-section-target', 'a.docs-method-target').each do |node|
+          node.next_element['id'] = node['id']
+          node.remove
+        end
+
+        css('> article', '.docs-method-prose', '.docs-method-signature', 'h2 > a', 'h3 > a', 'pre > code').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('.docs-method-edit', 'hr').remove
+
+        css('pre').each do |node|
+          if node.content =~ /\A</
+            node['data-language'] = 'html'
+          elsif node.content !~ /\A\d/
+            node['data-language'] = 'javascript'
+          end
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 23 - 0
lib/docs/filters/moment_timezone/entries.rb

@@ -0,0 +1,23 @@
+module Docs
+  class MomentTimezone
+    class EntriesFilter < Docs::EntriesFilter
+
+      def additional_entries
+        entries = []
+        type = nil
+
+        css('[id]').each do |node|
+          if node.name == 'h2'
+            type = node.content
+            name = "Intro"
+          else
+            name = node.content.strip
+          end
+          entries << [name, node['id'], type]
+        end
+
+        entries
+      end
+    end
+  end
+end

+ 30 - 0
lib/docs/scrapers/moment_timezone.rb

@@ -0,0 +1,30 @@
+module Docs
+  class MomentTimezone < UrlScraper
+    self.name = 'Moment.js Timezone'
+    self.slug = 'moment_timezone'
+    self.type = 'moment_timezone'
+    self.release = '0.5.37'
+    self.base_url = 'https://momentjs.com/timezone'
+    self.root_path = '/docs/'
+    self.initial_paths = %w(/docs/)
+    self.links = {
+      home: 'http://momentjs.com/timezone/',
+      code: 'https://github.com/moment/moment-timezone/'
+    }
+
+    html_filters.push 'moment_timezone/clean_html', 'moment_timezone/entries', 'title'
+
+    options[:title] = 'Moment.js Timezone'
+    options[:container] = '.docs-content'
+    options[:skip_links] = true
+
+    options[:attribution] = <<-HTML
+      &copy; JS Foundation and other contributors<br>
+      Licensed under the MIT License.
+    HTML
+
+    def get_latest_version(opts)
+      get_github_tags('moment', 'moment-timezone', opts)[0]['name']
+    end
+  end
+end

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


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


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

@@ -0,0 +1 @@
+https://momentjs.com/static/img/moment-timezone-favicon.png