Add 'Updates' notification

Ref #25.
pull/308/merge
Thibaut Courouble 9 years ago
parent 41dd8deceb
commit d20156e1f1

@ -133,6 +133,7 @@
@settings.set 'count', ++visitCount
new app.views.Notif 'Share', autoHide: null if visitCount is 5
new app.views.News()
new app.views.Updates()
@updateChecker = new app.UpdateChecker()
reload: ->

@ -26,6 +26,15 @@ app.templates.notifInvalidLocation = ->
app.templates.notifNews = (news) ->
notif 'Changelog', """<div class="_notif-content _notif-news">#{app.templates.newsList(news, years: false)}</div>"""
app.templates.notifUpdates = (docs) ->
html = """<ul class="_notif-content _notif-list">"""
for doc in docs
html += "<li>#{doc.name}"
html += " (#{doc.release})" if doc.release
html += "</li>"
html += "</ul>"
notif 'Updates', html
app.templates.notifShare = ->
textNotif """ Hi there! """,
""" Like DevDocs? Help us reach more developers by sharing the link with your friends, on

@ -0,0 +1,25 @@
#= require views/misc/notif
class app.views.Updates extends app.views.Notif
@className += ' _notif-news'
init: ->
@updatedDocs = @getUpdatedDocs()
@show() if @updatedDocs.length
@markAllAsRead()
return
render: ->
@html app.templates.notifUpdates(@updatedDocs)
return
getUpdatedDocs: ->
return [] unless time = @getLastUpdateTime()
doc for doc in app.docs.all() when doc.mtime > time
getLastUpdateTime: ->
app.settings.get 'version'
markAllAsRead: ->
app.settings.set 'version', if app.config.env is 'production' then app.config.version else Math.floor(Date.now() / 1000)
return

@ -114,7 +114,6 @@
}
._notif-list {
margin: .5em 0;
padding-left: 1rem;
}

Loading…
Cancel
Save