mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-15 16:32:16 +00:00
got ical to send downloadable icsf files
This commit is contained in:
parent
6cffdfd1e8
commit
10a8ad551f
3 changed files with 14 additions and 12 deletions
|
|
@ -21,7 +21,8 @@
|
|||
"coffee-script": "*",
|
||||
"underscore": "*",
|
||||
"mongoskin": "*",
|
||||
"nconf": "*"
|
||||
"nconf": "*",
|
||||
"icalendar": "*"
|
||||
},
|
||||
"private": true,
|
||||
"subdomain": "habitrpg",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
scoring = require('../app/scoring')
|
||||
_ = require('underscore')
|
||||
icalendar = require('icalendar')
|
||||
|
||||
module.exports = (expressApp, root, derby) ->
|
||||
|
||||
|
|
@ -13,26 +14,26 @@ module.exports = (expressApp, root, derby) ->
|
|||
staticPages.render 'terms', res
|
||||
|
||||
# localhost:3000/users/9/tasks.ics?apiToken=ae164366-f1ad-4a7d-83ef-b1d1085a96b6
|
||||
expressApp.get '/users/:uid/tasks.ics', (req, res, next) ->
|
||||
expressApp.get '/users/:uid/tasks.ics', (req, res) ->
|
||||
{uid} = req.params
|
||||
{apiToken} = req.query
|
||||
|
||||
model = req.getModel()
|
||||
query = model.query('users').withIdAndToken(uid, apiToken)
|
||||
query.fetch (err, result) ->
|
||||
return next(err) if err
|
||||
userObj = result.at(0).get()
|
||||
tasksWithDates = _.filter userObj.tasks, (task) -> !!task.date
|
||||
console.log("DATES LOLOL " + tasksWithDates)
|
||||
throw err if err
|
||||
tasks = result.at(0).get('tasks')
|
||||
tasksWithDates = _.filter tasks, (task) -> !!task.date
|
||||
|
||||
ical = new icalendar.iCalendar()
|
||||
_.each tasksWithDates, (task) ->
|
||||
event = new icalendar.VEvent(task.id);
|
||||
event.setSummary(task.text);
|
||||
# event.setDate new Date(task.date), 60 * 60 # Duration in seconds
|
||||
event.setDate new Date(task.date), 60 * 60 # Duration in seconds
|
||||
ical.addComponent event
|
||||
event2 = ical.addComponent("VEVENT")
|
||||
event2.setSummary "Second test event"
|
||||
event2.setDate new Date(2011, 11, 5, 12, 0, 0), 60 * 60 # Duration in seconds
|
||||
res.send(200, ical.generateIcs())
|
||||
next()
|
||||
res.type('ics')
|
||||
res.send(200, ical.toString())
|
||||
|
||||
# ---------- Deprecated Paths ------------
|
||||
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@ do a find for the string after "→"
|
|||
{else if equal(:task.type, 'todo')}
|
||||
<div class=control-group>
|
||||
<label>Date</label>
|
||||
<input type="date" value={:task.date} />
|
||||
<input type="date" value="{:task.date}" />
|
||||
</div>
|
||||
{/}
|
||||
<button type=submit class="btn">Save & Close</button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue