CityDesk In Depth

In this article, Fog Creek Software founder Joel Spolsky looks under the hood at what CityDesk does and how it works. This article is intended for experienced web developers and programmers.

First things first

The first thing you see when you start up CityDesk is a window showing the hierarchical view of your site.

CityDesk Main Window

It looks like a bunch of folders, with articles, HTML files, and pictures in there -- and indeed, that's what it is. But it's all stored in a single file on your hard drive using Microsoft Jet, that is, the exact same format as Microsoft Access. If you have Access on your system you can open up a CityDesk file and peek under the hood.

The simplest way to use CityDesk is just to drag your existing site, with all its folders and documents, into the window. You can rearrange them, edit the HTML files in a WYSIWYG editor, or edit any file using any editor you have installed. Here's what the built-in editor for HTML files looks like.

The build in WYSIWYG editor

It's totally WYSIWYG and very easy to use for people who are used to word processors. There's a spell checker, drag and drop, a word count, etc. Inserting a picture is as simple as dragging it in place.

One click publishes your site. It copies over files using FTP or plain old file copy to any server you specify. After a file has been copied once, it normally won't be copied again unless it changes. (You can override this optimization and republish everything by checking a box).

Indeed, if you wanted, you could use CityDesk as an overpriced file transfer utility. But bear with me for one more simple but important concept which makes CityDesk a zillion times more powerful.

A simple concept

If you have a web site with more than about three pages, chances are most of those pages are going to look substantially the same. Think of a popular news site like CNN. Click on just about any story, and you get a page which is 90% the same as every other news story. They might all have the same stuff at the top and bottom, and the same fonts and colors. The only thing that changes is the actual words in the middle.

At the heart of CityDesk is a very simple concept: the template. Instead of creating thousands of pages with the same formatting and slightly different content, you create one template which has a hole in the middle where you can stick different content to create each page.

What do CityDesk templates look like? Nothing unusual. They're just HTML pages that contain placeholders instead of the actual text. Here's a dirt simple template:

<html>
<head>
<title>{$ .headline $}</title>
</head>
<body>
<h1>{$ .headline $}</h1>
{$ .body $}
</body>
</html>

As you can see the placeholders are set off by surrounding them with {$ and $}. So now imagine that you had a simple database that looked like this:

Headline Body
Grandmother of Eight Makes Hole in One So shaken as we are, so wan with care, find we a time for frighted peace to pant, and breathe short-winded accents of new broils to be commenced in strands afar remote.
Police begin campaign to run down jaywalkers Hung be the heavens with black, yield day to night! Comets, importing change of times and states, brandish your crystal tresses in the sky, and with them scourge the bad revolting stars that have consented unto Henry's death!
Deaf mute gets new hearing in killing O for a Muse of fire, that would ascend the brightest heaven of invention, a kingdom for a stage, princes to act and monarchs to behold the swelling scene!

By slamming each row of this database into the template, we could generate three complete, beautifully formatted web pages. (Well, if the template was ugly, the pages would be too, but you know what I mean!)

This is what it looks like to edit a template in CityDesk:

Templates in CityDesk

Although CityDesk has a simple WYSIWYG editor, to get your templates exactly right many designers will edit them in HTML View:

CityDesk templates in HTML view

In fact we expect that template designers have their own favorite HTML editors and we make it easy to use them:

Choosing your favorite editor

Automatic table of contents

The first thing every site needs is a table of contents -- something that lists the articles available with links to them. In CityDesk you can create a table of contents anywhere you want by writing a little bit of simple CityScript code. Here's an example:

<html>
<head>
<title>{$ .headline $}</title>
</head>
<body>
<h1>Contents</h1>
{$ foreach x in (folder "news") $}
<a href="{$ x.link $}">
{$ x.headline $}
</a><br>
{$ next $}
</body>
</html>

There's a little loop here surrounded by foreach and next. What this means in English is "for every article which is in the folder named news, print the headline, and make it a link to the article itself." If the folder "news" contained three articles, this would produce a table of contents like this:

Contents
Article One
Article Two
Article Three

Whenever you delete, rename, move, or add an article, the table of contents will be updated automatically.

You can change the formatting of the table of contents just by changing the HTML. One popular feature is to include a teaser next to the name of the article. There's a place to enter this in the article editor. Then your table of contents might look like this:

Article One
Why you should read this story.

Article Two
Something interesting about this story.

