2017 © Pedro PelĂĄez
 

library additeasy

PSR-7 compatible flat-file CMS

image

bitexpert/additeasy

PSR-7 compatible flat-file CMS

  • Saturday, July 1, 2017
  • by shochdoerfer
  • Repository
  • 10 Watchers
  • 7 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

bitexpert/additeasy

addItEasy is a PSR-7 compatible flat-file CMS and static site generator written in PHP., (*1)

Installation

The preferred way of installing bitexpert/additeasy is through Composer. Simply add bitexpert/additeasy as a dependency:, (*2)

composer.phar require bitexpert/additeasy

To initialize a new project simply call the init command of the provided addItEasy cli tool:, (*3)

./vendor/bin/addItEasy init

Add a template

addItEasy uses Twig as templating engine. Create a template named "default.twig" in the templates folder like this:, (*4)

<!DOCTYPE html>
<html lang="en">
<head>
    <title>{{ site.title }}</title>
    <base href="http://localhost:8080/" />
</head>
<body>


{% block content %}
{% endblock %}

</body>
</html>

Adding content

Content files need to placed in the content directory. Content files are basically Twig files which provide the blocks required by the template., (*5)

{% extends "default.twig" %}

{% block content %}


Hello World!
{% endblock content %}

Every page of your site is represented by a subfolder in the content directory. The folder names build the URL structure for your site, nested subfolders are allowed. Each folder needs to be prefixed with a number which is used to indicate the sorting order. Each folder needs to contain one twig template file containing the content to display., (*6)

The content folder could look like this:, (*7)

  |-01-home
  |---home.twig
  |-02-about
  |---about.twig
  |-posts
  |---01-post1
  |-----post1.twig
  |---02-post2
  |-----post2.twig
  |---03-post3
  |-----post3.twig
  |---04-post4
  |-----post4.twig  

Twig helper functions

The current page object gets exposed as a variable named "page" in the template, the $EASY_CONF["site"] configuration array gets exposed as variable named "site". In addition to that addItEasy exposes 3 helper functions to "interact" with the content pages., (*8)

The children($pagename) function takes a page name as an argument and returns the child pages., (*9)

{% for post in children('posts') %}
    {{ post.getName() }}
{% endfor %}

The siblings($pagename) function takes a page name as an argument and returns all sibling pages including the current page., (*10)

{% for mainnav in siblings('home') %}
    {{ mainnav.getName() }}
{% endfor %}

The pageblock($page, $blockname) function takes a page object as first argument and the name of the block to render as a second argument., (*11)

{% for post in children('posts') %}
    {{ pageblock(post, 'title') }}
{% endfor %}

Running addItEasy

Running addItEasy as a flat-file CMS

In case you want to run addItEasy locally the following command needs to be executed in the project directory:, (*12)

php -S 0.0.0.0:8080 -t .

Open a web browser and point it to http://localhost:8080 so see addItEasy in action., (*13)

Running addItEasy as a static site generator

To export static HTML pages run the export command od the provided addItEasy cli tool:, (*14)

./vendor/bin/addItEasy export

The HTML files as well as the assets will get exported to the folder specified in the project configuration., (*15)

License

addItEasy is released under the Apache 2.0 license., (*16)

The Versions

01/07 2017
23/07 2016