Edit 16 Dec 2013: For a richer and supported solution, check Ruby-based
Nanoc.
After checking out a bunch of Content Management System (CMS) softwares, either server- or desktop-based, I got fed up looking and wrote my own. I wanted the following features:
- Runs on my Windows desktop, so as to increase performance and make it easier to back up data files
- No or little setup required
- Truely WYSIWYG editing. Even a textarea in a browser with basic WYSIWYG like HTMLArea is no match for a dedicated WYSIWYG HTML editor like Namo Webeditor, Mozilla Composer, or Dreamweaver. I'm a CTRL-S addict, so a web-based editor is out
- Small and fast utility to let me apply a common layout to all the articles of the site (ie. CSS, navigation bar), and regenerate the homepage whenever a new article is added
So... I finally wrote the following snippet in PowerBasic
Python and the PyWin32 module Delphi 7 to display a basic GUI
and generate a static web site. Things can be simplified yet by compiling the Python script into binaries using py2exe, and combining the few files that are created into a single file using PE Bundle
Thanks to Delphi, this EXE has no dependencies, and requires no installer.
Here's how to set things up:
- At the root of where you want to store the files for the site on your
workstation (eg. C:\WWW), copy this EXE
- In C:\WWW, create a directory called .\input. In this directory, create
sub-directories, one for each category of articles (eg. .\input\Unix, .\input\Windows,
etc.) The names are significant, as BabyCMS will use them in the index page.
In other words, renaming a sub-directory changes the category name displayed
in the index
- Populate those sub-directories with HTML files with the HTML editor
of your choice. Word generates crappy HTML, but BabyCMS doesn't care as
it will extract data stored in the TITLE, KEYWORDS, and BODY tags, and ignore
the rest of the document
- In C:\WWW, create a directory named .\templates, and empty this
ZIP file there. As you can see, those files are used to generate articles,
including a header and a footer.
At this point, the EXE should be
in C:\WWW\, and you should have two directories, C:\WWW\INPUT\ with a least
one subdirectory, and C:\WWW\TEMPLATES\ with a few HTML files
- Run the EXE: It will loop through the list of sub-directories in .\INPUT,
merge each HTML file it finds with the templates, save the resulting article
in C:\WWW\OUTPUT (which will be created the first time the EXE is run),
and an index.html will finally be created in .\OUTPUT, listing all the articles,
each layed out in the category where it belongs.
To speed things
up, a file named data.txt is created at the root of the site to record the
TITLE and category to which each file belongs, to avoid needlessly opening
all the files where rebuilding the index, even for files that didn't change
since the last build
- Use your favorite FTP client to upload the contents of .\OUTPUT to your
web server.
Create a directory to host everything, such as C:\WWW
At the root level of this directory, create a directory eg. /script/ and
put babycms.py
in there, after making sure you installed ActivePython (this distribution
for Windows includes PyWin32)Still at the root of C:\WWW, create a subdirectory input/ (ie. C:\WWW\INPUT) where the raw articles will be located. "Raw" means the articles that hold the actual contents before we massage them to have a common look and feel
While in C:\WWW\INPUT, put INDEX.TPL and TEMPLATE.TPL, which are the templates that will be used as the layout to generated the homepage and articles, respectively
Personally, I keep the CSS and a couple of GIF at the root of the site, and images somewhere below /images/. If you change this, remember to update the template files accordingly
Each article in input/ must have the following layout:
<html>
<head>
<title>The article's title</title>
<meta name="description" content="Some description">
<meta name="keywords" content="some keywords">
<meta name="classification" content="other">
</head>
<body>
[the actual article here...]
</body>
</html>
Important: As you can see in index.tpl, each article must be set to one of a few categories (unix, windows, other, japan, misc.) This is how BabyCMS can tell in which section an article must be listed in the homepage. To customize this stuff for your site, edit index.tpl according to whatever word you use in the Classification metatag in source HTML documents.
Run BabyCMS: It will loop through each HTM(L) file in input/, create a cuter equivalent under C:\WWW\docs\, and (re)generate index.html at the root of the tree
Use your favorite FTP client to upload /index.html, /docs/*.*, along with add-ons like a CSS file, and images.
Voilą! :-) You now have your very own fast, static, personal web site, without
bothering with clumsy, browser-based, through-the-web editing.
Full disclosure: Since I have zero artistic talent, the look and feel of this site was shamelessly stolen from the default layout that comes with the database-free, PHP-written Pivot CMS.