A Weird Imagination

Simple remote view of todo.txt

The problem#

A few months ago, I wrote about using todo.txt to keep track of household tasks. The key word there being "household": many of the tasks I'm tracking are not performed on a computer. I mentioned this issue in the post, that I wanted to look into some way to view those tasks not from my computer.

The solution#

I wrote todotxt-to-html, a very simple script that takes a todo.txt file (with thresholds and due dates as supported by Sleek) and outputs it as HTML. Since Sleek auto-saves on every change to the file, using a script like my compile on save script, it regenerates the HTML file to keep it always up-to-date:

watch_todo.sh /path/to/todo.txt /path/to/webdir/

Also copy or link todo.css into /path/to/webdir/. Use nginx or some other web server to make /path/to/webdir/ available on your local network and then share the link to your smartphone or whatever other device you want to view your TODO list on.

The details#

Why not an app?#

Mostly, I just wanted to do the simplest possible thing. That is, this is a minimum viable product.

An app has the complexity of setting up syncing the todo.txt file to/from the phone. I was already using Syncthing to do that between computers, and there do appear to exist Android and iOS apps for it, so it's probably possible, but would require non-trivial effort to set up syncing on each individual device. Which is much more work than just bookmarking a URL. Additionally, I make a lot of use of the "threshold" concept in Sleek and I'm sure which other apps support it.

There's the obvious downside to my approach that it doesn't support modifying the TODO list in any way, including checking off tasks. While it does make the implementation much simpler, I may want to rethink this in the future. On the upside, it avoids needing to worry too much about security (e.g., accidentally letting guests on my local network access the web site and modify the list) or interface complexities like needing to be able to undo accidentally checking off an item due to precise taps being difficult on a small phone screen.

Implementation#

As a standard format, there's multiple todo.txt parsers in multiple languages. I chose pytodotxt as I generally prefer Python for simple scripting tasks like this. For generating the HTML, I found Airium, which is a library which supports writing natural Python code to generate HTML documents.

The only complication I ran into is that pytodotxt does not have explicit support for the due date or threshold date attributes separate from any arbitrarily named attributes, but that was easily solved by writing a small helper:

def get_date_attribute(t, a):
    if a in t.attributes:
        return date.fromisoformat(t.attributes[a][0])
    return None

Then get_date_attribute(t, 'due') and get_date_attribute(t, 't') give the due date and threshold date (or None if not present).

Styling#

I would like to make the TODO display look as much like Sleek as possible, but pytodotxt's parsing does not provide enough information to separate out each section of each TODO item so it can be styled differently. Sleek uses jsTodoTxt to parse todo.txt files, so I may switch languages to JavaScript/TypeScript in order to be able to use that library instead.

Web hosting#

I already had a local nginx server running. I set the directory I put the output files in to only be accessible to my own devices on my local network (and also set it to allow the .html to be omitted):

location /todo {
    try_files $uri $uri/ $uri.html =404;

    allow 127.0.0.0/8;   # localhost
    allow ::1;           # localhost
    allow 192.168.0.123; # other IPs to allow
    deny all;
}

Comments

Have something to add? Post a comment by sending an email to comments@aweirdimagination.net. You may use Markdown for formatting.

There are no comments yet.