mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-15 08:22:17 +00:00
add task export functionality
This commit is contained in:
parent
16140089b0
commit
b1b478bc74
5 changed files with 75 additions and 0 deletions
|
|
@ -31,6 +31,13 @@
|
|||
"qrCode": "QR Code",
|
||||
"dataExport": "Data Export",
|
||||
"saveData": "Here are a few options for saving your Habit data.",
|
||||
"taskLists": "Task Lists",
|
||||
"taskData": "You can export lists of your current tasks (useful for sharing many items with another person)",
|
||||
"exportHabits": "Export Habits",
|
||||
"exportDailies": "Export Dailies",
|
||||
"exportToDos": "Export To-Dos",
|
||||
"exportRewards": "Export Rewards",
|
||||
"exportAllTasks": "Export All",
|
||||
"habitHistory": "Habit History",
|
||||
"exportHistory": "Export History:",
|
||||
"csv": "(CSV)",
|
||||
|
|
|
|||
|
|
@ -156,6 +156,10 @@ for $stage in $stages
|
|||
width: 20%
|
||||
span
|
||||
font-size: 0.8em
|
||||
.help-block a
|
||||
border: 0
|
||||
float: right
|
||||
font-size: 0.85em
|
||||
|
||||
// an individual task entry
|
||||
// ------------------------
|
||||
|
|
|
|||
|
|
@ -22,6 +22,48 @@ var request = require('request');
|
|||
------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
function buildTaskList(list) {
|
||||
var output = [];
|
||||
_.each(list, function(task) {
|
||||
output.push(task);
|
||||
});
|
||||
return output;
|
||||
}
|
||||
|
||||
dataexport.habits = function(req, res) {
|
||||
return res.jsonstring({
|
||||
'habits': buildTaskList(res.locals.user.habits)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.dailies = function(req, res) {
|
||||
return res.jsonstring({
|
||||
'dailies': buildTaskList(res.locals.user.dailys)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.todos = function(req, res) {
|
||||
return res.jsonstring({
|
||||
'todos': buildTaskList(res.locals.user.todos)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.rewards = function(req, res) {
|
||||
return res.jsonstring({
|
||||
'rewards': buildTaskList(res.locals.user.rewards)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.tasks = function(req, res) {
|
||||
var user = res.locals.user;
|
||||
return res.jsonstring({
|
||||
'habits': buildTaskList(user.habits),
|
||||
'dailies': buildTaskList(user.dailys),
|
||||
'todos': buildTaskList(user.todos),
|
||||
'rewards': buildTaskList(user.rewards)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.history = function(req, res) {
|
||||
var user = res.locals.user;
|
||||
var output = [
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ var i18n = require('../i18n');
|
|||
var middleware = require('../middleware.js');
|
||||
|
||||
/* Data export */
|
||||
router.get('/habits.json',auth.authWithSession,i18n.getUserLanguage,dataexport.habits); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/dailies.json',auth.authWithSession,i18n.getUserLanguage,dataexport.dailies); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/todos.json',auth.authWithSession,i18n.getUserLanguage,dataexport.todos); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/tasks.json',auth.authWithSession,i18n.getUserLanguage,dataexport.tasks); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/rewards.json',auth.authWithSession,i18n.getUserLanguage,dataexport.rewards); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/history.csv',auth.authWithSession,i18n.getUserLanguage,dataexport.history); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/userdata.xml',auth.authWithSession,i18n.getUserLanguage,dataexport.leanuser,dataexport.userdata.xml);
|
||||
router.get('/userdata.json',auth.authWithSession,i18n.getUserLanguage,dataexport.leanuser,dataexport.userdata.json);
|
||||
|
|
|
|||
|
|
@ -228,6 +228,23 @@ script(id='partials/options.settings.export.html', type="text/ng-template")
|
|||
.col-md-6
|
||||
h2=env.t('dataExport')
|
||||
small=env.t('saveData')
|
||||
h4=env.t('taskLists')
|
||||
small=env.t('taskData')
|
||||
p
|
||||
=env.t('exportHabits')
|
||||
a(href="/export/habits.json")= ' ' + env.t('json')
|
||||
p
|
||||
=env.t('exportDailies')
|
||||
a(href="/export/dailies.json")= ' ' + env.t('json')
|
||||
p
|
||||
=env.t('exportToDos')
|
||||
a(href="/export/todos.json")= ' ' + env.t('json')
|
||||
p
|
||||
=env.t('exportRewards')
|
||||
a(href="/export/rewards.json")= ' ' + env.t('json')
|
||||
p
|
||||
=env.t('exportAllTasks')
|
||||
a(href="/export/tasks.json")= ' ' + env.t('json')
|
||||
h4=env.t('habitHistory')
|
||||
=env.t('exportHistory')
|
||||
a(href="/export/history.csv")= ' ' + env.t('csv')
|
||||
|
|
|
|||
Loading…
Reference in a new issue