From 752babb9d0f934c1aa56972a299a3240b869f2ae Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sun, 30 Nov 2014 13:56:02 -0500 Subject: [PATCH] Move changelog to a JSON file --- assets/javascripts/news.json | 173 ++++++++++++++ .../templates/pages/news_tmpl.coffee | 219 ------------------ .../templates/pages/news_tmpl.coffee.erb | 37 +++ assets/javascripts/views/misc/news.coffee | 4 +- lib/app.rb | 3 + 5 files changed, 215 insertions(+), 221 deletions(-) create mode 100644 assets/javascripts/news.json delete mode 100644 assets/javascripts/templates/pages/news_tmpl.coffee create mode 100644 assets/javascripts/templates/pages/news_tmpl.coffee.erb diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json new file mode 100644 index 00000000..1da6f359 --- /dev/null +++ b/assets/javascripts/news.json @@ -0,0 +1,173 @@ +[ + [ "2014-11-30", + "New PHPUnit and Nokogiri documentations" + ], [ + "2014-11-16", + "New Python 2 documentation" + ], [ + "2014-11-09", + "New design\nFeedback welcome on Twitter and GitHub." + ], [ + "2014-10-19", + "New SVG, Marionette.js, and Mongoose documentations" + ], [ + "2014-10-18", + "New nginx documentation" + ], [ + "2014-10-13", + "New XPath documentation" + ], [ + "2014-09-07", + "Updated the HTML, CSS, JavaScript, and DOM documentations with additional content." + ], [ + "2014-08-04", + "New Django documentation" + ], [ + "2014-07-27", + "New Markdown documentation" + ], [ + "2014-07-05", + "New Cordova documentation" + ], [ + "2014-07-01", + "New Chai and Sinon documentations" + ], [ + "2014-06-15", + "New RequireJS documentation" + ], [ + "2014-06-14", + "New Haskell documentation" + ], [ + "2014-05-25", + "New Laravel documentation" + ], [ + "2014-05-04", + "New Express, Grunt, and MaxCDN documentations" + ], [ + "2014-04-06", + "New Go documentation" + ], [ + "2014-03-30", + "New C++ documentation" + ], [ + "2014-03-16", + "New Yii documentation" + ], [ + "2014-03-08", + "Added path bar." + ], [ + "2014-02-22", + "New C documentation" + ], [ + "2014-02-16", + "New Moment.js documentation" + ], [ + "2014-02-12", + "The root/category pages are now included in the search index (e.g. CSS)" + ], [ + "2014-01-26", + "Updated Angular.js documentation" + ], [ + "2014-01-19", + "New D3.js and Knockout.js documentations" + ], [ + "2014-01-18", + "DevDocs is now available as a Firefox web app (currently requires Aurora)." + ], [ + "2014-01-12", + "Added alt + g shortcut for searching on Google.", + "Added alt + r shortcut for revealing the current page in the sidebar." + ], [ + "2013-12-14", + "New PostgreSQL documentation" + ], [ + "2013-12-13", + "New Git and Redis documentations" + ], [ + "2013-11-26", + "New Python documentation" + ], [ + "2013-11-19", + "New Ruby on Rails documentation" + ], [ + "2013-11-16", + "New Ruby documentation" + ], [ + "2013-10-24", + "DevDocs is now open source." + ], [ + "2013-10-09", + "DevDocs is now available as a Chrome web app." + ], [ + "2013-09-22", + "New PHP documentation" + ], [ + "2013-09-06", + "New Lo-Dash documentation ", + "On mobile devices you can now search a specific documentation by typing its name and Space." + ], [ + "2013-09-01", + "New jQuery UI and jQuery Mobile documentations" + ], [ + "2013-08-28", + "New smartphone interface\nTested on iOS 6+ and Android 4.1+" + ], [ + "2013-08-25", + "New Ember.js documentation" + ], [ + "2013-08-18", + "New CoffeeScript documentation", + "URL search now automatically opens the first result." + ], [ + "2013-08-13", + "New Angular.js documentation" + ], [ + "2013-08-11", + "New Sass and Less documentations" + ], [ + "2013-08-05", + "New Node.js documentation" + ], [ + "2013-08-03", + "Added support for OpenSearch" + ], [ + "2013-07-30", + "New Backbone.js documentation" + ], [ + "2013-07-27", + "You can now customize the list of documentations.\nNew docs will be hidden by default, but you'll see a notification when there are new releases.", + "New HTTP documentation" + ], [ + "2013-07-15", + "URL search now works with single documentations: devdocs.io/#q=js sort" + ], [ + "2013-07-13", + "Added syntax highlighting", + "Added documentation versions" + ], [ + "2013-07-11", + "New Underscore.js documentation ", + "Improved compatibility with tablets\nA mobile version is planned as soon as other high priority features have been implemented." + ], [ + "2013-07-10", + "You can now search specific documentations.\nSimply type the documentation's name and press Tab.\nThe name is fuzzy matched so you can use abbreviations like js for JavaScript." + ], [ + "2013-07-08", + "Improved search with fuzzy matching and better results\nFor example, searching jqmka now returns jQuery.makeArray().", + "DevDocs finally has an icon.", + "space has replaced alt + space for scrolling down." + ], [ + "2013-07-06", + "New DOM and DOM Events documentations\nDevDocs now includes almost all reference documents available on the Mozilla Developer Network.\nBig thank you to Mozilla and all the people that contributed to MDN.", + "Implemented URL search: devdocs.io/#q=sort" + ], [ + "2013-07-02", + "New JavaScript documentation" + ], [ + "2013-06-28", + "DevDocs made the front page of Hacker News!\nHi everyone — thanks for trying DevDocs.\nPlease bear with me while I fix bugs and scramble to add more docs.\nThis is only v1. There's a lot more to come." + ], [ + "2013-06-18", + "Initial release" + ] +] diff --git a/assets/javascripts/templates/pages/news_tmpl.coffee b/assets/javascripts/templates/pages/news_tmpl.coffee deleted file mode 100644 index 175ff324..00000000 --- a/assets/javascripts/templates/pages/news_tmpl.coffee +++ /dev/null @@ -1,219 +0,0 @@ -app.templates.newsPage = -> - """

Changelog

-

For the latest news, - subscribe to the newsletter - or follow @DevDocs.
- For development updates, follow the project on GitHub. -

#{app.templates.newsList app.news}
""" - -app.templates.newsList = (news) -> - year = new Date().getUTCFullYear() - result = '' - - for value in news - date = new Date(value[0]) - if year isnt date.getUTCFullYear() - year = date.getUTCFullYear() - result += "

