Mecha CMS

File and folder structure.

Shield

Table of Content

WTF is shield?

Shield is a term used by Mecha to express theme in other CMS.

A shield is a folder with a unique name, stored in lot\shield folder:

lot\
└── shield\
    ├── document\
    ├── shield-1\
    ├── shield-2\
    ├── …
    └── …

A standard shield should at least contains files that structured like this:

shield-1\
├── asset\
│   ├── .htaccess
│   ├── css\
│   │   ├── shield-1.css
│   │   └── shield-1.min.css
│   └── js\
│       ├── shield-1.js
│       └── shield-1.min.js
├── state\
│   └── config.php
├── 404.php
├── about.page
├── footer.php
├── header.php
├── index.php
├── page.php
└── pages.php

Note: The .htaccess file is required to enable access of the asset files publicly. It only contains this command:

allow from all

Error 

Minimum requirements for 404.php file:

<?php static::header(); ?>
<p>404 not found!</p>
<?php static::footer(); ?>

Index 

This file contains custom functions used by the shield:

<?php

Asset::set('css/document.min.css');
Asset::set('js/document.min.js');

Header 

Minimum requirements for header.php file:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="<?php echo $site->charset; ?>">
    <link href="<?php echo $url; ?>/favicon.ico" rel="shortcut icon">
    <title><?php echo To::text($site->trace); ?></title>
  </head>
  <body>
    <header>
      <h1><?php echo $site->title; ?></h1>
      <p><?php echo $site->description; ?></p>
    </header>

Footer 

Minimum requirements for footer.php file:

    <footer>
      <p>&#x00A9; <?php echo $date->year; ?></p>
    </footer>
  </body>
</html>

Page 

Minimum requirements for page.php file:

<?php static::header(); ?>
<main>
  <article>
    <h3><?php echo $page->title; ?></h3>
    <div><?php echo $page->content; ?></div>
  </article>
  <nav><?php echo $pager; ?></nav>
</main>
<?php static::footer(); ?>

Pages 

Minimum requirements for pages.php file:

<?php static::header(); ?>
<main>
  <?php if ($pages): ?>
  <?php foreach ($pages as $page): ?>
  <article>
    <h4><a href="<?php echo $page->url; ?>"><?php echo $page->title; ?></a></h4>
    <div><?php echo $page->content; ?></div>
  </article>
  <?php endforeach; ?>
  <?php else: ?>
  <p>No pages yet.</p>
  <?php endif; ?>
  <nav><?php echo $pager; ?></nav>
</main>
<?php static::footer(); ?>

About 

Minimum requirements for about.page file:

---
title: Shield Title
description: Shield description.
author: Shield Author
type: Markdown
link: 'http://example.com'
version: 1.0.0
...

Usage, external credits, etc.