Skip to content

Concepts

Sander van Dragt edited this page Jul 4, 2021 · 3 revisions
  • Cuttlefish framework functionality exists in the site/www/system folder.
  • Cuttlefish\blog functionality exists in the site/www/application folder. Cuttlefish is not limited to blogs, and the blog application will be split off to enforce this separation.

Model, View, Controller

Cuttlefish follows the established data model, template view, logic controller pattern (MVC).

Data Models

Cuttlefish supports any number of data models. These all extend Cuttlefish\Model. Sections of content are rendered by transformations and assigned to fields that are called later by templates.

The Blog application comes with:

  • ModelPage: a page consist only of markdown. Pages are also used for error pages.
  • ModelPost: a post consist of a metadata section and a markdown section. A blog has posts with published date (published:) and tags (not yet implemented).
  • ModelFile: reads files present on the system, for example image files.

Sections are separated by two blank lines. Data models can be used by many controllers (the home, archive and posts controller all load posts, for example):

Logic Controllers

Controllers are attached to Routes and hook up data using the data model to the template views.

Blog controllers load data from the contentPath as records. They then pass the records through the data model. The contents are then passed into the template.

Request object:

  • Cache
  • Log
  • Environment
  • Controller
    • Records
    • Model
    • View

Controllers:

  • Home (posts) default homepage
  • Admin (no model) administration section
  • Archive (posts) post archive
  • Errors (page) custom error pages
  • Feeds (posts) feed of posts
  • Images (file) content images
  • Pages (page) individual pages
  • Posts (post) individual posts

Model types:

  • File (present bare file)
  • Page (structure for pages)
  • Post (structure for posts)

View types:

  • Html (templated content)
  • Feed (xml representation)
  • File (download)

Blog Application

Posts are listed in the index page. Pages contain a section of YAML followed by Markdown, by default.
Pages just contain markdown content, by default. In the basic theme, pages are linked from the footer.
Configuration settings override the defaults.
Manage your data models and theming logic using the MVC classes in the site/www/application folder.

Clone this wiki locally