#= depend_on news.json
app.templates.newsPage = ->
"""
Changelog
For the latest news, follow @DevDocs.
For development updates, follow the project on GitHub.
#{app.templates.newsList app.news}
"""
app.templates.newsList = (news, options = {}) ->
year = new Date().getUTCFullYear()
result = ''
for value in news
date = new Date(value[0])
if options.years isnt false and 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 %>