#{year}

" - result += newsItem(date, value[1..]) - - result - -MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] - -newsItem = (date, news) -> - date = """#{MONTHS[date.getUTCMonth()]} #{date.getUTCDate()}""" - result = '' - - for text, i in news - text = text.split "\n" - title = """#{text.shift()}""" - result += """
#{if i is 0 then date else ''} #{title} #{text.join '
'}
""" - - result - -app.news = [ - [ 1417305600000, # November 30, 2014 - """ New PHPUnit and Nokogiri documentations """ - ], [ - 1416096000000, # November 16, 2014 - """ New Python 2 documentation """ - ], [ - 1415491200000, # November 9, 2014 - """ New design - Feedback welcome on Twitter and GitHub. """ - ], [ - 1413676800000, # October 19, 2014 - """ New SVG, Marionette.js, and Mongoose documentations """, - ], [ - 1413590400000, # October 18, 2014 - """ New nginx documentation """, - ], [ - 1413158400000, # October 13, 2014 - """ New XPath documentation """, - ], [ - 1410048000000, # September 7, 2014 - """ Updated the HTML, CSS, JavaScript, and DOM documentations with additional content. """, - ], [ - 1407110400000, # August 4, 2014 - """ New Django documentation """, - ], [ - 1406419200000, # July 27, 2014 - """ New Markdown documentation """, - ], [ - 1404518400000, # July 5, 2014 - """ New Cordova documentation """, - ], [ - 1404172800000, # July 1, 2014 - """ New Chai and Sinon documentations """, - ], [ - 1402790400000, # June 15, 2014 - """ New RequireJS documentation """, - ], [ - 1402704000000, # June 14, 2014 - """ New Haskell documentation """, - ], [ - 1400976000000, # May 25, 2014 - """ New Laravel documentation """, - ], [ - 1399161600000, # May 4, 2014 - """ New Express, Grunt, and MaxCDN documentations """, - ], [ - 1396742400000, # April 6, 2014 - """ New Go documentation """, - ], [ - 1396137600000, # March 30, 2014 - """ New C++ documentation """, - ], [ - 1394928000000, # March 16, 2014 - """ New Yii documentation """, - ], [ - 1394236800000, # March 8, 2014 - """ Added path bar. """, - ], [ - 1393027200000, # February 22, 2014 - """ New C documentation """, - ], [ - 1392508800000, # February 16, 2014 - """ New Moment.js documentation """, - ], [ - 1392163200000, # February 12, 2014 - """ The root/category pages are now included in the search index (e.g. CSS) """, - ], [ - 1390694400000, # January 26, 2014 - """ Updated Angular.js documentation """, - ], [ - 1390089600000, # January 19, 2014 - """ New D3.js and Knockout.js documentations """, - ], [ - 1390003200000, # January 18, 2014 - """ DevDocs is now available as a Firefox web app (currently requires Aurora). """, - ], [ - 1389484800000, # January 12, 2014 - """ Added alt + g shortcut for searching on Google. """, - """ Added alt + r shortcut for revealing the current page in the sidebar. """ - ], [ - 1386979200000, # December 14, 2013 - """ New PostgreSQL documentation """ - ], [ - 1386892800000, # December 13, 2013 - """ New Git and Redis documentations """ - ], [ - 1385424000000, # November 26, 2013 - """ New Python documentation """ - ], [ - 1384819200000, # November 19, 2013 - """ New Ruby on Rails documentation """ - ], [ - 1384560000000, # November 16, 2013 - """ New Ruby documentation """ - ], [ - 1382572800000, # October 24, 2013 - """ DevDocs is now open source. """ - ], [ - 1381276800000, # October 9, 2013 - """ DevDocs is now available as a Chrome web app. """ - ], [ - 1379808000000, # September 22, 2013 - """ New PHP documentation """ - ], [ - 1378425600000, # September 6, 2013 - """ New Lo-Dash documentation """, - """ On mobile devices you can now search a specific documentation by typing its name and Space. """ - ], [ - 1377993600000, # September 1, 2013 - """ New jQuery UI and jQuery Mobile documentations """ - ], [ - 1377648000000, # August 28, 2013 - """ New smartphone interface - Tested on iOS 6+ and Android 4.1+ """ - ], [ - 1377388800000, # August 25, 2013 - """ New Ember.js documentation """ - ], [ - 1376784000000, # August 18, 2013 - """ New CoffeeScript documentation """, - """ URL search now automatically opens the first result. """ - ], [ - 1376352000000, # August 13, 2013 - """ New Angular.js documentation """ - ], [ - 1376179200000, # August 11, 2013 - """ New Sass and Less documentations """ - ], [ - 1375660800000, # August 5, 2013 - """ New Node.js documentation """ - ], [ - 1375488000000, # August 3, 2013 - """ Added support for OpenSearch """ - ], [ - 1375142400000, # July 30, 2013 - """ New Backbone.js documentation """ - ], [ - 1374883200000, # July 27, 2013 - """ You can now customize the list of documentations. - New docs will be hidden by default, but you'll see a notification when there are new releases. """, - """ New HTTP documentation """ - ], [ - 1373846400000, # July 15, 2013 - """ URL search now works with single documentations: devdocs.io/#q=js sort """ - ], [ - 1373673600000, # July 13, 2013 - """ Added syntax highlighting """, - """ Added documentation versions """ - ], [ - 1373500800000, # July 11, 2013 - """ New Underscore.js documentation """, - """ Improved compatibility with tablets - A mobile version is planned as soon as other high priority features have been implemented. """ - ], [ - 1373414400000, # July 10, 2013 - """ You can now search specific documentations. - Simply type the documentation's name and press Tab. - The name is fuzzy matched so you can use abbreviations like js for JavaScript. """ - ], [ - 1373241600000, # July 8, 2013 - """ Improved search with fuzzy matching and better results - For example, searching jqmka now returns jQuery.makeArray(). """, - """ DevDocs finally has an icon. """, - """ space has replaced alt + space for scrolling down. """ - ], [ - 1373068800000, # July 6, 2013 - """ New DOM and DOM Events documentations - DevDocs now includes almost all reference documents available on the Mozilla Developer Network. - Big thank you to Mozilla and all the people that contributed to MDN. """, - """ Implemented URL search: devdocs.io/#q=sort """ - ], [ - 1372723200000, # July 2, 2013 - """ New JavaScript documentation """ - ], [ - 1372377600000, # June 28, 2013 - """ DevDocs made the front page of Hacker News! - Hi everyone — thanks for trying DevDocs. - Please bear with me while I fix bugs and scramble to add more docs. - This is only v1. There's a lot more to come. """ - ], [ - 1371513600000, # June 18, 2013 - """ Initial release """ - ] -] diff --git a/assets/javascripts/templates/pages/news_tmpl.coffee.erb b/assets/javascripts/templates/pages/news_tmpl.coffee.erb new file mode 100644 index 00000000..d670e307 --- /dev/null +++ b/assets/javascripts/templates/pages/news_tmpl.coffee.erb @@ -0,0 +1,37 @@ +#= depend_on news.json + +app.templates.newsPage = -> + """

