Todo.txt Chrome App/Extension Postmortem-like thingProblem
: I use Todo.txt all the time to help me get things done but I wanted to use it from Chrome OS.Solution
: Make my own Chrome app for Todo.txt.
Instead of going a Wunderlist type of presentation, I decided to stay true to the original Todo.txt CLI version and create an emulated terminal(adapted example from HTML5Rocks). Besides modals to confirm deletion of tasks and select files, everything can done on the command line.
You can check out the code here: https://github.com/jwill/todotxt-chrome
- Basic file syncing using filepicker.io
- Add tasks
- Remove tasks
- Mark As Completed
- List tasks
- Limited search capabilities
- Lately plugin
Screenshots of app attached.
Security policy stuff
Sorting of tasks by priority
Full text search
Apply color to prioritized tasks
Implementing other core commands (p, depri, etc)Technical Details:
I started shortly after I bought a new ARM Samsung Chromebook in December 2012 and it was originally planned as a Chrome packaged app. The new Chrome Packaged App spec supports OAuth2.0 fairly well but OAuth 1.0a isn’t so fun. The official Todo.txt clients use Dropbox for file storage. Unfortunately, it uses OAuth 1.0.
I was eventually about to get file download working but none of the js OAuth wanted to work with file upload. Next, I decided to test out filepicker.io
as its marketing says it’s easier to integrate.
Running the filepicker script in a sandboxed page allowed me to progress a little further but still failed due to CSP. Extensions don’t have that restriction so I decided to temporarily change it to a Chrome extension that surfaces a new tab. Luckily, I wasn’t using any app-specific APIs besides chrome.runtime as an entry-point so moving it to an extension was just a matter of designating a browserAction and swapping out a couple lines of code.Filepicker.io
Once the CSP issues were settled, it was a breeze to setup Filepicker.io. When you select a file to use with your app, filepicker.io
uploads it to S3 and creates a URL for it. Any writes to that file will generally propagate back to the original source. So if I decided to move my todo files to Google Drive, I would need new URLs but I could use the same API calls.
The URLs that filepicker.io
generates are public. They seem to be reasonably randomized but if I were doing a production app, I’d make sure I set up some security policies (which filepicker.io
does support) to prevent unauthorized access. It should be noted that Dropbox is well supported in the extension space.Yeoman
Yeoman was helpful in generating JS from all the CoffeeScript code and the server command that could watch for changes was clutch.
Looking back, I'm glad that I kept the Chrome Packaged App features siloed so that it was easy to port to an extension. Once Dropbox gets their act together, I can make it a full packaged app again.