Article Three
No, really, this is the most interesting one.

You can have as many tables of contents as you want, throughout your site. By modifying the conditions on the foreach loop, you can do really interesting things, for example:

  • list all articles in a particular folder
  • list all articles from a particular range of dates
  • list articles marked with a certain keyword
  • articles by a particular author

If you want to have a table of contents that lists "the first 10 articles in the opinions folder written by John Q. Editor from the year 2002, in alphabetical order and excluding any content which is only for advanced users", it's possible.

Would you like that baked or fried?

The power of templates depends on when you cook the content into them. Most HTML editing apps like FrontPage have templates, but once you put content into them, you're stuck. It's baked in. If you want to change the template on hundreds of different pages, you have to edit hundreds of different pages.

High powered content management systems usually fry the templates to order every time a user requests a page. The page content and the template are not combined until somebody requests that exact page. The trouble with this approach is that it can't be done unless you install software on the web server, something that few webmasters can do. Most of us just have a web site somewhere with FTP access.

So CityDesk takes an intermediate approach. We keep the content in a database, separate from the templates, until you press the Publish button in CityDesk. At that point CityDesk slams the content into the templates and uploads any changed files to your web server.

Nothing on the server

The reason CityDesk is so useful to so many people is that you don't have anything special on the web server. CityDesk just uses FTP to copy the files up to a directory you choose. When you're done your web site will look and work exactly like a web site where you laboriously hand-coded all the pages.

Even before you publish, CityDesk has a Preview feature which lets you see exactly what the web site is going to look like before you inflict it on the world at large.

If your web server doesn't support FTP, CityDesk will, on demand, create a complete copy of the entire site on your hard drive (or on any network-connected hard drive). Then you can use another mechanism (cvs, scp, rdist, sneaker-net or carrier-pigeon) to actually get the files up onto the server.

When CityDesk copies your site to the server, it also publishes an XML file with a list of files and their checksums (What's a checksum?). The next time you try to publish, CityDesk can quickly figure out exactly which files have changed. So if you only changed a tiny thing in one file, only that file has to be copied to the web server.

Making it easy

The philosophy of CityDesk is that it should be super easy for complete novices to update their web sites using CityDesk. CityDesk ToolbarOnce you turn off CityDesk's designer mode, there are only four buttons on the toolbar. Even the most computer-phobic writer, who might be overwhelmed by a full-featured web design program, can be taught how to add, edit, and remove articles. Editing articles is as easy as using a GUI word processor. Adding pictures is a simple matter of drag and drop.

Advanced stuff

Since everything in CityDesk lives in a database, there are all kinds of advanced content-management type things you can do. Here's a quick list of features.

Languages - your site can appear in as many languages as you want. There is a split-screen interface for translators. Translators can easily list all new and changed articles that need to be translated.

Multiple Audiences  - a simple mechanism allows you to create multiple versions of your site for different audiences. Once you do this, a given article can be targeted at everybody or targeted at only one audience.

Never Publish Before / After - A given article can optionally be limited in time. It will not be published before and/or after the dates that you specify.

Template Families - As we saw earlier, every article is assigned to a template that determines how it will be formatted. You can also create groups of templates called template families which allow you to publish your site with several entirely different appearances. For example, one version might be rich HTML, while another version is optimized for Palm devices.

Variables - You can define a variable, for example, {$ .Copyright $}, in one place, and include it throughout your site. Now on New Year's Day, you can change the copyright notice in one place.

Multiple Publish Locations - Suppose you publish the French version of your site to a server in France, the English version to a server in the US, and you also have a private test server for your site where it is put for QA to review. CityDesk lets you define as many publish locations as you want to make managing all this easy.

Multiple Concurrent Users - Because Jet (our database engine) is inherently multiuser, you can have up to 255 people editing the site at the same time. They all simply open the same CityDesk file over a LAN or VPN and CityDesk takes care of the rest.

Try it, it's free!

The starter edition, which lets you make web sites that contain up to 50 files, is absolutely free. Download it now! The Professional Edition is priced reasonably and comes with the Fog Creek Software no-questions-asked 90 day money back guarantee. You can buy them now and download them right away at the Fog Creek Store.

CityDesk is a trademark of Fog Creek Software, Inc. Windows, FrontPage, Jet, and Access are trademarks of Microsoft Corp. All other trademarks belong to their respective holders.

CityDesk Home

Fog Creek Home

Email Us