Mecha CMS

Mecha CMS blog and documentation.

Version 1.2.0

Updated: Sunday, 07 August 2016

Changelog in Mecha 1.2.0.

Added

  • Constant
    • COMMENT
    • ENGINE
    • POST
    • WORKER
  • Method
    • Converter::DS()
    • Converter::DW()
    • Converter::ES()
    • Converter::EW()
    • Date::slug()
    • Date::timezone()
    • Filter::colon()
    • Filter::removed()
    • Get::articleTag()
    • Get::closestFiles()
    • Get::closestFolders()
    • Get::commentAnchor()
    • Get::commentHeader()
    • Get::commentPath()
    • Get::folders()
    • Get::pageTag()
    • Get::post()
    • Get::postAnchor()
    • Get::postExtract()
    • Get::postHeader()
    • Get::postPath()
    • Get::posts()
    • Get::postsExtract()
    • Get::response()
    • Get::responseAnchor()
    • Get::responseExtract()
    • Get::responseHeader()
    • Get::responsePath()
    • Get::responses()
    • Get::responsesExtract()
    • Guardian::hash()
    • Guardian::wizard('foo') → replaces Config::speak('file:foo')
    • HTTP::query()
    • Image::inspect()
    • Menu::add()
    • Menu::remove()
    • Menu::exist()
    • Notify::bare()
    • Package::deleteFolder()
    • Package::deleteFolders()
    • Package::inspect()
    • Package::read()
    • Plugin::exist()
    • Plugin::reload()
    • Route::accepted()
    • Route::overed()
    • Route::rejected()
    • Shield::chunk()
    • Shield::exist()
    • Weapon::ejected()
    • Widget::exist()
    • Widget::plug()
    • Widget::recentResponse()
    • Widget::remove()
  • Weapon
    • comment_form_button_after
    • comment_form_button_before
    • comment_form_input_after
    • comment_form_input_before
    • comment_form_textarea_after
    • comment_form_textarea_before
    • on_comment_notify_construct
  • Filter
    • archive:url
    • asset:input
    • asset:output
    • asset:path
    • asset:source
    • chunk:input
    • chunk:output
    • chunk:lot
    • chunk:path
    • index:url
    • manager:url
    • navigation:url
    • pager:anchor
    • pager:next.anchor
    • pager:prev.anchor
    • pager:step.anchor
    • pager:step.html
    • search:url
    • shield:input
    • shield:output
    • state:config
    • state:field
    • state:menu
    • state:shortcode
    • state:tag
    • tag:url
  • Parser
    • to_safe_folder_name
    • to_safe_path_name
    • to_title

Removed

  • Constant
    • ASSET_VERSION_FORMAT
    • DECK
    • HTML_PARSER
    • SEPARATOR_ENCODED
    • SYSTEM → replaced by ENGINE
  • Method
    • Get::adjacentFiles() → replaced by Get::closestFiles()
    • Get::inclusiveAdjacentFiles()
    • Get::inclusiveFiles()
    • Image::getInfo() → replaced by Image::inspect()
    • Menu::get()
    • Package::getContent() → replaced by Package::read()
    • Package::getInfo() → replaced by Package::inspect()
    • Text::ES() → replaced by Converter::ES()
    • Text::DS() → replaced by Converter::DS()
    • Widget::recentComment() → replaced by Widget::recentResponse()
  • Weapon
    • comment_form_input → replaced by comment_form_input_after
    • comments_footer
    • on_comment_notification_construct → replaced by on_comment_notify_construct
  • Filter
    • manager:bar
    • manager:bar.item
    • manager:list → replaced by manager:trunk and manager:branch
    • manager:list.item → replaced by manager:twig
    • manager:list.item.separator
    • navigation:list → replaced by navigation:trunk and navigation:branch
    • navigation.list.item → replaced by navigation:twig
    • navigation.list.item.separator
    • pager:link → replaced by pager:anchor
    • pager:next.link → replaced by pager:next.anchor
    • pager:prev.link → replaced by pager:prev.anchor
    • pager:step.link → replaced by pager:step.anchor
    • sanitize:input → replaced by shield:input
    • sanitize:output → replaced by shield:output
    • shield:cache

Updated

  • Method
    • Almost all.
  • Weapon
    • on_comment_construct
  • Parser
    • to_text → now accept HTML input

Safe Template Loader

Added Shield::chunk() method for loading template files safely. In version 1.2.x, users will be able to simplify the shield content markup into something like this:

<?php Shield::chunk('header'); ?>
<?php Shield::chunk('sidebar'); ?>
<div class="blog-main posts">
  <article class="post" id="post-<?php echo $article->id; ?>">
    <?php Shield::chunk('article.header'); ?>
    <?php Shield::chunk('article.body'); ?>
    <?php Shield::chunk('article.footer'); ?>
  </article>
  <?php Shield::chunk('pager'); ?>
  <?php Shield::chunk('comments'); ?>
</div>
<?php Shield::chunk('footer'); ?>

Related: Shield Chunks in Mecha 1.2.x

Substance Data Output

Attachment files will now be stored in a structured way based on the file extension respectively. Substance data in the page file will be stored as a file name, but will be converted into a full private file path in the output:

Input:

Title: My Sample Page
Description: "Description for my sample page."
Author: Taufik Nurrohman
Content Type: Markdown
Fields: {"header_image":"image-1.jpg"}

Output:

array(
    'title' => 'My Sample Page',
    'description' => 'Description for my sample page.',
    'author' => 'Taufik Nurrohman',
    'content_type' => 'Markdown',
    'fields' => array(
        'header_image' => '.\www\lot\extends\substance\jpg\image-1.jpg'
    )
)

Method Changes in Menu Class

A new class called Tree has been added to generalize the Menu class, in consideration that a menu doesn’t always refer to a list item.

This is how to create menus before Mecha 1.2.x:

echo Menu::get(array(
    'Home' => '/',
    'About' => '/about',
    'Contact' => '/contact'
), 'ul');

This is how to create menus in Mecha 1.2.x:

// Register
Menu::add('navigation', array(
    'Home' => '/',
    'About' => '/about',
    'Contact' => '/contact'
));

// Print
echo Menu::navigation('ul');

Related: Class Menu

Method Changes in Notify Class

Before 1.2.0, creating a custom notification message can be done like this, which is dirty in my opinion:

Notify::add('foo', 'Hello!', '<i class="icon-bar"></i> ', 'p');

In version 1.2.0, you need to perform a single step of registration prior to custom notification method usage:

// Register
Notify::plug('my_custom_message', function($text, $icon = 'bell-o') {
    Notify::bare($text, $icon, 'custom-class');
});

// Usage
Notify::my_custom_message('Hello there!');

// Print
echo Notify::read();

To create a custom notification message without any registration steps, you can use the Notify::bare() itself. Or, to make it looks more raw, you can use Notify::add(). But still, these are dirty:

Notify::bare('Hello there!', 'check', 'custom-class');
Notify::add('custom-class', '<i class="fa fa-fw fa-check"></i> Hello there!');

Related: Class Notify

Method Changes in Shield Class

Before 1.2.0, Shield::attach() method has some function parameters includes:

Shield::attach($name, $minify, $cache, $expire);

In version 1.2.0, this method will only contains three parameters:

Shield::attach($name, $fallback, $buffer);

Related: Class Shield

No More *::configure() Methods

Keep everything as simple as possible:

File::$config['file_extension_allow'] = array('css', 'js');

Optional Features

Some features that available by default in the older version of Mecha are now become optional, as plugins, which you can enable or disable it as you like, or even remove it completely:

  • Asset Versioning
  • Backup
  • Cache
  • Comment Location
  • Comment Notification
  • HTML Minifier
  • Live Preview
  • Markdown Parser
  • {{php}} Shortcode
  • Site Manager
  • Text Editor

Page States

Post

Before 1.2.x:

  • published
  • draft
  • archive

In 1.2.x:

  • published
  • drafted
  • archived

Response

Before 1.2.x:

  • approved
  • pending

In 1.2.x:

No changes.

User Statuses

In 1.2.x, all users status will be stored in the page file as a number. These numbers, then will be replaced by the user:status and comment:status filter in the output:

  • 0intruder
  • 1pilot
  • 2passenger

Output Changes in Navigator Class

Before 1.2.x:

$pager
 │
 ├── prev:
 │   ├── url: https://mecha-cms.com/2016/home
 │   ├── text: Home
 │   └── link: ""
 ├── next:
 │   ├── url: https://mecha-cms.com/2016/foo/bar/2
 │   ├── text: Older
 │   └── link: <a href="https://mecha-cms.com/2016/foo/bar/2" rel="next">Older</a>
 └── step:
     ├── url:
     │   ├── false
     │   ├── https://mecha-cms.com/2016/foo/bar/2
     │   ├── https://mecha-cms.com/2016/foo/bar/3
     │   └── https://mecha-cms.com/2016/foo/bar/4
     └── link: <span class="pagination"> … </span>

In 1.2.x:

$pager
 │
 ├── prev:
 │   ├── url: https://mecha-cms.com/2016/home
 │   └── anchor: ""
 ├── next:
 │   ├── url: https://mecha-cms.com/2016/foo/bar/2
 │   └── anchor: <a href="https://mecha-cms.com/2016/foo/bar/2" rel="next">Older</a>
 └── step:
     ├── url:
     │   ├── first: false
     │   ├── prev: false
     │   ├── 1: false
     │   ├── 2: https://mecha-cms.com/2016/foo/bar/2
     │   ├── 3: https://mecha-cms.com/2016/foo/bar/3
     │   ├── 4: https://mecha-cms.com/2016/foo/bar/4
     │   ├── 5: https://mecha-cms.com/2016/foo/bar/5
     │   ├── next: https://mecha-cms.com/2016/foo/bar/2
     │   └── last: https://mecha-cms.com/2016/foo/bar/5
     ├── anchor:
     │   ├── first: <span>First</span>
     │   ├── prev: <span>Previous</span>
     │   ├── 1: <strong class="current">1</strong>
     │   ├── 2: <a href="https://mecha-cms.com/2016/foo/bar/2">2</a>
     │   ├── 3: <a href="https://mecha-cms.com/2016/foo/bar/3">3</a>
     │   ├── 4: <a href="https://mecha-cms.com/2016/foo/bar/4">4</a>
     │   ├── 5: <a href="https://mecha-cms.com/2016/foo/bar/5">5</a>
     │   ├── next: <a href="https://mecha-cms.com/2016/foo/bar/2" rel="next">Next</a>
     │   └── last: <a href="https://mecha-cms.com/2016/foo/bar/5">Last</a>
     └── html: <span class="pagination"> … </span>

Scope Property in Tag Data

Just like the custom fields, tag data are now also have scope property to make it possible to load tags data of specific post type in the future.

posts
 │
 ├── article
 └── page

Added more tag data getter:

  • Get::tags() ← the base tag getter (load all)
  • Get::articleTags() ← get all tags scoped to article
  • Get::pageTags() ← get all tags scoped to page
  • Get::tag() ← the base single tag getter (load all)
  • Get::articleTag() ← get a tag scoped to article
  • Get::pageTag() ← get a tag scoped to page

Menu Manager Improvement

User now can add more than one menu group.

Tag Manager Improvement

Added better form for tag management.

Page Types

The home page type in 1.2.x will be replaced by an empty value:

if($config->page_type === "") {
    echo 'We are in the home page.';
}

Download Mecha v1.2.0

Donation and Email Subscription