just another flat file cms I made for my website
ffff is a flat file CMS, which is a Content Management Software using the filesystem as only database. It's aim is to enable a quick & easy creation of personnal websites.
The /public
directory contains the public content of the website.
Inside of it every folder is a page. Thus a page's URL is its folder's path (after public/
)
A page's content is rendered automaticly from the files it contains:
There are only two exceptions to this principle, each folder/page can have a parameters file and an assets folder:
params.yaml
which provides some options for each folder, like ignore files, set a different title for the page or the sort method.
The markup language used is YAML for it's human friendly syntax. (see more details in Page Configuration)assets
is where you can put content that will be used by your page but not automatically rendered./sample.params.yaml
, rename it into /params.yaml
and edit it's content. (see Main Configuration)/public
. (see Add Content)/inc/css
and your favicon in /inc/img
. (see Personalization)As it is a flat file CMS. To get started you just need to put your folders and files in the /public
directory.
However there still are some rules :
ffff
│ .gitignore
│ .htaccess
│ index.php
│ params.yaml # You will have to create it from the sample.
│ README.md
│ sample.params.yaml
│
├───inc # The files you want to include on every pages, like:
│ ├───css # your stylesheets,
│ ├───img # some images (like the favicon),
│ ├───js # a few scripts
│ └───php # and php files.
├───lib # All the php classes of the CMS.
├───public # The public directory containing your website.
├───res # Ressource files used by the CMS.
│ └───styles # styles files (css or php)
│ └───fonts # Fonts files
├───tmp # Temporary directory containing cache files.
└───tpl # The templates
├───layouts
│ default.php
└───views
li.cover.php
li.title.php
At the root of the project you can add the general configuration file: /params.yaml
It is there, for instance that you can edit the website's name.
Here are all the settings you can define inside (the order doesn't matter). There is sample of this file that you can copy and edit to create your own configuration: /sample.params.yaml
.
# general settings
site:
name: website-name
description: A description
# advanced settings
date formats:
- d/m/Y H:i:s
- d/m/Y H:i
- d/m/Y
page defaults:
cover: /inc/img/default-cover.png
sort:
- type: title | name | lastModif | date
order: asc | desc
render:
- cover | title
layout: default
assets dir: assets
external links:
arrow: true
new tab: true
# you don't really need to edit these settings
system:
public dir: public
The content is stored inside the public directory whose name can be defined in the main configuration. the default one is /public
.
To create a page, all you need to do is create a folder inside the public directory. The name of the folder will also automatically become the name of that page, but you can override it in the page parameters file. You can then add the content of this page inside this folder.
There are two possibilities to organize the content inside a page depending on the constitution of the page:
The /inc
folder provides possibilities for personalization. It will
add automatically on every pages :
/inc/css
/inc/js
/inc/img
/inc/php
In each page's folder you can add a params.yaml
configuration file :
Here are the parameters you can use in this file (the order doesn't matter):
title: Un Titre # override the automatic title of the page
cover: une-image.jpg # override the automatic cover
date: 2018-04-12 # set the date of this page
ignore: # files or folders you want to ignore
- un-fichier
- un-autre
- un-dossier
layout: test-layout # use a different PHP layout from /tpl/layouts
render: # rendering method for subpages
- title # method for subpages of level 1
- cover # method for subpages of level 2
sort: # sort method for subpages
- type: name # sort type for subpages of level 1
order: asc # sort order for subpages of level 1
- type: lastModif # sort type for subpages of level 2
order: desc # ...
custom: # custom settings
render: # custom rendering
un-fichier: cover # render `un-fichier` as a cover
sort: # custom sort : start with 'hello' then 'world' and end with '2014'
- hello
- world
- *
- 2014
bypass:
styles: true # bypass default styles
scripts: true # bypass default scripts
styles: # add stylesheets for this page
- un-fichier.css
scripts: # add scripts for this page
- un-script.js
- https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js
favicon: image.png # override the default favicon
assets dir: assets # override the default assets dir name
The assets folder is a special folder that can be created in every pages. It has a few specificities:
.css
and .js
files it contains will be automatically added to the pagefavicon.(ico|png)
file it contains will automatically override the default one~/
The name of the assets folder of each page can be defined in it's params.
The templates are stored in the /tpl
directory. There are two kinds: the layouts
and the views
.
A layout is the general structure of a page, you will most likely use only one for every page. One is allready there with the sources and is used by default: default.php
.
To use another template by default you must add a PHP file in /tpl/layouts
and add it in your main params.yaml
(see Main Configuration).
You can also use a layout for a specific page, just edit the page's configuration.
The views are the differents ways to render the elements of a page. Views have a notation rule:
<type>.<name>.php
For example a list item view named title will be li.title.php
Each time a page is rendered, ffff will generate a cache for this page to speed up the future renderings.
Each time a page is shown, ffff will check in the cache (/tmp
) if a cache exists for this page. If id does then no need to render it, it is served directly from the cache. If it doesn't or if it is outdated, then the page will be rendered again.
There is command to efficiently clear the cache:
bin/console cache clear
See also the list of contributors who participated in this project.