Grav CMS – The future of flat file CMS

Standard

Grav is an open source Flat-File CMS written in PHP developed by RocketTheme. When we say Flat-File CMS it means that the Content Management System doesn’t rely on a Database to serve content, instead, it stores content in files that can be a text file or a markdown file depending on what kind of content it is handling or what kind of CMS it is. Flat-File CMS are useful with your I/O for file handling is faster than a Database response or when you don’t have enough resource to power a Database. It is also useful if a specific Database type costs money, Flat-File CMS at times can cost cheaper then a Database driven CMS. There are many Flat-File CMS out there like Statamic, Kirby, PhileCMS and many other. To know what makes Grav a better choice stay tuned.

Grav is one of the fastest flat-file CMS with a cleaner code base that follows the PSR standards. Grav uses YAML that uses the <code class="highlighter-rouge">.yaml extension to store system and other various configuration. It uses Markdown files with the <code class="highlighter-rouge">.md extension to store content the Markdown files are parsed by Parsedown one of the best PHP based Markdown parser. Grav uses Twig for templating that is one of the most popular PHP-based templating engines. It is also a better templating engine compared to other templating engines because Twig is parsed directly into PHP that makes it really fast.

The benefit of using Twig for templating is that the user does not require knowledge of PHP and can directly read the documentation and start developing themes for it. This is one of the reasons why I love Grav.

Grav has it’s own package manager named GPM was also known as Grav Package Manager that lets the user install/uninstall/update 3rd party plugins and themes. It is also the at the very core of Grav that lets the user update this Grav install on every new update. The GPM package manager makes Grav, even more, user-friendly. Grav also comes with other CLI tools like grav it is similar to GPM. Grav grav CLI lets the user purge cache and manage much other various stuff.

Even after Grav being in the development stage turns out to be very stable. Grav developers are working on an Admin Panel plugin that lets the user have a really nice looking GUI to work with Grav. The Admin panel is currently not yet available it would be available in version 1.0.1, you can find the screenshots over here. Grav is being developed on GitHub.

Grav lets the user create skeletons some skeletons are already available here.

For a developer, Grav has a lot of user in areas where one would prefer file based system or lack resource to have a Database at the same time not lack functionality for this reason. Grav plugins are written in PHP and let 3rd part developers add more functionality to Grav. Grav lets theme developers file written in PHP named after the theme name that can make a connection with plugins or have it’s own unique functionality. Grav lets the theme have its own YML configuration file with a .yaml an extension that lets the theme developer add this/her own configuration with having to mess with the CMS core configuration files.

Grav being a Flat-File CMS also lets the user manage it using version control and sync based system, as the whole system just files. Version Controlling a CMS can be a very good idea at times as it lets the user have a track record of every change made and lets the user revert back to an older build. This can be better achieved on a Flat-File CMS, because If a Database driven CMS is version control like an SQLite driven CMS then only the binary change can be visible and file size as this does not show the big changes made to the system and makes the SQLite driven CMS a much unfriendly option for version control users.

In my opinion, Grav is one of the fastest Flat-File CMS I have ever used and one of the best in the way it works. Grav might be the best alternative to Database driven systems in the near future.

Thanks for reading. This is my first written preview of any web technology. Feel free to give a feedback or ask any questions in a comment below.

This post was written before the features of Grav became common to other CMS

Sitemap for Wintersmith

Standard

Sitemap helps Search Engine index your website. It give the search engine a list of all the links available.

If you don’t have a sitemap your website might not be indexed correctly and only some links will be shown in search result. Wintersmith is a really good static site generator. I have written a template for Wintersmith that generates the <code class="highlighter-rouge">sitemap.xml file so search engines can index your website. All you need to do is to clone this github repo and copy the <code class="highlighter-rouge">sitemap.json from the <code class="highlighter-rouge">contents directory and places it into your website source <code class="highlighter-rouge">contents directory. Next copy the <code class="highlighter-rouge">sitemap.jade from <code class="highlighter-rouge">templates directory and place it in your website source <code class="highlighter-rouge">templates directory. This will automatically generate the sitemap required for your website.

BitTorrent Server on Raspberry Pi

Standard

Here is a really easy process to turn your Raspberry Pi into a high performance Bit-torrent server that can be used to download or upload Bit-torrent. Using Raspberry Pi as a BitTorrent can be good for users who are using more than one OS or hardware or prefer to download their stuff in the background while doing any other work. It can also be useful if you want to access all your BitTorrent in one place without changing hardware.

We would be using Transmission daemon as our BitTorrent client as it is very lightweight and comes with a really nice Web UI. We will be reverse proxy Transmission daemon using Nginx as it lets give performance benefits. This tutorial is for Debian based Linux distributions for Raspberry Pi like Raspbian or if you prefer minimal build I would recommend the Raspbian-UA-Netinst. Lets get started.

