Laverna: Keeping track of your notes in the cloud

25 August 2015 on OpenSource, Cloud, Self-Hosted, Notes, and Linux. 30 minutes Intermediate

The application stores all your notes in your browser local storage spaces such as indexedDB or localStorage, which is good for security reasons, because only you have access to them. Currently you can sync your notes to DropBox and Remote Storage. It’s also highly secure because all of the data is stored in your browser (unless you decide to use Cloud Sync). This is also a downside if you want to have your notes on every device you own. If that’s the case, you’ll need use Cloud Sync

Demo

Installation

To begin, we need a fresh Ubuntu 14.04 LTS Server. Mine will be using my AWS EC2 instance.

Now, lets add our Laverna user

useradd laverna -m -d /home/laverna -s /bin/bash

Next, we need to make sure that we have NodeJS, NPM, and GIT installed

apt-get install nodejs npm git

Because Ubuntu is sometimes strange, we need to SymLink our nodejs binary to node

ln -s /usr/bin/nodejs /usr/bin/nnode

After we have our basics completed, lets switch to the laverna user and goto our home directory

su laverna
cd ~

Lets clone the Laverna repo

git clone https://github.com/Laverna/laverna.git

Once cloned, enter the newly created directory

cd laverna

Checkout the current working production branch

git checkout 0.6.2

Use NPM to install bower, grunt, and grunt-cli

npm install bower
npm install grunt
npm install grunt-cli

Next, Alias bower and grunt for this session

alias bower="./node_modules/bower/bin/bower"
alias grunt="./node_modules/grunt-cli/bin/grunt"

Install Laverna’s dependencies

npm install && bower install

Build Laverna

grunt build

Now that we have Laverna built into static files, we need to create a Virtual Host in our Web Server. Here’s an example for NGINX

server  {
    listen  80;
    root /home/laverna/laverna/app;
    index index.html;
    server_name  notes.hudson.bz;
    error_log  /var/log/nginx/notes.hudson.bz-error.log warn;
    access_log  /var/log/nginx/notes.hudson.bz.com-access.log combined;
        location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
          access_log off;
          expires max;
        }
        location ~ /\.ht {
          deny  all;
        }
}

Finally, navigate to your site. Bonus Task

Add an SSL Certificate for even more security!

Example NGINX virtual host for SSL

server  {
    listen  80;
    root /home/laverna/laverna/app;
    index index.html;
    server_name  notes.hudson.bz;
    error_log  /var/log/nginx/notes.hudson.bz-error.log warn;
    access_log  /var/log/nginx/notes.hudson.bz.com-access.log combined;
        location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
          access_log off;
          expires max;
        }
        location ~ /\.ht {
          deny  all;
        }
}
server {
    listen 443;
    root /home/laverna/laverna/app;
    index index.html;
    server_name  notes.hudson.bz;
    ssl                   on;
    ssl_certificate       /home/laverna/ssl/certbundle.pem;
    ssl_certificate_key   /home/laverna/ssl/privkey.key;
    ssl_prefer_server_ciphers on;
    ssl_protocols         TLSv1;
    ssl_ciphers           ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
    error_log  /var/log/nginx/notes.hudson.bz-error.log warn;
    access_log  /var/log/nginx/notes.hudson.bz.com-access.log combined;
}

Enable Cloud Storage

Warning

You must use HTTPS for DropBox syncing

You can generate a self-signed certificate if you need to

Create a DropBox API Key here

When you create a new app at Dropbox’s Developer site you should keep in mind that:

1) Type of app should be Dropbox API app
2) Choose the type of access you need
  App folder – Access to a single folder created specifically for your app.
3)  Name
  Should be unique

Once created, we need to add a Redirect URI. Under OAuth2 Redirect URIs add the following https://mydomain.com/dropbox.html

Click Add

Now, Go to Laverna settings https://mydomain.com/index.html#/settings and find Cloud Storage. Click DropBox, and enter your API Key in the box below.

I recommend while you’re in settings, that you check the Use Encryption Box

Then click Save!

You’ll be prompted to Authorize the app. Once that’s done, you’ll return to your Laverna app and your notes will be synced! They are saved in ~/Dropbox/Apps/AppName

You now have an amazing note keeping app, that can be accessed anywhere


Previous

Mail In a Box: Keeping the NSA out of your base since 2013

Since before it was widely known that the internet wasn't as secure as we hoped, I've been one to run applications in my own environment instead of taking advantage of the commercialized products easily available. Sometimes it's simply for the sheer amount of control, and others it's because I don't want my Drunk Spending on Amazon to be tied to my email accounts. It's not always the best thing that Google and Amazon can now predict the exact days and times I'll be most inebriated and offer me 'Great deals'