Why I wrote my own CMS so I could write a novel in a month

November 2, 2012 | 8 comments

Growing up, I always wanted to be a professional writer. It’s still something I aspire to, but I get just as many creative kicks out of building software – and the pleasure is even greater when, just occasionally, I get to combine the two.

I’ve tried to participate in NaNoWriMo, the National Novel Writing Month, before. Usually, I flake out. To have “won” NaNoWriMo means that you’ve written a complete novel of over 50,000 words over the course of the 30 days of November, and most of the time I stall at 3,000 or less. I’m ashamed to admit that part of my inability to complete any kind of long-form content is my dependence on the Internet: I’m so used to tweeting and getting feedback that the thought of getting to 50,000 words without anyone seeing it is daunting. (There’s a whole other piece to be written about this – I’ll get there another time.)

So, I decided that this year I’d try it again, but I’d publish publicly as I went. It’s an exercise in perseverance more than anything else, so I’ve tricked myself into thinking that this is okay. So here it is – but I’ve chosen to write it a homegrown CMS rather than using Word or WordPress. I wanted to prominently see the word count as I typed, to track my progress towards 50,000 words. And I didn’t want to deal with the increasingly-complicated WordPress interface (which I gladly use for this blog) or be tied to a single computer in the way I would be with Word. I also wanted to play around with some little bits of flair that would be hard with an existing piece of software.

So, I spent an hour or two the other night putting something together.

(My Writemo editor, above, vs WordPress’s editor, below.)

The CMS is a series of PHP scripts sitting on a single-table MySQL back-end. I’ve split the novel up into segments, which are effectively posts. That makes it easy for me to edit small chunks of the novel at once, rather than having to open the whole thing up each time. It also allows me to syndicate the novel in an RSS feed, and give people the choice to read it novel-style, with the segments in ascending order, or blog-style, with the newest segment at the top.

There are no images. I set the background to #eeeeee, the text color to #333333, and the font to Kameron from the Google Web Fonts collection. The editor is a simple textarea control, but in order to ensure I can use tabs, I use the following jQuery (which I found on StackOverflow, although I’ve now lost the source page):

$('#maintext').keypress(function (e) {
    if (e.keyCode == 9) {
        var myValue = "\t";
        var startPos = this.selectionStart;
        var endPos = this.selectionEnd;
        var scrollTop = this.scrollTop;
        this.value = this.value.substring(0, startPos) + myValue + this.value.substring(endPos,this.value.length);
        this.focus();
        this.selectionStart = startPos + myValue.length;
        this.selectionEnd = startPos + myValue.length;
        this.scrollTop = scrollTop;

        e.preventDefault();
    }
});

I also count the number of words in the textarea with each keypress, and display both the number of words in the current segment, but also the number of words across the whole project (top and bottom numbers respectively in the screenshot). For this, I used C. Bavota’s jQuery word count plugin as a starting point, and pared it down into something simple enough for my needs.

Because I didn’t want to mess with wysiwyg editing, I chose to use markdown notation in the editor. That way, I can italicize a passage by using _underscores on either side of it_, for example. It’s very intuitive, particularly if you’ve ever edited anything on Wikipedia or in Mediawiki. And Michel Fortin’s PHP Markdown project is extremely simple to use: you simply wrap your string with the Markdown($string) function in order to turn it into perfectly serviceable HTML. The only niggle is that I noticed it doesn’t handle single line-breaks very well, so I deliberately double-space my text before I convert it from markdown.

And that’s it; the editor itself is deliberately designed to be extremely simple, and (if I push Firefox to full-screen mode) feels like a low-rent iA Writer or other distraction-free writing utility. I can edit from anywhere, on anything that supports standard HTML, and my pages are extremely low-impact. And most importantly, I’m getting the words out.

Anyone else rolling their own software for this kind of thing? I’d love to compare notes.

A geek’s guide to writing

March 2, 2012 | 2 comments

NOT one of THOSEI’ve had this idea for a story for years. We live in a world where truth is curated for us, everything we do can be tracked and used to infer things about what we’re going to do next, and identity is defined by what we broadcast. What happens when we no longer fit into the narrative?

This year, I’m writing it. It’s called Profiled, and I’ll be releasing it in installments later this year, alongside a blog about taking a lean startup approach to writing a novel. You can sign up for free here. (And yes, these posts and the signup form are my minimum viable product.)

I can’t tell you too much about my actual writing thought process, because I don’t know what to say. I’m getting into the story, which is probably a good sign, but there’s no getting away from the fact that I’ve never done this before. I need professional advice and editing. More on that another time.

Nor can I talk authoritatively about how to write in terms of the structure of language or narrative. Instead, I thought I’d tell you a little about my setup:

Sitting down to write

Years of Internet work (and obsessive Twitter checking) have left me with a very short attention span. I’m shockingly easy to distract.

For a while I was using Dr Evil’s Write Or Die, a little Adobe Air app that forces you to write a certain number of words in a pre-defined timeframe. Plug in 500 words and 25 minutes, and you’re off, racing against the timer. The app punishes you if you pause significantly. If you’re feeling particularly masochistic, it’ll even start to delete your work, word by word.

I wrote my first published short story this way, but this is a very stressful way to write a longer piece. Also, Adobe Air is unholy. So for Profiled, I’ve been experimenting with the same methodology I use in my day job: the Pomodoro Technique.

