Things is a popular task and project management app from Cultured Code. Things supports advanced URL schemes (required Things v3.4 or greater on iOS) which can accept multiple todos, projects, headings in a single call to the app. The scripting interfaces below are convenience wrappers that allow easy creation and encoding of the URLs needed to pass this type of information to Things.
The TJS* JavaScript objects are wrappers around an open source Swift library provided by Cultured Code, with a few modifications to work in JavaScript. In all cases, nothing is committed to Things until the the items are wrapped in a TJSContainer, and the URL it generates called to send the data to Things. This is best done with Drafts’ CallbackURL object (see example below).
// create a Things Projectvar project = TJSProject.create();
project.title = "My Project From Drafts";
project.notes = "Let's do this stuff";
// create and add a heading to the projectvar heading = TJSHeading.create();
heading.title = "First Heading";
project.addHeading(heading);
// add todos to the projectvar todo1 = TJSTodo.create();
todo1.title = "My first todo";
todo1.when = "today";
project.addTodo(todo1);
var todo2 = TJSTodo.create();
todo2.title = "My second todo";
todo2.when = "tomorrow";
project.addTodo(todo2);
// create a container to handle creation of Things URLvar container = TJSContainer.create([project]);
// Use CallbackURL object to open URL in Things.var cb = CallbackURL.create();
cb.baseURL = container.url;
var success = cb.open();
if (success) {
console.log("Project created in Things");
}
else {
context.fail();
}
TJSContainer
Wraps an array of todo and/or project items and encodes them into a URL for use to send the request to Things.
Things Integration Notes
The TJS* JavaScript objects are wrappers around an open source Swift library provided by Cultured Code, with a few modifications to work in JavaScript. In all cases, nothing is committed to Things until the the items are wrapped in a TJSContainer, and the URL it generates called to send the data to Things. This is best done with Drafts’
CallbackURL
object (see example below).For more information about what values Things understands in these objects, refer to their URL scheme documenation.
Example
// create a Things Project var project = TJSProject.create(); project.title = "My Project From Drafts"; project.notes = "Let's do this stuff"; // create and add a heading to the project var heading = TJSHeading.create(); heading.title = "First Heading"; project.addHeading(heading); // add todos to the project var todo1 = TJSTodo.create(); todo1.title = "My first todo"; todo1.when = "today"; project.addTodo(todo1); var todo2 = TJSTodo.create(); todo2.title = "My second todo"; todo2.when = "tomorrow"; project.addTodo(todo2); // create a container to handle creation of Things URL var container = TJSContainer.create([project]); // Use CallbackURL object to open URL in Things. var cb = CallbackURL.create(); cb.baseURL = container.url; var success = cb.open(); if (success) { console.log("Project created in Things"); } else { context.fail(); }