/** * Set up Flight Engine (PHP micro-framework, http://flightphp.com) */ private function setup() { # base url F::set('flight.base_url', F::get('root')); # Smarty init F::register('view', 'Smarty', array(), function ($smarty) { if (env == 'dev') { $smarty->caching = 0; $smarty->force_compile = true; } $smarty->setTemplateDir('src/'); $smarty->setCompileDir('src/_smarty/templates_c/'); $smarty->setConfigDir('src/_smarty/config/'); $smarty->setCacheDir('src/_smarty/cache/'); $smarty->addPluginsDir('src/_smarty/plugins/'); }); # render templates F::map('render', function ($template, $data = array()) { F::view()->assign(array('root' => F::get('root'), 'app' => array("name" => "fastdoc", "version" => "1.0", "homepage" => "http://github.com/ray0be/fastdoc"), 'config' => F::get('config'), 'edit' => F::get('edit'), 'data' => $data)); # flashbags messages if (isset($_SESSION['flashbag'])) { F::view()->assign(array('flashbag' => $_SESSION['flashbag'])); $_SESSION['flashbag'] = null; } F::view()->display($template); }); }
F::route('GET /edit-nav/remove-category/@cat:[A-Za-z0-9_-]+', function ($cat) { Fastdoc::run('Admin\\EditNav', 'remove_category', array($cat)); }); // ######################################## \\ // ## ## ## ## // == page == \\ ## ## ## ## \\ F::route('POST /create/page', function () { Fastdoc::run('Admin\\EditNav', 'create_page'); }); F::route('GET /edit-nav/remove-page/@cat:[A-Za-z0-9_-]+/@page:[A-Za-z0-9_-]+', function ($cat, $page) { Fastdoc::run('Admin\\EditNav', 'remove_page', array($cat, $page)); }); /** * =============================================== * Page view & Page edit * =============================================== */ F::route('/@cat:[A-Za-z0-9_-]*(/@page:[A-Za-z0-9_-]+)(\\.@mode:edit)', function ($cat, $page, $mode) { Fastdoc::savePageInfos(array('cat' => $cat, 'page' => $page)); $mode = empty($mode) ? 'view' : 'edit'; Fastdoc::run('Doc\\Doc', 'page', array($mode)); }); /** * =============================================== * Public * =============================================== */ // ####################################### \\ // ## ## ## ## // == 404 == \\ ## ## ## ## \\ F::map('notFound', function () { Fastdoc::run('Core\\Core', 'error404'); });