Changelog

+

For the latest news, + subscribe to the newsletter + or follow @DevDocs.
+ For development updates, follow the project on GitHub. +

#{app.templates.newsList app.news}
""" + +app.templates.newsList = (news) -> + year = new Date().getUTCFullYear() + result = '' + + for value in news + date = new Date(value[0]) + if year isnt date.getUTCFullYear() + year = date.getUTCFullYear() + result += "

#{year}

" + result += newsItem(date, value[1..]) + + result + +MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] + +newsItem = (date, news) -> + date = """#{MONTHS[date.getUTCMonth()]} #{date.getUTCDate()}""" + result = '' + + for text, i in news + text = text.split "\n" + title = """#{text.shift()}""" + result += """
#{if i is 0 then date else ''} #{title} #{text.join '
'}
""" + + result + +app.news = <%= App.news.to_json %> diff --git a/assets/javascripts/views/misc/news.coffee b/assets/javascripts/views/misc/news.coffee index 57eb3348..04f50270 100644 --- a/assets/javascripts/views/misc/news.coffee +++ b/assets/javascripts/views/misc/news.coffee @@ -20,11 +20,11 @@ class app.views.News extends app.views.Notif return [] unless time = @getLastReadTime() for news in app.news - break if news[0] <= time + break if new Date(news[0]).getTime() <= time news getLastNewsTime: -> - app.news[0][0] + new Date(app.news[0][0]).getTime() getLastReadTime: -> app.store.get 'news' diff --git a/lib/app.rb b/lib/app.rb index 85f53f33..7eafe57f 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -26,6 +26,9 @@ class App < Sinatra::Application set :docs_manifest_path, -> { File.join(docs_path, 'docs.json') } set :docs, -> { Hash[JSON.parse(File.read(docs_manifest_path)).map! { |doc| [doc['slug'], doc] }] } + set :news_path, -> { File.join(root, assets_prefix, 'javascripts', 'news.json') } + set :news, -> { JSON.parse(File.read(news_path)) } + Dir[docs_path, root.join(assets_prefix, '*/')].each do |path| sprockets.append_path(path) end