# Requirements

To run Morfy you simple need PHP 5.3.0 or higher with PHP's Multibyte String module.
Operation system: Unix, Linux, Windows, Mac OS.
Webserver: Apache with Mod Rewrite or Ngnix with Rewrite Module.


# Installation

  1. Download the latest version.
  2. Unzip the contents to a new folder on your local computer.
  3. Upload that whole folder with an FTP client to your host.
  4. You may also need to recursively CHMOD the folder /content/, /themes/ to 755(or 777) if your host doesn't set it implicitly.
  5. Also you may also need to recursively CHMOD the /config.php, /install.php, /.htaccess to 755(or 777) if your host doesn't set it implicitly.
  6. Type http://example.org/install.php in the browser.

# Content

Morfy is a flat file CMS, this means there is no administration backend and database to deal with. You simply create .md files in the "content" folder and that becomes a page.

Creating content

Morfy doesnt provide any administration backend and database to deal with. You just create .md files in the content folder and that becomes a page.


That how it looks:
Physical LocationURL
content/index.md/
content/sub.md/sub
content/sub/index.md/sub (same as above)
content/sub/page.md/sub/page
content/a/very/long/url.md/a/very/long/url


Text file markup

Text files are marked up using Markdown Plugin. They can also contain regular HTML. At the top of text files you can place a block comment and specify certain attributes of the page.


Examples:
Title: Welcome  
Description: Some description here  
Keywords: key, words  
Author: Awilum  
Date: 2013/12/31  
Tags: tag1, tag2  
Robots: noindex,nofollow  
Template: index (allows you to use different templates in your theme)  
----


Text file vars

Write text file vars inside {} e.g. {var}

NameDescription
site_urlOutputs site url
morfy_separatorOutputs morfy separator
morfy_versionOutputs morfy version
cutPage Cut
phpFor embeded php code

# Themes

You can create themes for your Morfy installation and in the "themes" folder. To setup your theme just update theme setting in config.php

All themes must include an index.html file to define the HTML structure of the theme. You can seperate index.html to header.html and footer.html on your wish and easy include theme: <?php include 'header.html' ?> and <?php include 'footer.html' ?>


Theme structure

  • themes
    • default
      • blog.html
      • blog_post.html
      • footer.html
      • header.html
      • index.html
      • navbar.html


Theme variables

NameDescription
Config
$config['site_url']Site url
$config['site_charset']Site charset
$config['site_timezone']Site timezone
$config['site_theme']Site theme
$config['site_title']Site title
$config['site_description']Site description
$config['site_keywords']Site keywords
Page
$page['title']Page title
$page['description']Page description
$page['keywords']Page keywords
$page['tags']Page tags
$page['url']Page url
$page['author']Page author
$page['date']Page date
$page['robots']Page robots
$page['template']Page template

# Blogging

To add a "blog" to your Morfy site, please follow the steps below.

  1. Put all of your post.md files in your "content folder" "blog folder".
  2. Make sure you write/put text file markup like this on your post.md:
Title: Hello World!
Description: Some description here   
Keywords: Some keywords here  
Author: Admin
Date: January 20, 2014
Tags: Some tags here  
Template: blog_post
----
## Example heading here
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima, sunt, nisi id magni dignissimos rem dolorem aut dicta quis a officiis accusamus cum facere reiciendis quam iste laborum! Quasi, quos.
<!-- Short post to blog.html -->
{cut}
Vitae, velit, temporibus sequi mollitia dolorem voluptatibus assumenda et cumque soluta laudantium commodi odit cupiditate eos nobis quisquam obcaecati vero rerum ut.


In your blog.html do something like this:
<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
  <?php Morfy::factory()->runAction('theme_content_before'); ?>
  <?php
    $posts = Morfy::factory()->getPages(CONTENT_PATH . '/blog/', 'date', 'DESC', array('404','index'));
    foreach($posts as $post) {
      echo '<h3><a href="'.$config['site_url'].'/blog/'.$post['slug'].'">'.$post['title'].'</a></h3>                
            <p>Posted on '.$page['date'].'</p>    
            <div>'.$post['content_short'].'</div>';
    }
  ?>
  <?php Morfy::factory()->runAction('theme_content_after'); ?>
</div> <!--/.container -->
<?php include 'footer.html' ?>


In your blog_post.html do something like this:
<?php include 'header.html' ?>
<?php include 'navbar.html' ?>
<div class="container">
  <?php Morfy::factory()->runAction('theme_content_before'); ?>
  <h3><?php echo $page['title']; ?></h3>
  <p>Posted on <?php echo $page['date']; ?></p>
  <div><?php echo $page['content']; ?></div>
  <div><?php echo Morfy::factory()->runAction('myContact'); ?></div>
  <?php Morfy::factory()->runAction('theme_content_after'); ?>
  <hr>
</div> <!--/.container -->
<?php include 'footer.html' ?>



# Config

You can set your own site title, keywords, description and etc.. by editing config.php in the root Morfy directory.

Default config.php
<?php
  return array(
    'site_url' => 'http://example.org/',
    'site_charset' => 'UTF-8',
    'site_timezone' => 'UTC',
    'site_theme' => 'default',
    'site_title' => 'Site title',
    'site_description' => 'Site description',
    'site_keywords' => 'site, keywords',
    'email' => 'admin@admin.com',
    'plugins' => array(
    'markdown',
    'sitemap',
  ),
);

