Image

I have a terrible memory, which means that I rely on a lot of tools and methodologies (like GTD, Getting Things Done) to help me track things. This also means that I have a lot of different tools ,and I regularly re-evaluate and change them if something new can meet my ever-changing needs.

For the last two years I’ve been using Quiver to categorize and keep notes. These are notes for myself of people, projects, interesting things, escalations, etc. These are also notes on nearly every meeting I attend. For obvious reasons, these are sensitive and need to be kept under my own control. Prior to Quiver, I was using EagleFiler (incidentally, I still use EagleFiler, just not for note keeping — it’s a great way to organize and collect files).

While Quiver worked quite well, it has limitations. As I try to do more work from my iPad rather than my laptop, the companion Quiver iOS app was showing it’s limitations. I could share the notes via my own internal WebDAV server, but it was read-only. That is great if I only want a reference, but to fully move to my iPad for the “normal day to day” stuff I needed something where I could review and edit notes.

I recently came across Inkdrop which is a note-taking application similar to Quiver with a more robust set of features, including iOS applications that will edit, and a better way of synchronizing those notes. While Inkdrop does provide a server to store the data (which is no good for me since I want to retain full control of my data), it does allow you to use a local CouchDB server. It also has a subscription of $5/mo which, if it can do what I need it to do, is worth it to me (particularly with the travel I’ve been doing of late).

The big things for me were standing up a CouchDB server (never played with it before) and being able to convert my Quiver library into a format that Inkdrop can use. Fortunately, both Quiver and Inkdrop use JSON files for the metadata so with a little bit of elbow grease I figured I could make it work. This post covers a few things: standing up the CouchDB server, getting Inkdrop to sync to it, and finally converting the data I already had in Quiver (nearly 1800 notes).

CouchDB in a FreeNAS jail

The first step was to create the FreeNAS jail in which I was going to run CouchDB. This needed to be running on my local network and not accessible to the internet. It also needed to use HTTPS. The first step was to create a new jail named inkdrop in FreeNAS (using the web UI). Once that was done, I logged into the FreeNAS server, entered the jail, and installed the pkg tool to install what I needed for CouchDB:

$ sudo iocage console inkdrop
# pkg
# pkg install couchdb2 curl
# cd /usr/local/etc/couchdb2
# vi local.ini

At this point we need to assign the admin user a password and note it in the local.ini file. There are other files to edit as well:

# vi vm.args

In vm.args, change the setcookie option from its default.

# vi /etc/rc.conf

In rc.conf set coudchdb2_enable to YES. Now we can start the service and initialize our database. The database will be named inkdrop and the admin user’s password is passwd in the following examples.

# service couchdb2 start
# curl -X PUT http://admin:[email protected]:5984/_users
# curl -X PUT http://admin:[email protected]:5984/_replicator
# curl -X PUT http://admin:[email protected]:5984/_global_changes
# curl -X PUT http://admin:[email protected]:5984/inkdrop

Install nginx as the CouchDB proxy

The next step is to use nginx as the proxy for CouchDB so that we can have HTTPS requests rather than HTTP.

# pkg install nginx
# cd /usr/local/etc/nginx
# vi nginx.conf

At this point you want to follow the Inkdrop instructions for setting up your own sync server. That should get nginx nicely configured. The next step is to use Let’s Encrypt in the FreeNAS jail. I’ve blogged about this in the past here, with Using LetsEncrypt on FreeNAS and Using LetsEncrypt with Plex so I won’t go into a lot of detail, but will simply note the commands used:

# pkg install git
# cd /root
# git clone https://github.com/Neilpang/acme.sh.git
# cd acme.sh
# ./acme.sh --install
# cd /root/.acme.sh
# export CF_Key="api_key"
# export CF_Email="email_addr"
# ./acme.sh --issue --dns dns_cf -d inkdrop.hostname --fullchain-file /usr/local/etc/nginx/fullchain.pem --key-file /usr/local/etc/nginx/privkey.pem
# crontab -l
12 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null

With our SSL certificate setup and making sure the cronjob is set as well, we can now start nginx and test if we can connect to our CouchDB server over HTTPS:

# vi /etc/rc.conf
# service nginx start
# curl -X GET https://127.0.0.1:6984/_all_dbs
{"error":"unauthorized","reason":"You are not a server admin."}
# curl -X GET https://admin:[email protected]:6984/_all_dbs
["_global_changes","_replicator","_users","inkdrop"]

In rc.conf you want to set nginx_enable to YES.

If you intend to use Inkdrop on your mobile device, you now need to create the mobile design document as per Inkdrop’s mobile sync documentation, which is effectively running:

# curl -X PUT https://admin:[email protected]:6984/inkdrop -d '{ "_id": "_design/mobile", "filters": { "sync": "function (doc) { return doc._id.indexOf('file:') === -1 }" } }'

Mobile Sync

At this point you should have a fully functional CouchDB running behind nginx in a FreeNAS jail. Now you can point Inkdrop to your server for syncing. You can set this up to be accessible from anywhere, or you can leave it accessible only internally. That’s the way I chose to do it since you can edit documents while disconnected and it will sync back to the server when the client is able to connect. This allows for complete privacy by not making it available outside of your own network, but makes it portable enough that you can take your notes with you so you can add and edit as you’re out and about.

The only thing that would make this even better for me would be for Inkdrop to have PIN or TouchID/FaceID protection on the mobile device.

Converting from Quiver to Inkdrop

Now if you’re like me and you’ve used Quiver in the past, there is good news! You can convert from Quiver to Inkdrop. I had to scratch my own itch here as there was no conversion tool available. Thankfully, Quiver uses JSON files that can be parsed and, for Inkdrop, I can talk directly to the CouchDB server. Because of this I could see the content/format of what I had in Quiver, and what Inkdrop expected in CouchDB. It wasn’t terribly difficult to figure out, just took a bit of trial and error.

My script for the conversion is available on GitHub: quiver-to-inkdrop.

This was a nice amusement for me, to be honest. I always enjoy playing with new software, something I don’t get to do as often as I used to (when I wrote for TechRepublic years ago I was playing with new things all the time). Everything here aside from FreeNAS was new for me and I’d never played with CouchDB before, and I always enjoy doing a bit of Python and hacking things to make them work. Hopefully there is something interesting or useful here for others to use as well!

Share on: TwitterLinkedIn


Related Posts


Published

Category

Macos

Tags

Stay in touch