Commento on Ghost on Uberspace 7
This post explains how to install Commento (current version 0.3.1) on a Uberspace 7 installation.
Prerequisites
First choose a random port that is still free
COMMENTOPORT=$(( $RANDOM % 4535 + 61000)); netstat -tulpen | grep $COMMENTOPORT && echo "versuch's nochmal"
Because there is no port forwarding as of yet I decided to use apache as a port 80 proxy to commento. So the first step is so register a new subdomain. I chose comments.yourdomain.tld
. Register it with the uberspace
tool and don't forget to set your DNS records:
uberspace web domain add comments.yourdomain.tld
Next create a folder in your virtualroot for your subdomain and
cd /var/www/virutal/$USER/
mkdir comments.yourdomain.tld
cd comments.yourdomain.tld
Place an .htaccess
file in there with the following contents to proxy the requests to the commento server and don't forget to change COMMENTOPORT
to the port echo $COMMENTOPORT
gives you:
RewriteEngine On
RewriteRule ^(.*) http://localhost:COMMENTOPORT/$1 [P,L]
All of this will probably be obsolete in the near future.
Installing Commento
First create a subfolder for the binary and databasefile:
mkdir ~/commento
cd ~/commento
Next lookup the latest release url, download the latest release of Commento from Github and extract it.
wget "https://github.com/adtac/commento/releases/download/v0.3.1/commento_0.3.1_linux_amd64.tar.gz"
tar -xzf commento_0.3.1_linux_amd64.tar.gz
rm commento_0.3.1_linux_amd64.tar.gz
Now copy the assets (namely the javascript and stilesheet) into your ghost theme. For example I copy them in my casper theme:
cp assets/style/commento.css ~/ghost/content/themes/casper/assets/css/
cp assets/js/commento.js ~/ghost/content/themes/casper/assets/js/
Edit your post.hbs
to include the following code snippet I wrote. In my case its the ~/ghost/content/themes/casper/post.hbs
. In the casper theme there is already a commented out section for Disqus comments. Just place it right above/below that.
<h2>Comments</h2>
<div id="commento"></div>
<script
src="{{asset "js/commento.js"}}"
data-div="#commento">
</script>
<script>
Commento.init({
serverUrl: "//comments.yourdomain.tld",
commentoCssUrl: "{{asset "css/commento.css"}}"
})
</script>
Create the service file ~/etc/services.d/commento.ini
with the following content and again don't forget to change it to your actual COMMENTOPORT
:
[program:commento]
directory=/home/$USER/commento
command=/home/$USER/commento/commento
environment = COMMENTO_PORT="COMMENTOPORT"
autorestart=true
Reread, update and restart all services, so ghost also reloads the script:
supervisorctl reread
supervisorctl update
supervisorctl restart all
And you're done! There should be a comment section below every post now. If you have questions, leave a comment below.