Skip to content

Instantly share code, notes, and snippets.

@nelsonpecora
Last active December 20, 2015 08:59
Show Gist options
  • Select an option

  • Save nelsonpecora/6104196 to your computer and use it in GitHub Desktop.

Select an option

Save nelsonpecora/6104196 to your computer and use it in GitHub Desktop.
Sample code to grab to do items from the "Today" list, with Area / Project labels
set taskList to "["
tell application "Things"
repeat with toDo in to dos of list "Today"
set tdName to the name of toDo
set tdStatus to the status of toDo
if (project of toDo) is not missing value then
set tdSection to (name of project of toDo)
set tdSectionType to "project"
else if (area of toDo) is not missing value then
set tdSection to (name of area of toDo)
set tdSectionType to "area"
else
set tdSection to "null"
set tdSectionType to "null"
end if
set tdRecord to "{\"name\":\"" & tdName & "\", \"status\":\"" & tdStatus & "\", \"section\":\"" & tdSection & "\", \"sectiontype\":\"" & tdSectionType & "\"},"
set taskList to taskList & tdRecord
end repeat
set taskList to text 1 thru -2 of taskList
set taskList to taskList & "]"
log taskList
end tell
set taskList to the quoted form of taskList
do shell script "curl -d " & taskList & " http://localhost:8000/upload"
@nelsonpecora
Copy link
Author

With this, I believe I should just be sending POST requests with name: tdName and section: tdSection. I can parse them on the server and send them to Little Printer with proper section dividers. As per the Things App, tasks are grouped by Project (if it exists), then Area (if it exists), though I'll probably take the tasks without these and put them at the top of my displayed list (like it works in the desktop/iOS apps).

@nelsonpecora
Copy link
Author

Updated. Here's the code I get from Node.js:

{ name: 'test task without a section', section: 'null' }
{ name: 'Little Things', section: 'BERG Little Printer' }  //project
{ name: 'DH: Upgrade DAC camps and APC package', section: 'Shacktac' }  //area
{ name: 'DH: Improvements to Platoon Roster', section: 'Shacktac' }
{ name: 'Get dashboard into git', section: 'Work' }  //area
{ name: 'Consumer Signup', section: 'Work' }

It works!

@nelsonpecora
Copy link
Author

Updated with completion status.

@nelsonpecora
Copy link
Author

Updated, now with section type. Now you can loop through each task in null, projects, and areas, and display them in that order.

I'm working on a little node.js/mongodb app that I'll link to when it's ready, so you can see what I mean.

@nelsonpecora
Copy link
Author

Updated again. Now it concatenates everything into a single JSON string and POSTs it to the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment