LSBEngine

LSBEngine stands for Lovely Scala Blogging Engine. It is the software powering this website. It involves a simple Content Management System (CMS) that allows you to edit blog articles and publish them. You will find here a description of the version 1.0 of this software, its features and the technology stack involved.

Features

Last updated on version 1.1.1

Markdown blogging

The main feature of the software is to allow you to create edit blog posts, projects descriptions and a personal details page with markdown. It is both easy to implement and easy to learn to quickly generate nice blog posts. On top of this, you can organise your posts by categories that you handle your self from the administration interface. You can easily select a publication date for your posts, allowing you to schedule publications in the future so that you don't even need to be in front of your computer to release your articles at any point in time.
Finally, if you are so inclined, you can write explicit content and mark it as such. This will prevent the content from being displayed directly on the front page (which could offend the sensitivity of some people!). Instead, the nice family-friendly abstract (that you provide) will be displayed alongside a link to the full article.

RSS feeds

Not a lot to say here but the blog comes with two RSS feeds:

  • my.domain.me/feed/posts which is a feed of all the posts
  • my.domain.me/feed/projects which is a feed of all the projects

You can then have your readers to subscribe to your work and use those feeds in their favourite news reading application. Since version 1.1.1, the feeds only display the abstracts as rendering HTML in RSS viewers proved to be inconsistent.

Resume

If you configure the software properly (you can find the instructions on the repository's readme), you can have it serve your resume in PDF format from my.domain.me/feed/assets/firstname_lastname_resume.pdf.

Images hosting

[New in version 1.0.4] You can upload images directly on the server, they will be put on a folder of the file system of the host machine and indexed in the database. the key is the name of the file (without extension) and the image is then accessible at my.domain.me/assets/images/image_name.extension. In theory, it could work for non images but I provide no guarantee.

Posts Thumbnails

[New in version 1.0.5] Posts can now have thumbnails that will be propagated to the RSS feed. They can be selected from the collection of images you uploaded to the server (see previous section). If an image is selected as as thumbnail it can't be deleted.

Google Analytics

[New in version 1.0.6] You can configure your Google Analytics tracking ID to enable Google Analytics on the blog.

The future?

There are a few features I want to implement in the subsequent versions. I am not necessarily set on any of them, but here is a list of the ones I thought of, from most probable to least probable:

  • Sidebar with direct links to posts
  • Link previews: generate a preview for links in articles
  • Posts search

Technologies involved

Before you dig into this section, please note that beyond technical reasons to choose some technology, I also considered the fun I would have using the technology and how much I wanted to implement myself as the goal of this project was also to have fun!

The core: Scala and Akka-http

Scala (https://www.scala-lang.org) is a functional object-oriented programming language running on the Java Virtual Machine (JVM). It is fully compatible with Java (you can use any Java code you want in Scala) and therefore has access to the plethora of Java libraries. It is rather fast and makes use of all the power of the JVM which has proven to be an efficient tool for web applications.

Akka-http (https://doc.akka.io/docs/akka-http/current) is a framework designed for creating REST APIs based on the actor framework Akka. It was formerly known as Spray and is a powerful tool that has been used to create the Play framework which is geared towards creating full featured web applications.

The storage: MongoDB

MongoDB (https://www.mongodb.com) is a flexible NoSQL database system. The main reason it was chosen for this project is that it integrates very well with Scala through the ReactiveMongo (http://reactivemongo.org) library which makes use of the powerful reactive programming capabilites of Scala and allows for efficient synchronous operations which also happen to be at the core of Akka-http.

The frontend: JavaScript, Templating and Sass

The frontend has been thought to be as free of JavaScript as possible. The basis of all the frontend is the Twirl (https://www.playframework.com/documentation/2.6.x/ScalaTemplates) templating freamework. It has been developed for the Play framework and makes full use of Scala strong typing which allows strong guarantees on the consistency of the templates.

Being a blog, the public frontend does not need any complicated logic, in fact it includes little to no custom javascript and simply includes the following libraries:

  • highlight.js (https://highlightjs.org) : syntax highlighting for the web! Super useful to include code snippets in articles:
val isScalaAwesome: Boolean = true
  • JQuery: one of the oldest and most widespread JavaScript library, it is required for some of the manipulations highlight.js does.
  • Google Analytics, because I find it fun to see how many people visit my website

The admin frontend, on the other hand also includes some JavaScript to interact with the server. It also includes one other library: ShowDown (http://showdownjs.com ), a Markdown to HTML converter. Having this included in the frontend allows to easily generate preview without going to the server.

Finally, all of this would be much more ugly without CSS. I chose to go for the flexibility and and power of Sass (https://sass-lang.com) and tried my best to make this as beautiful as a backend engineer could.

Reverse proxy and SSL: NginX and Let's Encrypt

Reverse proxies have a lot of convenient features, and I used NginX (https://www.nginx.com) for the two main following features:

  • Serving static files
  • Handling SSL

Since Let's Encrypt (https://letsencrypt.org) launched in 2016, it has become possible for nearly anybody to have a secured connection for their website. It is so convenient I could not see how I would do without it.

Deployment: Docker

Docker (https://www.docker.com) is a container system based on LXC (https://linuxcontainers.org/lxc/introduction ). The main use of it in this project is to ensure the software runs on the same environment no matter on which machine it runs. Coupled with Docker Compose (https://docs.docker.com/compose) and Docker Machine (https://docs.docker.com/machine) it is an elegant way to build and run software on your production machine.
Bonus point: the Scala Build Tool (SBT) has a plugin that allows the build of lightweight docker images for your Scala application.