Publishing for Little Printer using Node.js and Heroku

Oct 07, 2012

Little Printer lives in your home, bringing you news, puzzles and gossip from friends. Use your smartphone to set up subscriptions and Little Printer will gather them together to create a timely, beautiful miniature newspaper.”

Little Printers first came to my attention whilst chatting with Alice from BERG at OGN 28. I thought they sounded like fun and thought I’d have a go at becoming a Little Printer publisher.

A quick glance at the API confirmed my suspicion that node.js would be ideal for serving up content.

In order to simplify matters further both for myself and others, I created a node module that handles most of the complicated stuff. It makes creating a node server for serving up Little Printer content a breeze. It’s all open source and on github, so take a look.

I thought I’d create a guide to publishing for Little Printer using a node server hosted on heroku. I’m confident you can be serving up content within minutes.

Install Heroku Toolbelt

Make sure that you have a Heroku account and have installed the toolbelt. The instructions are pretty simple if you haven’t and it’s free so no excuses.

Get The Sample

I’ve created a simple example project that you can take for starters. You can clone it, fork it or copy it. Whatever works for you. Let’s start by just cloning:

$ git clone git://github.com/roylines/node-littleprinter-example.git

Take a look at the code while your at it. It’s pretty simple. Here’s a quick overview:

  • server: initialises, configures and listens.
  • handler: allows you to configure your meta and get complicated content.
  • views: ejs template files for sample and edition .
  • icon: I guess you can work this one out.

Yep, it’s really that easy (in fact there’s an even simpler example here).

Personalise It A Bit

So you’ve got the sample why not personalise it a little.

Try changing the meta in the handler and replacing the icon.

Publish on Heroku

In summary you need to do the following:

$ heroku create
$ git push heroku master
$ heroku ps:scale web=1

Any problems take a look at the Heroku documentation.

That’s It!

OK, you’re done. You can use the BERG tools to validate the endpoints and preview your editions.

What Next?

Well I guess that bit’s up to you.

I took the example and wrote a simple publisher for getting a weekly bit of Edward Lear nonsense, and here it is:

Little Printer Lear Nonsense

Have fun and let me know if you find the module useful.