Todoist Plugin for Ubiquity
A plugin for Ubiquity that makes it easy to add todo items to your Todoist.com account. There are some hacks and it’s not the friendliest thing to use, but in the end you’ll be able to type todo mail electric bill and “mail electric bill” will be added to whatever you’ve specified as your default project.
Update (2008/09/03):
todo-token- Use this for the time being to set your web services token. You can find this in your preferences on Todoist.com under the ‘Account’ tab.todo-project- Use this to set the project id to use when adding an entry. You can find this by viewing a project on Todoist and looking at the URL. For example in this url:http://todoist.com/#project/123456the project id is123456.
In the future I hope to have these things set via modifiers, eg todo token <token> and todo project <project id>. I’d also like to add the ability to set priority and due date, but that’s down the road.
You can download the source here, I have also included it here:
TODOIST_DUE = "tomorrow";
TODOIST_PRIORITY = 4;
Todoist = {
setToken:function(key){
if (!Application.prefs.has("todoist_token")) {
Application.prefs.setValue("todoist_token", key);
} else {
var new_key = Application.prefs.get("todoist_token");
new_key.value = key;
return new_key.value;
}
},
setDefaultProject:function(key){
if (!Application.prefs.has("todoist_default_project")) {
Application.prefs.setValue("todoist_default_project", key);
} else {
Application.prefs.setValue("todoist_default_project", key);
}
},
getDefaultProject:function(){
return Application.prefs.get("todoist_default_project").value;
},
getToken:function(){
return Application.prefs.get("todoist_token").value;
},
everythingIsOK:function(){
return Application.prefs.has("todoist_token") && Application.prefs.has("todoist_default_project");
}
};
CmdUtils.CreateCommand({
name: "todo",
icon: "http://todoist.com/favicon.ico",
takes: {entry: noun_arb_text},
homepage: "http://www.baltimoresquirrels.com/projects/todoist-plugin-for-ubiquity/",
author: {
name: "Tom von Schwerdtner",
homepage: "http://baltimoresquirrels.com/"
},
license: "MPL",
preview: function(previewBlock, inputText) {
if (!Todoist.everythingIsOK()){
previewBlock.innerHTML = "Something is wrong...";
} else {
var previewTemplate = "Add entry to Todoist: <br />" +
"<strong>${entry}</strong>";
var previewData = {
entry: inputText.text
};
var previewHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
//previewBlock.innerHTML = previewHTML;
previewBlock.innerHtml = Todoist.getDefaultProject();
}
},
execute: function(inputText) {
if(inputText.text.length < 1) {
displayMessage("Don't have anything to do eh? Great!");
return;
}
var addItemUrl = "http://todoist.com/API/addItem";
var itemParams = {
token: Todoist.getToken(),
project_id: Todoist.getDefaultProject(),
content: inputText.text,
date_string: TODOIST_DUE,
priority: TODOIST_PRIORITY
};
res = jQuery.ajax({
type: "POST",
url: addItemUrl,
data: itemParams,
dataType: "json",
error: function() {
displayMessage("Todoist error - entry not added");
},
success: function() {
displayMessage("Todoist entry added");
}
});
}
});
CmdUtils.CreateCommand({
name: "todo-token",
takes: {token: noun_arb_text},
icon: "http://todoist.com/favicon.ico",
homepage: "http://www.baltimoresquirrels.com/projects/todoist-plugin-for-ubiquity/",
author: {
name: "Tom von Schwerdtner",
homepage: "http://baltimoresquirrels.com/"
},
license: "MPL",
description: "Set your Todoist API token. Check your web servies token at http://todoist.com",
help: "Type todo-setup <token>. Find your token in your account preferences under the 'Account' tab.",
execute: function(token) {
if(token.length < 1) {
displayMessage("Please, enter your web services token");
return;
}
Todoist.setToken(token.text);
displayMessage("Your token has been set.");
}
});
CmdUtils.CreateCommand({
name: "todo-project",
takes: {project: noun_arb_text},
homepage: "http://www.baltimoresquirrels.com/projects/todoist-plugin-for-ubiquity/",
icon: "http://todoist.com/favicon.ico",
author: {
name: "Tom von Schwerdtner",
homepage: "http://baltimoresquirrels.com/"
},
license: "MPL",
description: "Set the default project for todo entries.",
help: "Type todo-project <project id>. You can find a project id by looking at the URL of a project when viewing it..",
execute: function(project) {
if(project.length < 1) {
displayMessage("Please, enter a project id");
return;
}
Todoist.setDefaultProject(project.text);
displayMessage("Your default project has been set.");
}
});
You are the best ever! Thank you!!!!!!!!
xoxo
S
Sharona
2 Sep 08 at 12:17 pm
[...] plugin for Ubiquity (which I mentioned previously) that allows you to interface with Todoist. At the moment you have to [...]
Baltimore Squirrels » Blog Archive » Todays projects
6 Sep 08 at 11:20 am
ubiquitous says ‘an exception occurred while loading code.syntaxerror: missing } after property list’ after adding the code.
garrth
3 Nov 08 at 5:19 pm
@gareth: Did you copy and paste the code above into the ubiquity command editor or did you subscribe to the command on this page via the blue bar?
Tom
4 Nov 08 at 1:14 pm
Awesome.
Assuming you’re still working on this (and I hope you are, because it’s great), could you perhaps set the default date_string to null? The default for the web app itself is to leave the date blank unless you specify otherwise, and I think that’s the way it ought to be. (”Tomorrow” is kind of arbitrary and would have to be changed most of the time for most items. :))
Anyway, keep up the great work!
Ben
5 Dec 08 at 3:29 pm