# 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: and


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.

{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:


runAction('theme_content_before'); ?> getPages(CONTENT_PATH . '/blog/', 'date', 'DESC', array('404','index')); foreach($posts as $post) { echo '

'.$post['title'].'

Posted on '.$page['date'].'

'.$post['content_short'].'
'; } ?> runAction('theme_content_after'); ?>


In your blog_post.html do something like this:


runAction('theme_content_before'); ?>

Posted on

runAction('myContact'); ?>
runAction('theme_content_after'); ?>



# Config

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

Default config.php
 '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.
 *
 *  
 *      $morfy = Morfy::factory();
 *  
 *
 * @access  public
 */
public static function factory()
/**
 * Run Morfy Application
 *
 *  
 *      Morfy::factory()->run($path);
 *  
 *
 * @param string $path Config path
 * @access  public
 */
public function run($path)
/**
 * Get Url
 *
 *  
 *      $url = Morfy::factory()->getUrl();
 *  
 *
 * @access  public
 * @return string
 */
public function getUrl()
/**
 * Get Uri Segments
 *
 *  
 *      $uri_segments = Morfy::factory()->getUriSegments();
 *  
 *
 * @access  public
 * @return array
 */
public function getUriSegments()
/**
 * Get Uri Segment
 *
 *  
 *      $uri_segment = Morfy::factory()->getUriSegment(1);
 *  
 *
 * @access  public
 * @return string
 */
public function getUriSegment($segment)
/**
 * Create safe url.
 *
 *  
 *      $url = Morfy::factory()->sanitizeURL($url);
 *  
 *
 * @access  public
 * @param  string $url Url to sanitize
 * @return string
 */
public function sanitizeURL($url)
/**
 * Sanitize URL to prevent XSS - Cross-site scripting
 *
 *  
 *      Morfy::factory()->runSanitizeURL();
 *  
 *
 * @access  public
 * @return void
 */
public function runSanitizeURL()
/**
 * Get pages
 *
 *  
 *      $pages = Morfy::factory()->getPages(CONTENT_PATH . '/blog/');
 *  
 *
 * @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
 *
 *  
 *      $page = Morfy::factory()->getPage('downloads');
 *  
 *
 * @access  public
 * @param  string $url Url
 * @return array
 */
public function getPage($url)
/**
 * Get list of files in directory recursive
 *
 *  
 *      $files = Morfy::factory()->getFiles('folder');
 *      $files = Morfy::factory()->getFiles('folder', 'txt');
 *      $files = Morfy::factory()->getFiles('folder', array('txt', 'log'));
 *  
 *
 * @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.
 *
 *  
 *      // Hooks a function "newLink" on to a "footer" action.
 *      Morfy::factory()->addAction('footer', 'newLink', 10);
 *
 *      function newLink() {
 *          echo 'My link';
 *      }
 *  
 *
 * @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.
 *
 *  
 *      // Run functions hooked on a "footer" action hook.
 *      Morfy::factory()->runAction('footer');
 *  
 *
 * @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
 *
 *  
 *      Morfy::factory()->applyFilter('content', $content);
 *  
 *
 * @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
 *
 *  
 *      Morfy::factory()->addFilter('content', 'replacer');
 *
 *      function replacer($content) {
 *          return preg_replace(array('/\[b\](.*?)\[\/b\]/ms'), array('\1'), $content);
 *      }
 *  
 *
 * @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
 *
 *  
 *      $new_array = Morfy::factory()->subvalSort($old_array, 'sort');
 *  
 *
 * @access  public
 * @param  array  $a      Array
 * @param  string $subkey Key
 * @param  string $order  Order type DESC or ASC
 * @return array
 */