diff --git a/assets/images/icons.png b/assets/images/icons.png index e6c3318b..f87d15ea 100644 Binary files a/assets/images/icons.png and b/assets/images/icons.png differ diff --git a/assets/images/icons@2x.png b/assets/images/icons@2x.png index 330d0858..1728d3e4 100644 Binary files a/assets/images/icons@2x.png and b/assets/images/icons@2x.png differ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 77b98372..fcb26bf6 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -143,6 +143,11 @@ credits = [ '2009-2013 The Dojo Foundation', 'MIT', 'https://raw.github.com/lodash/lodash/master/LICENSE.txt' + ], [ + 'Moment.js', + '2011-2014 Tim Wood, Iskren Chernev, Moment.js contributors', + 'MIT', + 'https://raw.github.com/moment/moment/master/LICENSE' ], [ 'Node.js', 'Joyent, Inc. and other Node contributors
Node.js is a trademark of Joyent, Inc.', diff --git a/assets/javascripts/templates/pages/news_tmpl.coffee b/assets/javascripts/templates/pages/news_tmpl.coffee index 8e284a18..a767f935 100644 --- a/assets/javascripts/templates/pages/news_tmpl.coffee +++ b/assets/javascripts/templates/pages/news_tmpl.coffee @@ -24,7 +24,10 @@ newsItem = (date, news) -> result app.news = [ - [ 1392163200000, # February 12, 2013 + [ 1392508800000, # February 16, 2013 + """ New Moment.js documentation """, + ], [ + 1392163200000, # February 12, 2013 """ The root/category pages are now included in the search index (e.g. CSS) """, ], [ 1390694400000, # January 26, 2013 diff --git a/assets/javascripts/views/pages/moment.coffee b/assets/javascripts/views/pages/moment.coffee new file mode 100644 index 00000000..c7e94d2e --- /dev/null +++ b/assets/javascripts/views/pages/moment.coffee @@ -0,0 +1,6 @@ +#= require views/pages/base + +class app.views.MomentPage extends app.views.BasePage + afterRender: -> + @highlightCode @findAll('pre'), 'javascript' + return diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index de05a2e0..9baf4415 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -37,6 +37,7 @@ 'pages/less', 'pages/lodash', 'pages/mdn', + 'pages/moment', 'pages/node', 'pages/php', 'pages/postgres', diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index a1f490f2..8d8df115 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -47,3 +47,4 @@ ._icon-postgresql:before { background-position: -3rem -6rem; } ._icon-d3:before { background-position: -4rem -6rem; } ._icon-knockout:before { background-position: 0 -7rem; } +._icon-moment:before { background-position: -1rem -7rem; } diff --git a/assets/stylesheets/pages/_moment.scss b/assets/stylesheets/pages/_moment.scss new file mode 100644 index 00000000..eb5eb399 --- /dev/null +++ b/assets/stylesheets/pages/_moment.scss @@ -0,0 +1,7 @@ +._moment { + > h2 { @extend %block-heading; } + > h3 { @extend %block-label, %label-blue; } + > h3 > span { float: right;} + h4 { font-size: 1em; } + code { @extend %label; } +} diff --git a/lib/docs/filters/moment/clean_html.rb b/lib/docs/filters/moment/clean_html.rb new file mode 100644 index 00000000..5330bcc6 --- /dev/null +++ b/lib/docs/filters/moment/clean_html.rb @@ -0,0 +1,26 @@ +module Docs + class Moment + class CleanHtmlFilter < Filter + def call + # Set id attributes on headings + css('a.target').each do |node| + node.next_element['id'] = node['name'].sub(/\A\//, '').sub(/\/\z/, '').gsub('/', '-') + end + + css('> article', '.prose', 'h2 > a', 'h3 > a', 'pre > code').each do |node| + node.before(node.children).remove + end + + # Remove introduction + doc.child.remove while doc.child['id'] != 'parsing' + + # Remove plugin list + doc.children.last.remove while doc.children.last['id'] != 'plugins' + + css('.hash', '#plugins').remove + + doc + end + end + end +end diff --git a/lib/docs/filters/moment/entries.rb b/lib/docs/filters/moment/entries.rb new file mode 100644 index 00000000..09a4fea8 --- /dev/null +++ b/lib/docs/filters/moment/entries.rb @@ -0,0 +1,46 @@ +module Docs + class Moment + class EntriesFilter < Docs::EntriesFilter + IGNORE_IDS = %w( + i18n-loading-into-nodejs + i18n-loading-into-browser + i18n-adding-language + i18n-getting-language) + + def additional_entries + entries = [] + type = nil + + css('[id]').each do |node| + if node.name == 'h2' + type = node.content + next + end + + next if IGNORE_IDS.include?(node['id']) + + if node['id'] == 'utilities-invalid' # bug fix + name = 'moment.invalid()' + elsif %w(Display Durations Get\ +\ Set i18n Manipulate Query Utilities).include?(type) || + %w(parsing-is-valid parsing-parse-zone parsing-unix-timestamp parsing-utc).include?(node['id']) + name = node.next_element.content[/moment(?:\(.*?\))?\.(?:duration\(\)\.)?\w+/] + name.sub! %r{\(.*?\)\.}, '#' + name << '()' + elsif type == 'Customize' + name = node.next_element.content[/moment.lang\(.+?\{\s+(\w+)/, 1] + name.prepend 'Language#' + else + name = node.content.strip + name.sub! %r{\s[\d\.]+\z}, '' # remove version number + name.sub! %r{\s\(.+\)\z}, '' # remove parenthesis + name.prepend 'Parse: ' if type == 'Parse' + end + + entries << [name, node['id'], type] + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/moment.rb b/lib/docs/scrapers/moment.rb new file mode 100644 index 00000000..9f4308c7 --- /dev/null +++ b/lib/docs/scrapers/moment.rb @@ -0,0 +1,20 @@ +module Docs + class Moment < UrlScraper + self.name = 'Moment.js' + self.slug = 'moment' + self.type = 'moment' + self.version = '2.5.1' + self.base_url = 'http://momentjs.com/docs/' + + html_filters.push 'moment/clean_html', 'moment/entries', 'title' + + options[:title] = 'Moment.js' + options[:container] = '.docs' + options[:skip_links] = true + + options[:attribution] = <<-HTML + © 2011–2014 Tim Wood, Iskren Chernev, Moment.js contributors
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/moment/16.png b/public/icons/docs/moment/16.png new file mode 100644 index 00000000..875dcf5d Binary files /dev/null and b/public/icons/docs/moment/16.png differ diff --git a/public/icons/docs/moment/16@2x.png b/public/icons/docs/moment/16@2x.png new file mode 100644 index 00000000..135446ae Binary files /dev/null and b/public/icons/docs/moment/16@2x.png differ