Restart

July 21st, 2014

I hated the 2013 version of timpietrusky.com: Selfcrafted PHP "static files"-based system, which was controlled by one big array and different PHP files. So everytime I wanted to update the page, I had to edit the files and push them on the server. There was no backend UI, because I had no time to deal with that kind of shit, too.  

Don't get me wrong: It was great creating a CMS from scratch, but in the end it was just so time consuming. Just creating one article was a long and heavy process. A process I could not longer afford. 

After using Node.js / MongoDB to develop custom web applications (e.g. temper1-connector or Thunder Commander), I wanted to switch the system behind my own page too. That's why I decided to search for a nice CMS based on the knowledge I already had and the page of KeystoneJS was the best looking one... Winner found :D

KeystoneJS

Using KeystoneJS is pretty nice, because:

I never used Jade before and I always try to learn new stuff. So I started using and loving it. 

I only use SCSS so I added Gulp (which compiles all SCSS files into one CSS file) and removed every default CSS/JS file from the frontend. The only default CSS I use is Bullgrid

Bullgrid

A responsive grid framework based on the grid component of inuit.css and various contributions of other developers. You can find Bullgrid on GitHub

Structure

The focus of my new page lies on all the content I (& from others in the future) created for the web. That's why the startpage displays the content in "information blocks" and you can filter these blocks with the top navigation:

  • Audio: Music from SoundCloud for now
  • Code: Experiments, projects and everything with real code
  • Text: Only my articles for now
  • Video: Talk(s) I have given and videos I created

Server

Since this is my first Node.js application that I publish trough an URL, I can't you use Apache anymore, because the performance with mod_proxy is very bad. Hurray, that means I can finally use a Droplet (512MB / 1 CPU / 20GB SSD DISK) from DigitalOcean with pre-installed Ubuntu 14.04 x64 / node-v0.10.29 and do the final steps (thanks to this awesome tutorial from DigitalOcean):

  • Install nginx & forever & mongod
  • Configure nginx to recognise the page by creating a nginx site config (/etc/nginx/sites-available/timpietrusky.com): 
     # The port Keystone is running on (e.g. 3000)
    upstream app_yourdomain {  
        server 127.0.0.1:3000;
    }
    
    # The nginx server instance
    server {
        # Listen on port 80 -> default HTTP request
        listen 0.0.0.0:80;
    
        # The Domain(s)
        server_name timpietrusky.com www.timpietrusky.com;   
    
        # Logs
        access_log /var/log/nginx/timpietrusky.com_access.log;    
        error_log /var/log/nginx/timpietrusky.com_error.log;
    
        # Set correct headers and send the external request on port 80    
        # to the internal port of "app_yourdomain"
        location / {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X-NginX-Proxy true;
    
          proxy_pass http://app_yourdomain/;
          proxy_redirect off;
        }
     }
  • Enable the nginx site config by creating a symlink into the sites-enabled folder:
    ln -s /etc/nginx/sites-available/timpietrusky.com /etc/nginx/sites-enabled/
  • Copy the page to the server (/var/www/timpietrusky.com)
  • Copy a dump of your local mongodb to the server and restore it
    # Create the local backup
    mongodump --db <db_name> --out /path/to/backup/<backup_name>
    
    # Copy the backup to the server
    # ...
    
    # Restore your local backup on the server
    mongorestore --db <db_name> --drop /path/to/backup/on/server/<backup_name>/<db_name>
  • Start keystone using forever:
    cd /var/www/timpietrusky.com
    forever start keystone
  • Restart nginx:
    service nginx restart 

Feedback

This page depends on your awesome feedback. That's why you can find my page on GitHub and if you find any bugs or have nice ideas to improve it, please open an issue on GitHub or leave a comment.