CMS? DoItYourself! (version 5.1)

Home Page | Comments | Articles | Faq | Documents | Search | Archive | Tales from the Machine Room | Contribute | Login/Register

Long, long ago, in a galaxy far far away, I began writing my own web-site. Since I'm a control freak, I decided to write it down from scratch directly in html. No bullshit.

Now, that's fine if the site is relatively small, but after a while is going to get tought, especially if you want to change something that is in every page like a logo, or the style of the title. Manual editing is slow, tedious and errors-prone.

Well, that's why mankind invented CMSes (Content Management Systems), so you can concentrate in writing the content and let the system take care of the rest.

But... I couldn't find a CMS that I really liked and could do what I wanted.

First of all, I want to be able to divide my site in "pages", each one is a document on his own, each one has common parts (title, navigation bar, wathever) but potentially each one could be totally different from the rest.

Second, I want to be able to divide the site in sections or directories to logically manage everything. For example, all the documents in a section could be showed as a list or a group. All the documents in a section could or should have common characteristics (style, templates...). But still, I want to be able to decide per-document if it is going to be in the list, with that style and so on.

All the CMSes I saw had some kind of integrated editor, that was kind of shit. I'm used to write off-line, maybe I write the same stuff ten times and sometimes after that I simply throuw it away. An off-line editor is the best for me. It also allow me to use wathever editor I want to prepare the document and then upload it when I'm satisfied.

Well, it doesn't sound like a too complicated list of whishes, does it? Only, I couldn't find any CMS that did what I wanted. Not without rewriting huge portions of them or paying a lot of money. So, in the end, I decided that if you want something done, you'll have to do it yourself. So I sat down and began writing my own CMS. The FdT (Fai Da Te = Do It Yourself).

The first draft of the CMS toke about 2 days. It didn't used a database, just plain text files. The 'CMS' did nothing but "merge" the files together and send the mashed stuff to the browser. But functionalities were really limited and required direct access to the server to add or change things. Some things were also basically impossible (comments).

Version 2.0 began right away with a database backend and a minimal backoffice interface to allow changes and updates without direct access to the server. A huge improvement, but still wasn't satisfying.

During Christmas' break I wrote version 3.0 with lots of changes. Better documents management, multiusers and a skeletal multihosting functionality. But the backoffice was still somehow lacking and the design of the database was crude and unrefined (it didn't have any foreign key).

After some time spent using the thing, I decided to do a major rehauling of the project and here cames version 4.0. The database is changed a lot, it has referential integrity, it is multi-host and multi-user and the documents are really hierarchical.

During an intense debug sessions I changed a lot of things and added support for a Javascript editor to do minor editing of stuff, this required some database changes so I bumper the version counter up to 5.0.

Version 5.1 is the actual "production" version, is also the one that is currently under maintenance. Basic characteristics:

  1. Written in perl
  2. Multihost
  3. Multilanguage
  4. Multiuser and support different authorization levels
  5. Documents with hieararchical structure
  6. Each document can have multiple links (url) that refers to the doc. A doc can "appear" this way in different places.
  7. Both On-Line and Off-Line editing
  8. Support CSS

There are a lot of things that I want to improve, in specific, I'd like to add some interactivity in the system, for example in the document management: I'd like to do drag & drop of a document from a directory in my pc to the system and get the "upload" window. Or move a document from one group to another in the same way.

As said, the whole CMS is written in Perl. I wrote it using 5.8.8, but I've also tested it on OpenBSD with 5.10 and had no trouble. Why did I picked perl? Because 90% of CMSes out there are written in PHP. And that means that 90% of jackasses that could think to came here and annoy me knows PHP. So picking a different language is a fast and easy way to get rid of 90% of the problem already.

I decided to split the system in 2: the cms properly named is the part that grab wathever the user type in the address bar, recover the document, apply a template put everything together and send it back to the user, and then there is the backoffice, that is the part used by me to add and manage the content of the site. This allow me to reduce the risk of having an 'active' site: in the 'cms' there are no "update" to use to add stuff to the system.

There are some common parts, some functions that are used by both parts. All in all, is just an half a dozen perl scripts.

To do antispam and check of the comments I used SpamAssassin with a couple of custom-made rules. So far, just 3 or 4 comments managed to get through. And since I always do the final check by hand, no spam-comment reached the web yet.

As a "search engine" I decided to use Swish, because it has a built-in Perl interface so I can easily integrate it. This unfortunately means that you'll need to install Swish libraries too and you'll need a cronjob to keep its indexes up-to-date. Unfortunately, it seems that Swish is no longer maintained, so I think I'll have to figure out something else for the future.

After a lot of thinking, I've decided to implemente CKEditor as an "integrated editor" to modify documents and other text content. The version I've used is 4.0 but it should also be working with the 5. I've also decided to "extend" the Image plugin to allow insertion of the images that are already into the CMS directly into the editing window.

Unfortunately, CK has the bad attitude of removing all the "class" definition from its text, this means that if you are using a very complex HTML with lots of <div class=...>, you'll have problems. It is in these situation that the off-line editing cames to the rescue. Download the text, edit it in whatever editor you like and the re-upload it. Sometimes is even faster.

In my conception, the document is the King. The document contain the main text and content of the page, what al the users wants to see. The rest is just around the document to let it display.

This approach shows in the fact that 90% of the system is devoted to manage documents and the rest is for support functions. However, you need to have the support bits in place before you can start adding documents.

Let's see a practical example. Let's supposed you did installed the system and want to test it. You begin by adding an host, that is, a site. Once done that, you need to create a template, that is nothing more than an HTML page where you specify where the various bits are going to be, using <div> or <table> or wathever.

Once you have these, you can add a document and 'attach' the template. Only at this point you can see the resulting document. Change the template and the document changes.

The same document can be in more languages. The cms look up the document in one of the language that the user's browser accept. If no document matches, the default one is returned.

A template can be applied to the generation of lists and directories too. This way is possible to personalize how the various lists are displayed on the page.

Some portion of a page are common to other pages (title, navigation bar, disclaimers...) these 'fragments' are managed separtely from the document and the template, this way you can have multiple version in different languages. To manage even smaller elements (single words) the default texts are used.

To piece together all the bits, the cms understand metatags, that looks like html comment but are processed by the CMS and replaced with documents and other informations coming from the database.

In the CMS documentation (distributed as a site and available on line) there is a list with all the metatags and their meaning.

Version 5.1 is on SourceForge. I have to say that put the file on sourceforge has been a pain in the ass, I really don't like their interface. Anyhow, I kept a copy here.

Before beginning, I suggest you RTFM, especially the part about required perl modules. During the debugging I've installed it on many virtual servers, installed from scratch and I had no trouble installing the required modules. Recently I used CentOS 7 and found everything in Yum repositories, with one exception that required EPEL, for the rest it was done in 10 minutes.

The required Perl modules are:

The easiest way to see if your kit is complete or not is to try to run or from the command-line If it works, you should be set. If you get errors about missing stuff, install the required modules and try again.

You'll also need a database (MySQL or Postgre, I prefer Postgre) and the corresponding Perl dbi modules.

If you are using version 5.0 you'll need to change ONE index in ONE table. I've modified the documentcontent table to allow the insertion of different versions of the same document with the same title. To upgtade there is one script in the scripts directory.

For some strange reason I'm thinking about java now... Maybe I'm getting old...

Anyhow, I'll move all the discussions to the CMS web site, this article remains as a connection between the two.

Comments are added when and more important if I have the time to review them and after removing Spam, Crap, Phishing and the like. So don't hold your breath. And if your comment doesn't appear, is probably becuase it wasn't worth it.

7 messages this document does not accept new posts
mfiskPossibile integrazione By mfisk - posted 14/10/2009 09:43
Per festeggiare il seicentesimo utente, potresti integrare un'utile funzioncina, vale a dire la scelta della lingua di visualizzazione. Io uso Opera con la visualizzazione di default [en], e non c'è modo (o non l'ho scovato) di accedere alle tue pagine in italiano, se non andando a cambiare le impostazioni globali ogni volta che voglio leggerti. Cosė, sono costretto a visualizzare il sito con IE, e ciò è MALE.


Davide Bianchi@ mfisk By Davide Bianchi - posted 14/10/2009 10:08

> accedere alle tue pagine in italiano

Le pagine sono sempre visualizzate se manca l'equivalente in inglese e se tu ti configuri il browser per leggere le pagine in INGLESE devo supporre che tu LE VOGLIA in inglese, altrimenti cambiati le impostazioni del browser. E se il tuo browser non ti consente di scegliere quale lingua vuoi senza dover cambiare le impostazioni di tutto il sistema operativo o cambi browser o cambi sistema operativo.

Davide Bianchi

MarcoCMS FdT 4.0 By Marco - posted 10/03/2010 17:30

Ciao, volevo utilizzare il tuo CMS e ho provato ad installarlo su macchina virtuale.
L'ho installato come da istruzioni ma qualcosa non funzionava con il il modulo e ho visto che necessita di SWING::API.
Sulla Ubuntu Server da me utilizzata ho installato il corrispondente pacchetto (swing-e) e tutto pare andare. Con un po' di tempo cercherò di imparare...
Eventualmente, se ritieni, integra le dipendenze necessarie al funzionamento nella guida all'installazione.


Davide Bianchi@ Marco By Davide Bianchi - posted 10/03/2010 19:59

> e ho visto che necessita di SWISH::API.

Swish l'ho aggiunto solo dopo quando ho visto che il motore di ricerca lasciava molto a desiderare.
Aggiornero' la documentazione.

Davide Bianchi

Alessandro Porcu By Alessandro Porcu - posted 12/04/2012 15:33

Installato su Gentoo va che e' una favola. Ho solo il problema di ripristinarecommenti che c'erano sul vecchio wordpress, al limite me li riscrivo a manella.

Grande BigD !!

Alessandro Porcu

Gandolfo Ivo By Gandolfo Ivo - posted 17/11/2012 23:50

Ciao BigD, mi appello alla tua Grande Saggezza per un quesito che mi attanaglia.

Ho provato a usare il tuo cms, con un discreto risultato, solo un piccolo appunto: farebbe molto comodo avere un editor online per i doc oltre che per i template, ho visto che tempo fa avevi messo FCKeditor (dalle note del SVN) ma poi lo hai tolto. Un'altra soluzione per integrare un editor c'è, oppure devo copia-incollare la funzione di edit dei template e usarla anche per i doc?

a little sysadmin from h3ll

Davide Bianchi@ Gandolfo Ivo By Davide Bianchi - posted 20/11/2012 15:06

farebbe molto comodo avere un editor online per i doc

Ho abbandonato l'editor on-line per molte cose, avevo provato con fckeditor (ora ckeditor e basta) perche' non mi soddisfava molto, potresti riaggiungerlo se vuoi madonnare.

Davide Bianchi

7 messages this document does not accept new posts

Previous Next

Davide Bianchi, works as Unix/Linux administrator for an hosting provider in The Netherlands.

Do you want to contribute? read how.  

This site is made by me with blood, sweat and gunpowder, if you want to republish or redistribute any part of it, please drop me (or the author of the article if is not me) a mail.

This site was composed with VIM, now is composed with VIM and the (in)famous CMS FdT.

This site isn't optimized for vision with any specific browser, nor it requires special fonts or resolution.
You're free to see it as you wish.

Web Interoperability Pleadge Support This Project
Powered By Gojira