

Ask HN: Lightweight Programmer's CMS? - amouat

Does anyone have any recommendations for a lightweight CMS?<p>I'm happy writing pages in HTML &#38; CSS but I need something to take care of the menus, header and footer etc ("theme" if you like).<p>So far I've survived with a shell script that literally cats some common header and footer HTML onto my pages, but I feel there has to be a better solution.<p>Update: It seems what I'm looking for is often known as a "Static-site generator".
======
mahmud
I wrote a single DEFPAGE macro that takes care of this.

    
    
      (defmacro defpage (name (uri &optional title) &body body)
        `(define-easy-handler (,name :uri ,uri) ()
            (with-html
              (:html
                (:head (:title (or ,title (string-titlize ,uri))))
                (:body
                  (:div :id "container"
                    ,@body))))))
    

Usage:

    
    
      (defpage aboutus ("/aboutus" "About Hacker News")
        (:h3 "Hacker News Consists of the following people:")
        (:ul :id "user-list"
           (dolist (user (list-all-users))
              (htm (:il user)))))
    

The one I use for my current project is 2 pages long and even generates SEO-
friendly meta tags from the text content. In the future, I intend to make it
index each page into a Common Lisp search engine (Montezuma) so I can search
my entire site whenever I want.

I slice and dice CSS and html until I like the page layout, then abstract the
common parts and put them in DEFPAGE. I even have session-based stuff that
shows a login/logout stuff on the top of each page in tiny font, so logged in
users can view the public pages and know they're still logged in.

[Edit: Tonight I wrote self-validating CLOS objects that map to a database
record. They generate their own Lisp and Javascript validators and the
validators are auto-invoked both on the client and the server whenever their
respective object is instantiated. On the javascript side, instanciation is
attached to the :action of a form; it's clean and pretty, but forces me to use
a seperate form for each class/table. I only came up with the idea this
afternoon, so give it some time.]

~~~
apu
Somewhat unrelated, but is there a javascript library that I can use to
generate html strings which can be used similarly to your lisp code? i.e.,
something like this:

    
    
      var users = [...];
      var s = h3("Hacker News Consists of the following people:");
      s += ul({id: 'user-list'}, map(li({'c': "userel"}), users));

------
sohooo
Don't forget Webby (Ruby-based), which is pretty lightweight, but can be
extended depending on your environment.

It features various markup languages, some syntax highlighting options,
autobuild, and more.

<http://webby.rubyforge.org/>

~~~
evdawg
Very similar is Nanoc, Ruby-based, lightweight, and flexible.

<http://nanoc.stoneship.org/>

------
noss
I'm using Jekyll, the static site generator known from github pages. It will
definitely be a step up from writing html and doing cat HEAD ARTICLE FOOT >
PAGE :)

~~~
amouat
That looks pretty good, I'll probably give it a shot.

My only concern is that it seems oriented more towards blogs; do you think
I'll have any problems using it for a small open-source project website?

~~~
noss
The blog part will come handy for a project website, as you will probably have
a news-section on the front page with release and event announcements.

You can use the 'topic' feature to select "non-blog" articles with a given
topic. Say if you want a menu entry generated with links to all your
'documentation' topic pages.

I forget what the tool/library is called, but there is even support for syntax
highlighting code. Lots of languages supported, even Erlang which is properly
obscure I think.

I find the Yaml premable in articles very useful, if I add a description entry
there, i can refer to page.description in my template to add a meta-
description header, and in the RSS feed i can use it to summarize the article.

I also feel pretty secure in that if I would ever want to give up on Jekyll
most of my site would be in textile format which is quite practical and
supported by other things than ruby.

------
carbon8
Staticmatic is another static site generator that might be close to what you
are looking for. You can write your pages in Haml and Sass, so in addition to
much simpler markup and the ability to use inline textile and markdown, you
can also pull the header and footer out into partials.

<http://staticmatic.rubyforge.org/>

<http://github.com/staticmatic/staticmatic/tree/master>

------
pj
<http://www.qrimp.com> has a feature called "publisher" that you can use to
convert any database content to a set of static files that it can then FTP to
any server. You can modify your data, which in your case would be just the
content between the header and footer, you can also include a header file or a
footer file. The header and footer could change based on which area of your
site (which data) you are publishing.

The data can be anything, products, customers, or lists of blog posts. The
Qrimp blog is managed with the Qrimp publisher, for example:
<http://www.qrimp.com/blog/categories.Features.html>

With the templating system, you can create complex query structures to pull in
data from any table in your Qrimp app. It is a programming construct of sorts
that allows you to create static pages that are the result of dynamic queries,
so your website loads really fast, but it is based on a dynamic database.

------
colas
I would advise using a wiki. Wikis fit well the programmers mental model as
their main concept of editing "source" code that is compiled into a "machine"
language (HTML). What wiki to use will depend on your favorite language or
concepts. I use Foswiki <http://foswiki.org> (although I hate perl), because
you can mix html/css/javastrict with the wiki syntax, and it has no database
so I can hand edit easily the pages in emacs or use various shell hacks on
them. But many nice wikis exist, for intance moinmoin is a nice one for python
lovers.

I maintained my site with hand edited html, then I wrote a template engine for
it, but for one year I have just ported everything on Foswiki (Foswiki is the
active fork of TWiki), and have no regret. And if I want to add features, I
can code plugins to it, use other people plugins.

------
martin
If all you want to do is attach a header and footer to an otherwise static
HTML page, why not just use SSI?
<http://httpd.apache.org/docs/1.3/howto/ssi.html>

~~~
amouat
Good suggestion, but I think I'll go with one of the other solutions for a few
reasons:

\- I'd rather keep things completely static if I can

\- It ties my site to Apache a bit

\- I may as well take advantage of some of the other features Jekyll etc
provide

------
silentbicycle
If you're just converting static content, Make + Markdown + small amounts of
Awk/Perl/etc. should suffice.

There's also werc (<http://werc.cat-v.org/>).

------
andyking
I quite like ModX (<http://modxcms.com/>) although it might be a little on the
bloated side for many here. It's a pretty bog-standard PHP/MySQL package.

Basically, you design and code up your pages as if they were static, then
insert "template tags" where you want to put your title, content, footer, menu
- all of which is then pulled from the CMS database. I might be barking up
completely the wrong tree here but it works for me when I want to throw up a
site quickly.

------
mapleoin
Write one yourself in your favourite programming language! Don't forget to
include (what I use on my blahg): a markup language (textile), code
highlighting(pygments), a templating engine(mako), RSS.

The markup language and the templating engine are the things that really make
this effort worth it. Especially since you can now use your favourite editor
to edit posts. You can't really do that with wordpress.

~~~
amouat
I'd love to, but that's a bit much work. And I'd go mental when I wanted to
urgently make a small change to the website but was forced to spend hours
fixing some stupid bug.

I do use Wordpress at the minute, and pasting text from Vim tends to be
painful, which is one of the reasons I don't want to use it for my project
website.

------
kriskowal
Aeons ago, I wrote a language called SWL that served this exact purpose. It's
an condensed HTML dialect, similar to later inventions like markdown and
textile, but designed for programming and minimizing markup. It takes a
template from the directory context and generates HTML from all the SWL files.

<http://cixar.com/swl/>

------
catch404
Has anyone used Hobix? <http://www.hobix.com/>.

Seems very hard to beat a lisp style solution such as the one posted by
mahmud. lisp html generation always seems so much more concise than other
languages.

I've started writing one in python similar to mahmuds. Might be the perfect
time for me to learn clojure.

------
limmeau
There is also the WML (Website Meta Language) at <http://www.thewml.org/> \--
I used it for a few static websites in the early 2000s, but it isn't
maintained any more. It combines an HTML macro package, embedded perl, m4 and
a few other tools into a nine-pass compiler.

------
mvalente
I just use 2 shell scripts, cat.cgi and index.cgi, at my blog

<http://mv.asterisco.pt/cat.cgi?cat.cgi>
<http://mv.asterisco.pt/cat.cgi?index.cgi>

(View source)

\-- MV

------
btbytes
Try <http://github.com/btbytes/webgen.py> . This is a static site generator
written in Python.

It's a single Python file, with support to mardown, textile etc. The template
is one single file too which is based on YUI.

------
teilo
Or - you could use Django and whip something up really fast - just use their
template engine, and you get all the menues, header, footer, etc, and replace
the content with a big block of HTML pulled straight from the DB.

~~~
durin42
That's very much like Blatter: <http://bitbucket.org/jek/blatter/src/>

------
bradgessler
I've started using Sinatra for small websites. Its not a static-site generator
but it does give me pretty simple control over layout and I can do some
dynamic things if I wish.

------
dizz
CMS.txt? <http://cms.thewikies.com>

~~~
amouat
That's what prompted me to ask the question. Have you used it? What do you
think?

Going on what I've seen so far, I think Jeykll might be the best choice.

------
stevejalim
How about <http://grabaperch.com/> ?

------
jrschulz
rest2web: <http://www.voidspace.org.uk/python/rest2web/>

It is not very flexible, but doesn't take very much effort either.

