A simple web content management system using Compojure, Enlive and Twitter Bootstrap.
The software is available on github: https://github.com/ray1729/simple-cms.
It was written with my own website and workflow in mind, so is
unlikely to be useful to you out of the box. At the very least you
will have to update the layout template, and this may require changes
to the Enlive snippets in views.clj
.
The basic idea is that the site content is managed in a separate git
repository. This should contain two directories, content
and static
. Files in the static
directory
are served verbatim. For example, the file
$SITE_DIR/static/some/path.png
can be accessed from the
server via /some/path.png
.
Items in $SITE_DIR/content/some/path.html
will appear on
the server at /content/some/path
(note: no
.html
suffix). These articles are simple HTML with some
extra meta tags in the header, for example:
<html> <head> <title>Book Review - Secure Coding: Principles and Practices</title> <meta name="author" content="Ray Miller" /> <meta name="tags" content="book review, programming, security" /> <meta name="pubdate" content="2004-06-01" /> </head> <body> <p class="teaser"> This slim volume contains a wealth of information that will be of interest not only to software developers, but to anyone responsible for the deployment and operation of computer systems. Indeed, if I had one complaint about the book it would be that the title is misleading: it is not so much about secure coding as the overall software development process, and relatively little is said about coding per se. But do not let this put you off, programmers will benefit from reading this book too. </p> </body> </html>
The title
, author
and pubdate
become the header and subheader of the displayed item. The
tags
are used to build the tag cloud and category index.
Paragraphs with class teaser
will show up in the indexes.
Items without a pubdate
will not appear in any indexes,
but can be accessed via /preview/some/path
.
The CMS software takes care of rendering the article lists (optionally filtered on tag) and the articles themselves. It also produces an Atom feed for the latest articles (again, optionally filtered by tag).
The software provides no editing facilities. It is assumed that you
like to edit your content offline and commit to a version control
system. With this in mind, it also implements
/api/refresh-site-content
which handles POST requsets
containing an API key. If the key is valid, a git pull and metadata
rebuild is initiated, updating the site content. This will usually be
triggered by a post-commit hook in your VCS.
The content paths and API key are configured
in resources/simple-cms.properties
.
This software is currently hosting my own website, http://cms.1729.org.uk/.
Copyright (C) 2012 Ray Miller.
Distributed under the Eclipse Public License, the same as Clojure.