I give my Pomodoro session a brief title based on what I intend to write about (although I don’t hold myself to it), hit “OK”, and write until the timer goes off. Pomodoro gives me five minutes’ break, and then I start again. It’s a great way to write regularly and sustainably.

Keeping track of my writing

I’ve got both LibreOffice and Microsoft Office on my computer, as well as TextWrangler, OmmWriter and a number of other editors. But what really works for me is Scrivener.

I’ve got to admit that I was skeptical about all the hype around Scrivener, but it just works. It’s got a distraction-free text editor, it allows me to rearrange portions of my story as I see fit, and is unrepentantly geeky in the way that it stores my writing. It’s like dealing with a well-designed Git client for creative writing. If you’ve been hesitating over the “buy” button, I can confirm that it’s worth every penny.

(Side note: I did once start a poetry anthology as an open source Github repository. It turns out, though, that I’m not a poet. I’d be very interested in collaborating with poets on something similar though.)

The whole thing – like virtually all of my documents – is backed up on Dropbox (I’m a paying user), which allows me to keep track of versions and sync across any of my devices. Cloud services have changed the way I use my computers, and that’s no different here.

Research

Inevitably, almost all my research has been on the web. I’ve never been someone who keeps bookmarks, or leaves a bunch of tabs open overnight. My browser windows never stay open for more than a few hours. So when I do want to keep something, I need another approach.

Obviously, I use Evernote. It’s magic: notes, bookmarks, images and audio notes are all synced across my devices, available to me offline and easily searchable. The Chrome plugin is seamless. I wouldn’t use anything else.

Not-promotion

This has been my biggest struggle. I’m used to the instant gratification of social media, and there’s nothing instantly gratifying about writing long-form pieces. I previously shared a taster, but this was from my first draft – it’s likely to change significantly before I’m done. Should I have shared it at all? Probably not. In fact, I’m not convinced that my extended social media use is good for me at all – but that’s a subject for another post.

For now, my plan is to hold back and write, while gauging interest in the project. I’d love your input, both on the software I’m using above, and the themes that I’m incorporating into the story. But it won’t be ready til it’s ready.

In the meantime, you should definitely subscribe to updates here.

Spire Magazine: a teenage (mis)adventure

September 3, 2011 | Leave a comment

My high school yearbook entryI wrote a piece over on Google+ about Spire Magazine, my first real Internet project:

I became the editor and publisher, roping in our friends with the promise that they could get free games if they reviewed them. We considered static text files or the web, but decided that neither had the possibilities for layout and design that we wanted. So instead, every month I would edit everyone’s articles and compile them down into Windows Help format: an encapsulated hypertext format that could easily be downloaded. (These days, I’m convinced I would have used epub.)

[...] One piece we ran several times was called “What do you do on the Internet?” Nowadays the answer would be “everything”, but back then usage was still emerging. So people like Nicholas Negroponte, G.B. Trudeau and Roger Ebert would reply with very specific examples. I wish I still had a copy of these early issues.

These experiences still color everything I do; you can read the whole post over here. What was your first Internet project?

Separating form from content: when is a book a book?

April 5, 2011 | 1 comment

NOT one of THOSEFor what it’s worth, this blog is now available over on the Kindle Store for the Amazon-imposed price of $1.99 a month.

Of course, if you do decide to read it on your Kindle, you’re going to lose the standard form of a blog: the distinctive page shell, the list of posts, and probably the comments. Just like if you read it in Google Reader or any other news application. If someone links to this article on Twitter and you use a magazine app like Flipboard on your iPad, you’ll also have a completely different experience. Same exact content; different layout depending on your circumstances.

For reading consumers, this is a significant advance. Circumstances do change: what’s convenient for me to read in bed is different to what’s convenient at the office, on a train or spending ten minutes in a coffee shop. Each of those may require different devices, different software applications and different settings depending on what I’m doing.

For these reasons, software developers and web designers have been used to separating form from content for years. Model-View-Controller is a commonly-used software design pattern that separates data (the model) from both logic (the controller) and visual interface (the view) in a system, ensuring that each can be changed without affecting the others. Now that content is moving wholeheartedly into the digital arena, it makes sense for it to harness some of the same ideas. In a book, the words might be the model, the typography and layout might be the view, and the physical framework of the book itself might be the controller.

That opens publications up to a kind of remixing they’ve traditionally been insulated from. Geeks who love Hacker News but find the interface hard to read can install Georgify to make it more typographically palatable. People looking for emotional inspiration on Twitter can spend a couple of minutes with Twistori, an app that pulls out certain tweets and displays them in an appealing, emotionally resonant way. Mostly these kinds of things have been impossible with Wuthering Heights or The New Yorker.

There are a lot of people, I know, who love the form of books, and who are frightened of that changing, ever. And it won’t: there will always be books. But digital technology gives artists the power to explore new forms for content, that can be disassociated with the content itself and applied, again and again, to different words, in order to create whole new works. If your Twitter stream can be a book, then a book can be a real-time application, or fragments scattered in time and geographic space, or anything you can get your head around. And anyone can remix, and reskin, and make the form – as well as the content – have a life of its own.

If you’re in London on May 14th, Book Hack Day will cover some of these ideas. Regardless, I’d love to read your hacks and play with your words. I think there are many possibilities, and I’m excited to explore them.

Next Page »