Installing.

If you are <code class="highlighter-rouge">root user you don’t require to have <code class="highlighter-rouge">sudo before every command.

  • Updating local package database.

sudo apt-get update

  • Installing Transmission daemon.

sudo apt-get install transmission-daemon

  • Installing Nginx.

sudo apt-get install nginx-full

  • Stopping Transmission Daemon to write changes in <code class="highlighter-rouge">settings.json file.

service transmission-daemon stop

  • Editing <code class="highlighter-rouge">settings.json that is located in <code class="highlighter-rouge">/etc/transmission-daemon/settings.json.

nano /etc/transmission-daemon/settings.json

You configuration file should look something like this.

`{“alt-speed-down”:15,“alt-speed-enabled”:false,“alt-speed-time-begin”:540,“alt-speed-time-day”:127,“alt-speed-time-enabled”:false,“alt-speed-time-end”:1020,“alt-speed-up”:15,“bind-address-ipv4”:“0.0.0.0”,“bind-address-ipv6”:“::”,“blocklist-enabled”:true,“blocklist-url”:“http://blacklistedsite.com”,“cache-size-mb”:4,“dht-enabled”:true,“download-dir”:“/home/pi/Downloads”,“download-limit”:100,“download-limit-enabled”:0,“download-queue-enabled”:true,“download-queue-size”:5,“encryption”:1,“idle-seeding-limit”:30,“idle-seeding-limit-enabled”:false,“incomplete-dir”:“/media/NASDRIVE/Torrent_inprogress”,“incomplete-dir-enabled”:true,“lpd-enabled”:false,“max-peers-global”:200,“message-level”:2,“peer-congestion-algorithm”:“”,“peer-limit-global”:240,“peer-limit-per-torrent”:60,“peer-port”:51413,“peer-port-random-high”:65535,“peer-port-random-low”:49152,“peer-port-random-on-start”:false,“peer-socket-tos”:“default”,“pex-enabled”:true,“port-forwarding-enabled”:true,“preallocation”:1,“prefetch-enabled”:1,“queue-stalled-enabled”:true,“queue-stalled-minutes”:30,“ratio-limit”:2,“ratio-limit-enabled”:false,“rename-partial-files”:true,“rpc-authentication-required”:true,“rpc-bind-address”:“0.0.0.0”,“rpc-enabled”:true,“rpc-password”:“{46949fbf39bfeec6dc9d4bff9f40c3f52219a4260yk9yGNo”,“rpc-port”:9091,“rpc-url”:“/transmission/”,“rpc-username”:“transmission”,“rpc-whitelist”:“127.0.0.1”,“rpc-whitelist-enabled”:false,“scrape-paused-torrents-enabled”:true,“script-torrent-done-enabled”:false,“script-torrent-done-filename”:“”,“seed-queue-enabled”:false,“seed-queue-size”:10,“speed-limit-down”:100,“speed-limit-down-enabled”:false,“speed-limit-up”:100,“speed-limit-up-enabled”:false,“start-added-torrents”:true,“trash-original-torrent-files”:true,“umask”:7,“upload-limit”:100,“upload-limit-enabled”:0,“upload-slots-per-torrent”:14,“utp-enabled”:true}`

You can change the configuration as you prefer to suite your needs. It is a really simple `JSON` document that can be edited really easily and can do many performance differences. I would recommend that you should change the `rpc-username`, `rpc-password` string and disable `rpc-whitelist-enabled` If you wan’t all `ip` address to access the Transmission Daemon. The most important thing to change is `rpc-bind-address`. change it from

```
"rpc-bind-address": "0.0.0.0",
```

to

```
"rpc-bind-address": "127.0.0.1",
```

This will let Transmission daemon run on `127.0.0.1` instead of make it run on the external ip address and makes slow as it has needs to first known the IP and then run it. Next is reverse proxy it using NGINX. For that we can edit the `default` located in `/etc/nginx/site-enabled/default`. Replace the file content with this.

```
server {
listen 80;

    location / {
    proxy_pass       http://127.0.0.1:9091;
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;
    }

}


</div>Now start Nginx.

<div class="highlighter-rouge">```
service nginx start  

Lets start transmission daemon.

```
service transmission-daemon start
```

Now you have Transmission daemon running on port 80 of your Raspberry Pi address. Visit your Raspberry Pi IP address and you should have the Transmission Web UI waiting for you to add a new BitTorrent. The amount of BitTorrent you download also depends on the SD card size. It is recommended that you use an external HDD to serve storage purpose.

Thanks for reading. If you have any question feel free to leave a comment below.