# Plugin

You can create plugins in the "plugins" folder. To setup your plugin just update plugins setting in config.php

Morfy provides simple API to develope plugins.


Available public methods:
/**
 * Factory method making method chaining possible right off the bat.
 *
 *  <code>
 *      $morfy = Morfy::factory();
 *  </code>
 *
 * @access  public
 */
public static function factory()
/**
 * Run Morfy Application
 *
 *  <code>
 *      Morfy::factory()->run($path);
 *  </code>
 *
 * @param string $path Config path
 * @access  public
 */
public function run($path)
/**
 * Get Url
 *
 *  <code>
 *      $url = Morfy::factory()->getUrl();
 *  </code>
 *
 * @access  public
 * @return string
 */
public function getUrl()
/**
 * Get Uri Segments
 *
 *  <code>
 *      $uri_segments = Morfy::factory()->getUriSegments();
 *  </code>
 *
 * @access  public
 * @return array
 */
public function getUriSegments()
/**
 * Get Uri Segment
 *
 *  <code>
 *      $uri_segment = Morfy::factory()->getUriSegment(1);
 *  </code>
 *
 * @access  public
 * @return string
 */
public function getUriSegment($segment)
/**
 * Create safe url.
 *
 *  <code>
 *      $url = Morfy::factory()->sanitizeURL($url);
 *  </code>
 *
 * @access  public
 * @param  string $url Url to sanitize
 * @return string
 */
public function sanitizeURL($url)
/**
 * Sanitize URL to prevent XSS - Cross-site scripting
 *
 *  <code>
 *      Morfy::factory()->runSanitizeURL();
 *  </code>
 *
 * @access  public
 * @return void
 */
public function runSanitizeURL()
/**
 * Get pages
 *
 *  <code>
 *      $pages = Morfy::factory()->getPages(CONTENT_PATH . '/blog/');
 *  </code>
 *
 * @access  public
 * @param  string  $url        Url
 * @param  string  $order_by   Order by
 * @param  string  $order_type Order type
 * @param  array   $ignore     Pages to ignore
 * @param  int     $limit      Limit of pages
 * @return array
 */
public function getPages($url, $order_by = 'date', $order_type = 'DESC', $ignore = array('404'), $limit = null)
/**
 * Get page
 *
 *  <code>
 *      $page = Morfy::factory()->getPage('downloads');
 *  </code>
 *
 * @access  public
 * @param  string $url Url
 * @return array
 */
public function getPage($url)
/**
 * Get list of files in directory recursive
 *
 *  <code>
 *      $files = Morfy::factory()->getFiles('folder');
 *      $files = Morfy::factory()->getFiles('folder', 'txt');
 *      $files = Morfy::factory()->getFiles('folder', array('txt', 'log'));
 *  </code>
 *
 * @access  public
 * @param  string $folder Folder
 * @param  mixed  $type   Files types
 * @return array
 */
public static function getFiles($folder, $type = null)        
/**
 *  Hooks a function on to a specific action.
 *
 *  <code>
 *      // Hooks a function "newLink" on to a "footer" action.
 *      Morfy::factory()->addAction('footer', 'newLink', 10);
 *
 *      function newLink() {
 *          echo '<a href="#">My link</a>';
 *      }
 *  </code>
 *
 * @access  public
 * @param string  $action_name    Action name
 * @param mixed   $added_function Added function
 * @param integer $priority       Priority. Default is 10
 * @param array   $args           Arguments
 */
/**
 * Run functions hooked on a specific action hook.
 *
 *  <code>
 *      // Run functions hooked on a "footer" action hook.
 *      Morfy::factory()->runAction('footer');
 *  </code>
 *
 * @access  public
 * @param  string  $action_name Action name
 * @param  array   $args        Arguments
 * @param  boolean $return      Return data or not. Default is false
 * @return mixed
 */
/**
 * Apply filters
 *
 *  <code>
 *      Morfy::factory()->applyFilter('content', $content);
 *  </code>
 *
 * @access  public
 * @param  string $filter_name The name of the filter hook.
 * @param  mixed  $value       The value on which the filters hooked.
 * @return mixed
 */
/**
 * Add filter
 *
 *  <code>
 *      Morfy::factory()->addFilter('content', 'replacer');
 *
 *      function replacer($content) {
 *          return preg_replace(array('/\[b\](.*?)\[\/b\]/ms'), array('<strong>\1</strong>'), $content);
 *      }
 *  </code>
 *
 * @access  public
 * @param  string  $filter_name     The name of the filter to hook the $function_to_add to.
 * @param  mixed  $function_to_add The name of the function to be called when the filter is applied.
 * @param  integer $priority        Function to add priority - default is 10.
 * @param  integer $accepted_args   The number of arguments the function accept default is 1.
 * @return boolean
 */
/**
 * Subval sort
 *
 *  <code>
 *      $new_array = Morfy::factory()->subvalSort($old_array, 'sort');
 *  </code>
 *
 * @access  public
 * @param  array  $a      Array
 * @param  string $subkey Key
 * @param  string $order  Order type DESC or ASC
 * @return array
 */