History

Move changelog to a JSON file

Thibaut committed 11 years ago

Commit 752babb1 parent d74d0e75 files · +215 −221Browse files

Unified · Split

5 files
  1. assets/javascripts/news.json +173 −0
  2. assets/javascripts/templates/pages/news_tmpl.coffee +0 −219
  3. assets/javascripts/templates/pages/news_tmpl.coffee.erb +37 −0
  4. assets/javascripts/views/misc/news.coffee +2 −2
  5. lib/app.rb +3 −0
assets/javascripts/news.json+173−0
@@ -0,0 +1,173 @@
1+[
2+ [ "2014-11-30",
3+ "New <a href=\"/phpunit/\">PHPUnit</a> and <a href=\"/nokogiri/\">Nokogiri</a> documentations"
4+ ], [
5+ "2014-11-16",
6+ "New <a href=\"/python2/\">Python 2</a> documentation"
7+ ], [
8+ "2014-11-09",
9+ "New design\nFeedback welcome on <a href=\"https://twitter.com/DevDocs\" target=\"_blank\">Twitter</a> and <a href=\"https://github.com/Thibaut/devdocs\" target=\"_blank\">GitHub</a>."
10+ ], [
11+ "2014-10-19",
12+ "New <a href=\"/svg/\">SVG</a>, <a href=\"/marionette/\">Marionette.js</a>, and <a href=\"/mongoose/\">Mongoose</a> documentations"
13+ ], [
14+ "2014-10-18",
15+ "New <a href=\"/nginx/\">nginx</a> documentation"
16+ ], [
17+ "2014-10-13",
18+ "New <a href=\"/xpath/\">XPath</a> documentation"
19+ ], [
20+ "2014-09-07",
21+ "Updated the HTML, CSS, JavaScript, and DOM documentations with additional content."
22+ ], [
23+ "2014-08-04",
24+ "New <a href=\"/django/\">Django</a> documentation"
25+ ], [
26+ "2014-07-27",
27+ "New <a href=\"/markdown/\">Markdown</a> documentation"
28+ ], [
29+ "2014-07-05",
30+ "New <a href=\"/cordova/\">Cordova</a> documentation"
31+ ], [
32+ "2014-07-01",
33+ "New <a href=\"/chai/\">Chai</a> and <a href=\"/sinon/\">Sinon</a> documentations"
34+ ], [
35+ "2014-06-15",
36+ "New <a href=\"/requirejs/\">RequireJS</a> documentation"
37+ ], [
38+ "2014-06-14",
39+ "New <a href=\"/haskell/\">Haskell</a> documentation"
40+ ], [
41+ "2014-05-25",
42+ "New <a href=\"/laravel/\">Laravel</a> documentation"
43+ ], [
44+ "2014-05-04",
45+ "New <a href=\"/express/\">Express</a>, <a href=\"/grunt/\">Grunt</a>, and <a href=\"/maxcdn/\">MaxCDN</a> documentations"
46+ ], [
47+ "2014-04-06",
48+ "New <a href=\"/go/\">Go</a> documentation"
49+ ], [
50+ "2014-03-30",
51+ "New <a href=\"/cpp/\">C++</a> documentation"
52+ ], [
53+ "2014-03-16",
54+ "New <a href=\"/yii/\">Yii</a> documentation"
55+ ], [
56+ "2014-03-08",
57+ "Added path bar."
58+ ], [
59+ "2014-02-22",
60+ "New <a href=\"/c/\">C</a> documentation"
61+ ], [
62+ "2014-02-16",
63+ "New <a href=\"/moment/\">Moment.js</a> documentation"
64+ ], [
65+ "2014-02-12",
66+ "The root/category pages are now included in the search index (e.g. <a href=\"/#q=CSS\">CSS</a>)"
67+ ], [
68+ "2014-01-26",
69+ "Updated <a href=\"/angular/\">Angular.js</a> documentation"
70+ ], [
71+ "2014-01-19",
72+ "New <a href=\"/d3/\">D3.js</a> and <a href=\"/knockout/\">Knockout.js</a> documentations"
73+ ], [
74+ "2014-01-18",
75+ "DevDocs is now available as a <a href=\"https://marketplace.firefox.com/app/devdocs/\">Firefox web app</a> (currently requires Aurora)."
76+ ], [
77+ "2014-01-12",
78+ "Added <code class=\"_label\">alt + g</code> shortcut for searching on Google.",
79+ "Added <code class=\"_label\">alt + r</code> shortcut for revealing the current page in the sidebar."
80+ ], [
81+ "2013-12-14",
82+ "New <a href=\"/postgresql/\">PostgreSQL</a> documentation"
83+ ], [
84+ "2013-12-13",
85+ "New <a href=\"/git/\">Git</a> and <a href=\"/redis/\">Redis</a> documentations"
86+ ], [
87+ "2013-11-26",
88+ "New <a href=\"/python/\">Python</a> documentation"
89+ ], [
90+ "2013-11-19",
91+ "New <a href=\"/rails/\">Ruby on Rails</a> documentation"
92+ ], [
93+ "2013-11-16",
94+ "New <a href=\"/ruby/\">Ruby</a> documentation"
95+ ], [
96+ "2013-10-24",
97+ "DevDocs is now <a href=\"https://github.com/Thibaut/devdocs\">open source</a>."
98+ ], [
99+ "2013-10-09",
100+ "DevDocs is now available as a <a href=\"https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe\">Chrome web app</a>."
101+ ], [
102+ "2013-09-22",
103+ "New <a href=\"/php/\">PHP</a> documentation"
104+ ], [
105+ "2013-09-06",
106+ "New <a href=\"/lodash/\">Lo-Dash</a> documentation ",
107+ "On mobile devices you can now search a specific documentation by typing its name and <code class=\"_label\">Space</code>."
108+ ], [
109+ "2013-09-01",
110+ "New <a href=\"/jqueryui/\">jQuery UI</a> and <a href=\"/jquerymobile/\">jQuery Mobile</a> documentations"
111+ ], [
112+ "2013-08-28",
113+ "New smartphone interface\nTested on iOS 6+ and Android 4.1+"
114+ ], [
115+ "2013-08-25",
116+ "New <a href=\"/ember/\">Ember.js</a> documentation"
117+ ], [
118+ "2013-08-18",
119+ "New <a href=\"/coffeescript/\">CoffeeScript</a> documentation",
120+ "URL search now automatically opens the first result."
121+ ], [
122+ "2013-08-13",
123+ "New <a href=\"/angular/\">Angular.js</a> documentation"
124+ ], [
125+ "2013-08-11",
126+ "New <a href=\"/sass/\">Sass</a> and <a href=\"/less/\">Less</a> documentations"
127+ ], [
128+ "2013-08-05",
129+ "New <a href=\"/node/\">Node.js</a> documentation"
130+ ], [
131+ "2013-08-03",
132+ "Added support for OpenSearch"
133+ ], [
134+ "2013-07-30",
135+ "New <a href=\"/backbone/\">Backbone.js</a> documentation"
136+ ], [
137+ "2013-07-27",
138+ "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.",
139+ "New <a href=\"/http/\">HTTP</a> documentation"
140+ ], [
141+ "2013-07-15",
142+ "URL search now works with single documentations: <a href=\"/#q=js%20sort\">devdocs.io/#q=js sort</a>"
143+ ], [
144+ "2013-07-13",
145+ "Added syntax highlighting",
146+ "Added documentation versions"
147+ ], [
148+ "2013-07-11",
149+ "New <a href=\"/underscore/\">Underscore.js</a> documentation ",
150+ "Improved compatibility with tablets\nA mobile version is planned as soon as other high priority features have been implemented."
151+ ], [
152+ "2013-07-10",
153+ "You can now search specific documentations.\nSimply type the documentation's name and press <code class=\"_label\">Tab</code>.\nThe name is fuzzy matched so you can use abbreviations like <code>js</code> for <code>JavaScript</code>."
154+ ], [
155+ "2013-07-08",
156+ "Improved search with fuzzy matching and better results\nFor example, searching <code>jqmka</code> now returns <code>jQuery.makeArray()</code>.",
157+ "DevDocs finally has an icon.",
158+ "<code class=\"_label\">space</code> has replaced <code class=\"_label\">alt + space</code> for scrolling down."
159+ ], [
160+ "2013-07-06",
161+ "New <a href=\"/dom/\">DOM</a> and <a href=\"/dom_events/\">DOM Events</a> 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.",
162+ "Implemented URL search: <a href=\"/#q=sort\">devdocs.io/#q=sort</a>"
163+ ], [
164+ "2013-07-02",
165+ "New <a href=\"/javascript/\">JavaScript</a> documentation"
166+ ], [
167+ "2013-06-28",
168+ "DevDocs made the front page of Hacker News!\nHi everyone &mdash; 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."
169+ ], [
170+ "2013-06-18",
171+ "Initial release"
172+ ]
173+]
assets/javascripts/templates/pages/news_tmpl.coffee+0−219
@@ -1,219 +0,0 @@
1−app.templates.newsPage = ->
2− """ <h1 class="_lined-heading">Changelog</h1>
3− <p class="_note">For the latest news,
4− subscribe to the <a href="http://eepurl.com/HnLUz">newsletter</a>
5− or follow <a href="https://twitter.com/DevDocs">@DevDocs</a>.<br>
6− For development updates, follow the project on <a href="https://github.com/Thibaut/devdocs">GitHub</a>.
7− <div class="_news">#{app.templates.newsList app.news}</div> """
8−
9−app.templates.newsList = (news) ->
10− year = new Date().getUTCFullYear()
11− result = ''
12−
13− for value in news
14− date = new Date(value[0])
15− if year isnt date.getUTCFullYear()
16− year = date.getUTCFullYear()
17− result += "<h4>#{year}</h4>"
18− result += newsItem(date, value[1..])
19−
20− result
21−
22−MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
23−
24−newsItem = (date, news) ->
25− date = """<span class="_news-date">#{MONTHS[date.getUTCMonth()]} #{date.getUTCDate()}</span>"""
26− result = ''
27−
28− for text, i in news
29− text = text.split "\n"
30− title = """<span class="_news-title">#{text.shift()}</span>"""
31− result += """<div class="_news-row">#{if i is 0 then date else ''} #{title} #{text.join '<br>'}</div>"""
32−
33− result
34−
35−app.news = [
36− [ 1417305600000, # November 30, 2014
37− """ New <a href="/phpunit/">PHPUnit</a> and <a href="/nokogiri/">Nokogiri</a> documentations """
38− ], [
39− 1416096000000, # November 16, 2014
40− """ New <a href="/python2/">Python 2</a> documentation """
41− ], [
42− 1415491200000, # November 9, 2014
43− """ New design
44− Feedback welcome on <a href="https://twitter.com/DevDocs" target="_blank">Twitter</a> and <a href="https://github.com/Thibaut/devdocs" target="_blank">GitHub</a>. """
45− ], [
46− 1413676800000, # October 19, 2014
47− """ New <a href="/svg/">SVG</a>, <a href="/marionette/">Marionette.js</a>, and <a href="/mongoose/">Mongoose</a> documentations """,
48− ], [
49− 1413590400000, # October 18, 2014
50− """ New <a href="/nginx/">nginx</a> documentation """,
51− ], [
52− 1413158400000, # October 13, 2014
53− """ New <a href="/xpath/">XPath</a> documentation """,
54− ], [
55− 1410048000000, # September 7, 2014
56− """ Updated the HTML, CSS, JavaScript, and DOM documentations with additional content. """,
57− ], [
58− 1407110400000, # August 4, 2014
59− """ New <a href="/django/">Django</a> documentation """,
60− ], [
61− 1406419200000, # July 27, 2014
62− """ New <a href="/markdown/">Markdown</a> documentation """,
63− ], [
64− 1404518400000, # July 5, 2014
65− """ New <a href="/cordova/">Cordova</a> documentation """,
66− ], [
67− 1404172800000, # July 1, 2014
68− """ New <a href="/chai/">Chai</a> and <a href="/sinon/">Sinon</a> documentations """,
69− ], [
70− 1402790400000, # June 15, 2014
71− """ New <a href="/requirejs/">RequireJS</a> documentation """,
72− ], [
73− 1402704000000, # June 14, 2014
74− """ New <a href="/haskell/">Haskell</a> documentation """,
75− ], [
76− 1400976000000, # May 25, 2014
77− """ New <a href="/laravel/">Laravel</a> documentation """,
78− ], [
79− 1399161600000, # May 4, 2014
80− """ New <a href="/express/">Express</a>, <a href="/grunt/">Grunt</a>, and <a href="/maxcdn/">MaxCDN</a> documentations """,
81− ], [
82− 1396742400000, # April 6, 2014
83− """ New <a href="/go/">Go</a> documentation """,
84− ], [
85− 1396137600000, # March 30, 2014
86− """ New <a href="/cpp/">C++</a> documentation """,
87− ], [
88− 1394928000000, # March 16, 2014
89− """ New <a href="/yii/">Yii</a> documentation """,
90− ], [
91− 1394236800000, # March 8, 2014
92− """ Added path bar. """,
93− ], [
94− 1393027200000, # February 22, 2014
95− """ New <a href="/c/">C</a> documentation """,
96− ], [
97− 1392508800000, # February 16, 2014
98− """ New <a href="/moment/">Moment.js</a> documentation """,
99− ], [
100− 1392163200000, # February 12, 2014
101− """ The root/category pages are now included in the search index (e.g. <a href="/#q=CSS">CSS</a>) """,
102− ], [
103− 1390694400000, # January 26, 2014
104− """ Updated <a href="/angular/">Angular.js</a> documentation """,
105− ], [
106− 1390089600000, # January 19, 2014
107− """ New <a href="/d3/">D3.js</a> and <a href="/knockout/">Knockout.js</a> documentations """,
108− ], [
109− 1390003200000, # January 18, 2014
110− """ DevDocs is now available as a <a href="https://marketplace.firefox.com/app/devdocs/">Firefox web app</a> (currently requires Aurora). """,
111− ], [
112− 1389484800000, # January 12, 2014
113− """ Added <code class="_label">alt + g</code> shortcut for searching on Google. """,
114− """ Added <code class="_label">alt + r</code> shortcut for revealing the current page in the sidebar. """
115− ], [
116− 1386979200000, # December 14, 2013
117− """ New <a href="/postgresql/">PostgreSQL</a> documentation """
118− ], [
119− 1386892800000, # December 13, 2013
120− """ New <a href="/git/">Git</a> and <a href="/redis/">Redis</a> documentations """
121− ], [
122− 1385424000000, # November 26, 2013
123− """ New <a href="/python/">Python</a> documentation """
124− ], [
125− 1384819200000, # November 19, 2013
126− """ New <a href="/rails/">Ruby on Rails</a> documentation """
127− ], [
128− 1384560000000, # November 16, 2013
129− """ New <a href="/ruby/">Ruby</a> documentation """
130− ], [
131− 1382572800000, # October 24, 2013
132− """ DevDocs is now <a href="https://github.com/Thibaut/devdocs">open source</a>. """
133− ], [
134− 1381276800000, # October 9, 2013
135− """ DevDocs is now available as a <a href="https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe">Chrome web app</a>. """
136− ], [
137− 1379808000000, # September 22, 2013
138− """ New <a href="/php/">PHP</a> documentation """
139− ], [
140− 1378425600000, # September 6, 2013
141− """ New <a href="/lodash/">Lo-Dash</a> documentation """,
142− """ On mobile devices you can now search a specific documentation by typing its name and <code class="_label">Space</code>. """
143− ], [
144− 1377993600000, # September 1, 2013
145− """ New <a href="/jqueryui/">jQuery UI</a> and <a href="/jquerymobile/">jQuery Mobile</a> documentations """
146− ], [
147− 1377648000000, # August 28, 2013
148− """ New smartphone interface
149− Tested on iOS 6+ and Android 4.1+ """
150− ], [
151− 1377388800000, # August 25, 2013
152− """ New <a href="/ember/">Ember.js</a> documentation """
153− ], [
154− 1376784000000, # August 18, 2013
155− """ New <a href="/coffeescript/">CoffeeScript</a> documentation """,
156− """ URL search now automatically opens the first result. """
157− ], [
158− 1376352000000, # August 13, 2013
159− """ New <a href="/angular/">Angular.js</a> documentation """
160− ], [
161− 1376179200000, # August 11, 2013
162− """ New <a href="/sass/">Sass</a> and <a href="/less/">Less</a> documentations """
163− ], [
164− 1375660800000, # August 5, 2013
165− """ New <a href="/node/">Node.js</a> documentation """
166− ], [
167− 1375488000000, # August 3, 2013
168− """ Added support for OpenSearch """
169− ], [
170− 1375142400000, # July 30, 2013
171− """ New <a href="/backbone/">Backbone.js</a> documentation """
172− ], [
173− 1374883200000, # July 27, 2013
174− """ You can now customize the list of documentations.
175− New docs will be hidden by default, but you'll see a notification when there are new releases. """,
176− """ New <a href="/http/">HTTP</a> documentation """
177− ], [
178− 1373846400000, # July 15, 2013
179− """ URL search now works with single documentations: <a href="/#q=js%20sort">devdocs.io/#q=js sort</a> """
180− ], [
181− 1373673600000, # July 13, 2013
182− """ Added syntax highlighting """,
183− """ Added documentation versions """
184− ], [
185− 1373500800000, # July 11, 2013
186− """ New <a href="/underscore/">Underscore.js</a> documentation """,
187− """ Improved compatibility with tablets
188− A mobile version is planned as soon as other high priority features have been implemented. """
189− ], [
190− 1373414400000, # July 10, 2013
191− """ You can now search specific documentations.
192− Simply type the documentation's name and press <code class="_label">Tab</code>.
193− The name is fuzzy matched so you can use abbreviations like <code>js</code> for <code>JavaScript</code>. """
194− ], [
195− 1373241600000, # July 8, 2013
196− """ Improved search with fuzzy matching and better results
197− For example, searching <code>jqmka</code> now returns <code>jQuery.makeArray()</code>. """,
198− """ DevDocs finally has an icon. """,
199− """ <code class="_label">space</code> has replaced <code class="_label">alt + space</code> for scrolling down. """
200− ], [
201− 1373068800000, # July 6, 2013
202− """ New <a href="/dom/">DOM</a> and <a href="/dom_events/">DOM Events</a> documentations
203− DevDocs now includes almost all reference documents available on the Mozilla Developer Network.
204− Big thank you to Mozilla and all the people that contributed to MDN. """,
205− """ Implemented URL search: <a href="/#q=sort">devdocs.io/#q=sort</a> """
206− ], [
207− 1372723200000, # July 2, 2013
208− """ New <a href="/javascript/">JavaScript</a> documentation """
209− ], [
210− 1372377600000, # June 28, 2013
211− """ DevDocs made the front page of Hacker News!
212− Hi everyone &mdash; thanks for trying DevDocs.
213− Please bear with me while I fix bugs and scramble to add more docs.
214− This is only v1. There's a lot more to come. """
215− ], [
216− 1371513600000, # June 18, 2013
217− """ Initial release """
218− ]
219−]
assets/javascripts/templates/pages/news_tmpl.coffee.erb+37−0
@@ -0,0 +1,37 @@
1+#= depend_on news.json
2+
3+app.templates.newsPage = ->
4+ """ <h1 class="_lined-heading">Changelog</h1>
5+ <p class="_note">For the latest news,
6+ subscribe to the <a href="http://eepurl.com/HnLUz">newsletter</a>
7+ or follow <a href="https://twitter.com/DevDocs">@DevDocs</a>.<br>
8+ For development updates, follow the project on <a href="https://github.com/Thibaut/devdocs">GitHub</a>.
9+ <div class="_news">#{app.templates.newsList app.news}</div> """
10+
11+app.templates.newsList = (news) ->
12+ year = new Date().getUTCFullYear()
13+ result = ''
14+
15+ for value in news
16+ date = new Date(value[0])
17+ if year isnt date.getUTCFullYear()
18+ year = date.getUTCFullYear()
19+ result += "<h4>#{year}</h4>"
20+ result += newsItem(date, value[1..])
21+
22+ result
23+
24+MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
25+
26+newsItem = (date, news) ->
27+ date = """<span class="_news-date">#{MONTHS[date.getUTCMonth()]} #{date.getUTCDate()}</span>"""
28+ result = ''
29+
30+ for text, i in news
31+ text = text.split "\n"
32+ title = """<span class="_news-title">#{text.shift()}</span>"""
33+ result += """<div class="_news-row">#{if i is 0 then date else ''} #{title} #{text.join '<br>'}</div>"""
34+
35+ result
36+
37+app.news = <%= App.news.to_json %>
assets/javascripts/views/misc/news.coffee+2−2
@@ -20,11 +20,11 @@ class app.views.News extends app.views.Notif · 19 unmodified lines
2020 return [] unless time = @getLastReadTime()
2121
2222 for news in app.news
23− break if news[0] <= time
23+ break if new Date(news[0]).getTime() <= time
2424 news
2525
2626 getLastNewsTime: ->
27− app.news[0][0]
27+ new Date(app.news[0][0]).getTime()
2828
2929 getLastReadTime: ->
3030 app.store.get 'news'
lib/app.rb+3−0
@@ -26,6 +26,9 @@ class App < Sinatra::Application · 25 unmodified lines
2626 set :docs_manifest_path, -> { File.join(docs_path, 'docs.json') }
2727 set :docs, -> { Hash[JSON.parse(File.read(docs_manifest_path)).map! { |doc| [doc['slug'], doc] }] }
2828
29+ set :news_path, -> { File.join(root, assets_prefix, 'javascripts', 'news.json') }
30+ set :news, -> { JSON.parse(File.read(news_path)) }
31+
2932 Dir[docs_path, root.join(assets_prefix, '*/')].each do |path|
3033 sprockets.append_path(path)
3134 end