Skip to content

Instantly share code, notes, and snippets.

@melvincarvalho
Created February 27, 2015 11:24
Show Gist options
  • Select an option

  • Save melvincarvalho/5e3e9ba4a36ecb3fae17 to your computer and use it in GitHub Desktop.

Select an option

Save melvincarvalho/5e3e9ba4a36ecb3fae17 to your computer and use it in GitHub Desktop.
taskify data model
// items
if (!todo.items) todo.items = [];
for (var i=0; i<todo.items.length; i++) {
var id = todo.items[i].id.indexOf('http') ? '#' + todo.items[i].id : todo.items[i].id;
str += '\n'+ '<' + id + '> a <http://dig.csail.mit.edu/2010/issues/track#Task> .';
str += '\n'+ '<' + id + '> <http://purl.org/dc/terms/description> "'+ escape(todo.items[i].text) +'".';
str += '\n'+ '<' + id + '> <http://www.w3.org/2002/12/cal/ical#completed> '+ todo.items[i].complete +'.';
str += '\n'+ '<' + id + '> <https://taskify.org/ns/task#urgent> '+ todo.items[i].urgent +'.';
str += '\n'+ '<' + id + '> <https://taskify.org/ns/task#important> '+ todo.items[i].important +'.';
if (!todo.items[i].tags) todo.items[i].tags = [];
for (var j=0; j<todo.items[i].tags.length; j++) {
var obj = todo.items[i].tags[j].indexOf('http') ? '#' + todo.items[i].tags[j] : todo.items[i].tags[j];
str += '\n'+ '<' + id + '> <http://commontag.org/ns#tagged> <'+ obj +'>.';
}
}
// tags
if (!todo.tags) todo.tags = [];
for (var i=0; i<todo.tags.length; i++) {
var id = todo.tags[i].id.indexOf('http') ? '#' + todo.tags[i].id : todo.tags[i].id;
str += '\n'+ '<' + id + '> a <http://commontag.org/ns#Tag> .';
str += '\n'+ '<' + id + '> <http://commontag.org/ns#label> "'+ escape(todo.tags[i].name) +'".';
}
// columns
if (!todo.columns) todo.columns = [];
for (var i=0; i<todo.columns.length; i++) {
var id = todo.columns[i].id.indexOf('http') ? '#' + todo.columns[i].id : todo.columns[i].id;
str += '\n'+ '<' + id + '> a <https://taskify.org/ns/task#Column> .';
str += '\n'+ '<' + id + '> <https://taskify.org/ns/task#position> '+ i +' .';
str += '\n'+ '<' + id + '> <http://purl.org/dc/terms/description> "'+ escape(todo.columns[i].name) +'".';
if (!todo.columns[i].items) todo.columns[i].items = [];
for (var j=0; j<todo.columns[i].items.length; j++) {
var obj = todo.columns[i].items[j].indexOf('http') ? '#' + todo.columns[i].items[j] : todo.columns[i].items[j];
str += '\n'+ '<' + id + '> <https://taskify.org/ns/task#hasTask> <'+ obj +'>.';
}
}
}
// bookmarks
tasktree = localStorage.tasktree;
if (tasktree) tasktree = JSON.parse(tasktree);
if (tasktree) {
for (var i=0; i<tasktree.length; i++) {
str += '\n <'+ tasktree[i]['@id'] +'> a <http://www.w3.org/2005/01/wf/flow#tracker> ; <http://purl.org/dc/terms/modified> "'+ tasktree[i]['modified'] +'" . ';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment