← Alle berichten

A CMS whose whole API is three functions

The CMS moves into a package of its own with its own source path, and gets smaller doing it. The public interface is three functions: main() wraps a page in the layout, CMS() renders a model as a list, a record or a form, and field() makes a field.

Everything else follows from the model describing itself:

static objTable = 'cats'
static objFields => arr (
    name: field (
        type: 'text',
        title: 'Naam',
        search: true,
        required: true,
    ),
)

From that one declaration come the list columns, the search behaviour, the edit form, the validation, and the CREATE TABLE statement. A model that knows its own fields does not need a second description of them for the admin and a third for the schema.

The reason to split it out is that an admin interface is opinionated in ways a runtime must not be. It decides what a list looks like and what a permission means, and those decisions belong in a package you choose rather than in something every app inherits whether it wants an admin or not.

It earns the split immediately, with two applications running on it from different directions: a pedigree and breeding registry, and a general content site. Same three functions, two products that look nothing alike.

We gebruiken essentiële cookies om deze site te laten werken. Met uw toestemming gebruiken we ook analytics om de site te verbeteren.