Welcoming Comments

Surprise!

I was really pretty shocked once Ghost was up and running that it didn't already have comments from the get-go. I mean, what good is a blog without comments?

What now?

I went to the Ghost website and found this page on integrating comments. It mentions that some themes come with comments. I checked that out: the themes that have comments, usually add one of those listed, so I still have that decision.

I love tables. Here's one now:

Comment System Thoughts
Disqus Requires you to register with Disqus. Comes with an advertising system. On the one side, I need ad revenue. On the other, I don't want to be locked in to one particular advertiser. And I don't like that they've got the user data regardless.
Facebook Facebook?!?!
- users must register at FB - unacceptable
- FB data collection practices - unacceptable
NodeBB A bulletin board system? It uses mongodb*, a big negative. Still the most acceptable so far.
Livefyre Requires you to register with them - they host the comments. No.

So, I go with NodeBB.

Preliminaries

I go to NodeBB and find the guide for installing under Ubuntu. I have all the prerequisites, except:

Mongo!

Every time I think of MongoDB, I can't help thinking of Mongo from Blazing Saddles:

mongo

(The stunt horse was not harmed - note how the rider tugs on the reigns just before the "punch")

Looking at NodeBB's guide for installing MongoDB, I notice it doesn't match-up with the other info: it mentions Redis as the default, where ghost doesn't even mention Redis as a possibility, and "Note: NPM is installed along with node.js, so there is no need to install it separately" (hah!). So, I just search for the package:

$ apt-cache search mongodb

Reveals a butt-load of packages, so I go ahead and

$ sudo apt-get install mongodb

I check the list: nothing being uninstalled. Among those being installed: mongodb-clients, mongodb-dev and mongodb-server - it looks good. Confirm, and after a few minutes, it's done installing.

Back to the main course

Like with ghost, I made a user (nodebb) and a directory. Then I go ahead and git clone nodebb:

$ cd /var/www/ghost/nodebb
$ sudo su nodebb
$ git clone https://github.com/NodeBB/NodeBB.git nodebb **

This, of course, puts nodebb in the directory /var/www/ghost/nodebb/nodebb, not the intended /var/www/ghost/nodebb.
facepalm This isn't the first time I've done that. Maybe I should turn this into a script in /usr/local/bin or something:

Note: I need to go su briefly to do this.

$ cd ..
$ mv nodebb temp
$ cd temp
$ mv nodebb ..
$ cd ..
$ rmdir temp

Proceeding with installation per the nodebb guide:

$ cd nodebb
$ npm install --production

That seems to work, again leaving a tree that scrolled everything else off-screen. What's next?

$ ./nodebb setup As in the guide? No!

I tried that: that way leads to pain and suffering (unclear questions, failure to connect to MongoDB). Instead, jump ahead and just start it.

$ ./nodebb start

It starts in the background - I have a prompt again. So, this script works like an /etc/init.d script. I'll have to copy it there and set it up so that it starts on bootup - later.

Now, since it is only available locally (localhost above), I use lynx, which works in a shell:

$ lynx localhost:4567

I confirm the cookie it wants to give me, then get a nice page.  

Then per the ghost instructions, I try to login. Selecting the the [login] link doesn't seem to do anything. I scroll down.

Your browser does not seem to support JavaScript. ...

watchmen-smiley

Of course. Logins usually need JavaScript. Back to plesk. Setup a new subdomain nodebb.softwareschmiede-herndon.de. Redirect the new subdomain to localhost:4567 using ProxyPass (see My Oddysey to Blogging-Land).

Then, opening a regular browser to nodebb.softwareschmiede-herndon.de, I am greeted by this glorious sight:

nodebb-installer-welcome

Note: I reconstructed the process in VirtualBox, which is why it says localhost:4567 instead of nodebb.softwareschmiede-herndon.de

