dinky-cms

Dinky CMS is a Java Spring Boot Content Management Microservice. It is REST API first.

This project is maintained by schicwp

Back

Content Modeling

In modeling content, you define the structure of content objects that you will work with.

For example, if you are working on a news website, you may need a NewsArticle content type to represent news items, and a PressRelease content type to represent non-news information items that will appear on the site.

Content types are specified in a YAML document in the types directory. The YAML document declares a type name, the workflows that govern the content, and a set of fields that comprise the content object.

In the JellyBean example is below:

name: JellyBean
workflows:
  - JellyBeanWorkflow
fields:
  - name: flavor
    type: String
    config:
      maxLength: 10

  - name: color
    type: String
    config:
      allowedValues:
        - red
        - green
        - blue

The this example, the type is name JellyBean, and it is subject to the rules defined in the JellyBeanWorkflow. It has two fields, a flavor and a color, which are both String fields. The flavor field can have a max length of 10 characters, and the color must be one of red, green or blue.

Content Field Configuration

A field must have a name and type and can optionally be indexed or required. Each type of field can have custom options, in a yaml map called config.

An indexed field will have a DB index built to search it. If you plan on searching based on a simple field often, it should probably be indexed ( This does have a per-field storage and write performance penalty though - if you need to search a lot of fields, or do full text searching, consider using the search feature ).

A required field requires a non-null value.

  - name: flavor
    type: String
    required: true
    indexed: true
    config:
      maxLength: 10


Field Type Reference

String

Holds a string.

Config options:

param description
regex a regex to validate the string
allowedValues a list of values that the string may be
minLength the min length of the string
maxLength max length of the string

Int

Holds an integer.

Config options:

param description
min min value
max max value

Date

Holds a date/time object.

Binary

Holds a binary file - this can be used for images, attachments, etc.

Collection

This contains a collection of other items. The items it contains can be any other field type.

Config options:

param description
collectionType (required) a field configuration which defines the type of items in the collection

Example:

  - name: collectionOfStuff
    type: Collection
    config:
      collectionType:
        type: String
        config:
          maxLength: 49
          minLength: 20
          regex: "[a-z]*"
          

ObjectRef

A reference to another content object, by id.

param description
referencedType (optional) the type of object referenced. If not there, any type of object can be referenced

Adding field types

See the Extending for information on custom field types.

Back