The JavaScript blog.


news blogs

Migrating DailyJS to Ghost

Posted on .

I've been running DailyJS since 2009 using Jekyll, but for the last few years it's made writing more difficult in many ways. The main issue I had was the time it takes to generate the site--it was at about 15 minutes on my VPS, which meant any correction took an inordinate amount of effort.

Running a static site was great for server efficiency, but not friendly for writing. Using a CMS-style blog engine definitely makes writing and supporting contributors easier, so I decided to switch.

The blog engine I've ended up using is Ghost, which is written with Node. I've hosted it within an Express app so I can set up redirections for old URLs--Ghost doesn't have an in-built redirection system. Because you can run Ghost as a standard npm module, I came up with this short program:

var ghost = require('ghost');  
var express = require('express');  
var app = express();  
var redirects = require('./redirects.json');

redirects.forEach(function(redirect) {  
  var newUrl = redirect[1];
  if (!newUrl.match(/^http/)) {
    newUrl = 'http://dailyjs.com' + newUrl;
  console.log('Redirecting %s to %s', redirect[0], newUrl);
  app.get(redirect[0], function(req, res) {

ghost({ config: __dirname + '/ghost-config.js' }).then(function(ghostServer) {  

I have JSON file that's just an array of URLs (redirects.json), and it uses this file to set up an Express route handler for each redirection.

The theme I've used is the Astro Responsive Theme which is commercial--I paid $19 which included a $2 charge for using PayPal. I customised the theme so it includes the advertising I use to fund DailyJS. The sidebar where I want to show the ads is hidden on smaller screens, which would probably cut a huge amount of revenue, so I had to write some client-side JavaScript to detect this and move the ads. This may need to be improved upon later!

Other things that still need fixing includes links to tags: Ghost has proper support for tags, so we no longer need my hacked Jekyll tags.html#tagname file. I need to somehow remap all of these links to /tag/tagname.

The thing that everyone likes about Ghost is the admin area--the editor is very friendly, and it supports pages, top-level navigation, and data import/export.

I actually used the data import feature to import my old posts. I wrote a Node program that pulls in Jekyll posts, strips the YAML frontmatter, converts it to Ghost JSON, and then maps all the relationships for tags and authors. This took quite a long time because I had to also convert older Textile posts to Markdown. I used Pandoc for that, which is awesome, except it forces Textile to use smartquotes, which means all of my code examples got messed up. I had to build a version of Pandoc that turned smartquotes off just for this purpose.

The JSON for the old site ended up being 5 MB, which I wasn't able to import into Ghost when it ran on Heroku. To get around this, I tried connecting Ghost running locally to Heroku's database, but it wouldn't work that way either. It kept timing out without a clear error. As a last resort, I ran Ghost connected to a local PostgreSQL database, then restored Heroku's database from an export of the local database.

In the end migrating DailyJS to Ghost was lots of work, and there are still more issues to iron out. I really hope readers prefer the new site, I think the design is cleaner and the tags are definitely better. If you see anything you think is wrong, you can try contacting us through contact.dailyjs.com or just hassle me with my Twitter account (@alex_young).


blogs node

Node Roundup: Cluster, Node 0.5.9 and 0.6, French Node Blogs

Posted on .

You can send your node modules and articles in for review through our [contact form](/contact.html) or [@dailyjs](http://twitter.com/dailyjs).

Node Cluster

I saw a Tweet in which Ryan Dahl mentioned this commit to Node:
introduce node cluster, 87339a2.
It adds a command line option to run a script using multiple processes.
The obvious criticism of this is it's possible to build this at a higher
level, but I agree with Daniel Ennis' comment on the commit:

While it may seem high level, I'd much rather have an officially supported method of doing it that's maintained [...]

Node 0.5.9 and 0.6

Node 0.5.9 has been released, and Node

is getting close. This means 0.6 will be the new stable branch, and Ryan
recommended testing modules against 0.5.9.

I apologize that it's taken so long to reach a new stable release - porting to Windows took longer than expected. In the future we will try to keep dev/stable cycles to 6 weeks.

I thought this was a very humble statement given the herculean effort
that's been put into Windows support. I'm looking forward to 0.6!

More French Node Blogs

I recently featured a French Node
in the Node Roundup, and
reader Sebastien Chopin sent in two more:


javascript blogs

JavaScript, JavaScript

Posted on .

JavaScript, JavaScript is a blog by Angus Croll in which he discusses high-level JavaScript concepts
and techniques. Recent articles include tutorials on
closures, throw, and

It's a blog that's worth following if you're interested in improving
your JavaScript fundamentals.

var undefined = true

This post on reddit is amusing: var undefined = true; /* the best way
to screw up whole javascript apps

It's not really as bad as it sounds because most of us do this:

if (typeof made_up_variable === 'undefined') { alert("it's cool, I'm cool.") }

The other way would be to write the following:

var magic_var;
if (magic_var == undefined) { alert('undefined!'); }

undefined = true;
magic_var = true;
if (magic_var == undefined) { alert('undefined!'); }

This has the worrying outcome of displaying undefined for both cases.


nodejs software blogs

Node Blog and How To Node

Posted on .

Node Blog is a static site generator which you can use to create a blog. It currently uses haml and
markdown for templates and content.

Node Blog powers How To Node, which features
some interesting articles about using node by Tim
(creationix). You can get the
source for How To Node in

I've been slowly reading through all the How To Node articles, and I
really enjoyed Node + Redis =
. It brings together some
interesting libraries, like Nerve
(a node microframework).