For administrator, choose the username you want your users to see when you post - changing it later can cause you problems (yes, that's experience talking).

Choose a strong password right from the get-go: if you don't, it will fail without warning you: it won't create your admin account, while otherwise completing installation. You will be locked out.

If you do manage to lock yourself out, remove the config.json in the nodebb folder and try again - that worked for me.

Of course, change the database to MongoDB.

Then click "Install NodeBB". On the following page click "Launch NodeBB". Then login: you should land on the admin page.

Finally with setup done, I now install the "comments widget" as per the ghost instructions (this page again):

$ npm install nodebb-plugin-blog-comments

The instructions say to "Click on the Reload button at the bottom of the main Admin page". It's called the "Dashboard" now and restart button is:
nodebb-dashboard

Activating the plugin:

  • "open up Extended -> Plugins and activate nodebb-plugin-blog-comments". It's "EXTEND" now, but fine. I click on Activate for nodebb-plugin-blog-comments.
  • then I also activate nodebb-plugin-dbsearch - I want comments to be searchable.
  • Return to the Dashboard
  • Click [RESTART]
  • Refresh your browser (usually F5) - Do not skip this step: there is no auto-refresh when you click [RESTART], and the menu you need for the next step will not be there.

Configuring the plugin:

  • "Go to Installed Plugins -> Blog Comments".
  • I fill in the page and click

nodebb-save

The promised button with the word "Save" on it in their picture has morphed into this badly drawn image of a media that kids these days have never actually seen. The inner blue circle needs to be centered, it's the center of rotation for the disk inside! And there's no mouseover text - no hint! I have blind friends for whom this kind of thing matters! Sorry, I digress.

  • Go back to the Dashboard and
  • click [RESTART] again.

Inserting the comments into ghost - as per the instructions:

  • I find the file post.hbs - /var/www/ghost/content/themes/casper/post.hbs
  • I open post.hbs in a text editor
  • find the location of {{content}}
  • Copy and paste the following text after that line:
    <a id="nodebb-comments"></a> <script type="text/javascript"> var nbb = {}; nbb.url = 'http://nodebb-forum.com'; // EDIT THIS   (function() { nbb.articleID = '{{../post.id}}'; nbb.title = '{{../post.title}}'; nbb.tags = [{{#../post.tags}}"{{name}}",{{/../post.tags}}]; nbb.script = document.createElement('script'); nbb.script.type = 'text/javascript'; nbb.script.async = true; nbb.script.src = nbb.url + '/plugins/nodebb-plugin-blog-comments/lib/ghost.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(nbb.script); })(); </script> <script id="nbb-markdown" type="text/markdown">{{{../post.markdown}}}</script>

  • Edit the line with EDIT THIS, in my case, changing nodebb-forum.com to nodebb.softwareschmiede-herndon.de.
    Note: I first tried to be smart and hide nodebb, using localhost:4567. Of course it doesn't work - this script is executing in the client machine. Yay sleep deprivation!

  • I restart ghost:
    $ sudo /etc/init.d/ghost restart

I go to my first blog article at the bottom, note that it says "Read only". Oh, but there's this nice button: [PUBLISH THIS ARTICLE TO NODEBB]. I press it, and voila: I can comment!

Dancing

I'm not done yet.

As a good programmer, I test it from the users perspective: I register a new user and make a comment. Hooray!

Two days later, a friend skypes me with a comment. I tell him to go ahead and post it. He says he can't yet - apparently there's a one hour waiting period after registration. He thinks. It's not really clear to him.

I'm not sure why it worked straight away with my test user. Maybe some cookie from my admin login was still active?

In any case, I'm not happy with my users having to wait an hour by default:

  • I go to nodebb.softwareschmiede-herndon.de
  • I click on the Admin icon nodebb-admin-gears
  • I select the menu Settings→User
  • I activate Email registration.
  • I click the funky save icon.
  • I change Account Lockout Duration to 1 minute.
  • While I'm at it, I go to Settings→Email and set that up, too.

I'm eventually going to have to take spam counter measures - some sort of challenge against bots. But for now, I'm done.

exhausted at the finish

Lessons

  • Being bleeding edge is exhausting.
  • Sleep is good - coffee can only do so much.
  • When testing, use a different browser without your cookies. Better yet, a different machine. Still better, if possible, have someone else try it - you might have developed error avoidance habits.
  • Having a spare Ubuntu in a VirtualBox is very useful when trying to reconstruct what you did from incomplete notes.

Resources

* Why you should never use mongodb, by Sarah Mei, a contributor to Diaspora. Diaspora was founded as a more privacy rights aware alternative to Facebook, but got off to a bad start and has yet to take off.

** I skipped the -b v1.x.x recommended in the git command: I'd have to look up the most recent versions, decide which is stable enough, which might involve looking into individual bugs, etc. Nah, I want this done. We're already living dangerously getting a bleeding edge BB, we'll just get the bleeding edge version.

Copyright © 2016 William David Herndon. All rights reserved.

Here be ads: