Exemple #1
0
 */
Route::accept('/', function () use($config, $excludes) {
    Session::kill('search.query');
    Session::kill('search.results');
    $s = Get::articles();
    if ($articles = Mecha::eat($s)->chunk(1, $config->index->per_page)->vomit()) {
        $articles = Mecha::walk($articles, function ($path) use($excludes) {
            return Get::article($path, $excludes);
        });
    } else {
        $articles = false;
    }
    Filter::add('pager:url', function ($url) {
        return Filter::apply('index:url', $url);
    });
    Config::set(array('articles' => $articles, 'pagination' => Navigator::extract($s, 1, $config->index->per_page, $config->index->slug)));
    Shield::attach('page-home');
}, 110);
/**
 * Route Hook: after
 * -----------------
 */
Weapon::fire('routes_after');
/**
 * Do Routing
 * ----------
 */
Route::execute();
/**
 * 404 Page
 * --------
Exemple #2
0
 * ------------
 */
Route::accept(array($config->manager->slug . '/(' . $post . ')', $config->manager->slug . '/(' . $post . ')/(:num)'), function ($segment = "", $offset = 1) use($config, $speak) {
    $posts = false;
    $offset = (int) $offset;
    $s = call_user_func('Get::' . $segment . 's', strtoupper(Request::get('order', 'DESC')), Request::get('filter', ""), 'txt,draft,archive');
    if ($files = Mecha::eat($s)->chunk($offset, $config->manager->per_page)->vomit()) {
        $posts = Mecha::walk($files, function ($v) use($segment) {
            return call_user_func('Get::' . $segment . 'Header', $v);
        });
    } else {
        if ($offset !== 1) {
            Shield::abort();
        }
    }
    Config::set(array('page_title' => $speak->{$segment . 's'} . $config->title_separator . $config->manager->title, 'pages' => $posts, 'offset' => $offset, 'pagination' => Navigator::extract($s, $offset, $config->manager->per_page, $config->manager->slug . '/' . $segment), 'cargo' => 'cargo.post.php'));
    Shield::lot(array('segment' => $segment))->attach('manager');
});
/**
 * Post Repairer/Igniter
 * ---------------------
 */
Route::accept(array($config->manager->slug . '/(' . $post . ')/ignite', $config->manager->slug . '/(' . $post . ')/repair/id:(:num)'), function ($segment = "", $id = false) use($config, $speak, $response) {
    $units = array('title', 'slug', 'link', 'content', 'content_type', 'description', 'post' . DS . 'author');
    foreach ($units as $k => $v) {
        Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak, $v) {
            include __DIR__ . DS . 'unit' . DS . 'form' . DS . $v . '.php';
        }, $k + 1);
    }
    $units = array('css', 'js');
    foreach ($units as $k => $v) {
Exemple #3
0
            if (strpos(File::N($v), $filter) === false) {
                unset($takes[$k]);
            }
        }
    }
    if ($_files = Mecha::eat($takes)->chunk($offset, $config->per_page * 2)->vomit()) {
        $files = array();
        foreach ($_files as $_file) {
            $files[] = File::inspect($_file);
        }
        $files = Mecha::eat($files)->order('ASC', 'path')->vomit();
        unset($_files);
    } else {
        $files = false;
    }
    Config::set(array('page_title' => $speak->assets . $config->title_separator . $config->manager->title, 'offset' => $offset, 'files' => $files, 'pagination' => Navigator::extract($takes, $offset, $config->per_page * 2, $config->manager->slug . '/asset'), 'cargo' => DECK . DS . 'workers' . DS . 'cargo.asset.php'));
    Shield::lot('segment', 'asset')->attach('manager', false);
});
/**
 * Asset Repair
 * ------------
 */
Route::accept($config->manager->slug . '/asset/repair/(file|files):(:all)', function ($path = "", $old = "") use($config, $speak) {
    if (Guardian::get('status') !== 'pilot') {
        Shield::abort();
    }
    $old = File::path($old);
    $p = Request::get('path');
    $p = $p ? '?path=' . urlencode($p) : "";
    if (!($file = File::exist(ASSET . DS . $old))) {
        Shield::abort();
    if ($files = Get::comments(null, 'DESC', 'txt,hold')) {
        $comments = array();
        $comments_id = array();
        foreach ($files as $file) {
            $parts = explode('_', File::B($file));
            $comments_id[] = $parts[1];
        }
        rsort($comments_id);
        foreach (Mecha::eat($comments_id)->chunk($offset, $config->manager->per_page)->vomit() as $comment) {
            $comments[] = Get::comment($comment);
        }
        unset($comments_id, $files);
    } else {
        $comments = false;
    }
    Config::set(array('page_title' => $speak->comments . $config->title_separator . $config->manager->title, 'offset' => $offset, 'responses' => $comments, 'pagination' => Navigator::extract(Get::comments(null, 'DESC', 'txt,hold'), $offset, $config->manager->per_page, $config->manager->slug . '/comment'), 'cargo' => DECK . DS . 'workers' . DS . 'cargo.comment.php'));
    Shield::lot('segment', 'comment')->attach('manager', false);
});
/**
 * Comment Repair
 * --------------
 */
Route::accept($config->manager->slug . '/comment/repair/id:(:num)', function ($id = "") use($config, $speak) {
    if (Guardian::get('status') !== 'pilot' || !($comment = Get::comment($id))) {
        Shield::abort();
    }
    if (!isset($comment->content_type)) {
        $comment->content_type = $config->html_parser;
    }
    File::write($config->total_comments_backend)->saveTo(SYSTEM . DS . 'log' . DS . 'comments.total.log', 0600);
    Config::set(array('page_title' => $speak->editing . ': ' . $speak->comment . $config->title_separator . $config->manager->title, 'response' => Mecha::A($comment), 'cargo' => DECK . DS . 'workers' . DS . 'repair.comment.php'));
Exemple #5
0
<?php

/**
 * Cache Manager
 * -------------
 */
Route::accept(array($config->manager->slug . '/cache', $config->manager->slug . '/cache/(:num)'), function ($offset = 1) use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $filter = Request::get('q', "");
    $filter = $filter ? Text::parse($filter, '->safe_file_name') : "";
    $files = Get::files(CACHE, '*', 'DESC', 'update', $filter);
    $files_chunk = Mecha::eat($files)->chunk($offset, $config->per_page * 2)->vomit();
    Config::set(array('page_title' => $speak->caches . $config->title_separator . $config->manager->title, 'offset' => $offset, 'pagination' => Navigator::extract($files, $offset, $config->per_page * 2, $config->manager->slug . '/cache'), 'cargo' => 'cargo.cache.php'));
    Shield::lot(array('segment' => 'cache', 'files' => $files_chunk ? Mecha::O($files_chunk) : false))->attach('manager');
});
/**
 * Cache Repairer
 * --------------
 */
Route::accept($config->manager->slug . '/cache/repair/(file|files):(:all)', function ($prefix = "", $file = "") use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $path = File::path($file);
    if (!($file = File::exist(CACHE . DS . $path))) {
        Shield::abort();
        // File not found!
    }
    $G = array('data' => array('path' => $file));
Exemple #6
0
                        Guardian::kick($config->manager->slug . '/plugin?q=' . $path);
                    }
                }
            }
        } else {
            $tab_id = 'tab-content-2';
            include __DIR__ . DS . 'task.js.tab.php';
        }
    }
    $filter = Request::get('q', "");
    $filter = $filter ? Text::parse($filter, '->safe_file_name') : "";
    $s = Get::closestFolders($destination, 'ASC', 'path', $filter);
    if (!($folders = Mecha::eat($s)->chunk($offset, $config->manager->per_page)->vomit())) {
        Shield::abort();
    }
    Config::set(array('page_title' => $speak->plugins . $config->title_separator . $config->manager->title, 'offset' => $offset, 'pagination' => Navigator::extract($s, $offset, $config->manager->per_page, $config->manager->slug . '/plugin'), 'cargo' => 'cargo.plugin.php'));
    Shield::lot(array('segment' => 'plugin', 'folders' => Mecha::O($folders)))->attach('manager');
});
/**
 * Plugin Configurator
 * -------------------
 */
Route::accept($config->manager->slug . '/plugin/(:any)', function ($slug = 1) use($config, $speak) {
    if (is_numeric($slug)) {
        // It's an index page
        Route::execute($config->manager->slug . '/plugin/(:num)', array($slug));
    }
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    if (!File::exist(PLUGIN . DS . $slug . DS . 'launch.php') && !File::exist(PLUGIN . DS . $slug . DS . '__launch.php')) {
Exemple #7
0
 */
Route::accept(array($config->manager->slug . '/page', $config->manager->slug . '/page/(:num)'), function ($offset = 1) use($config, $speak) {
    $pages = false;
    $offset = (int) $offset;
    if ($files = Mecha::eat(Get::pages('DESC', "", 'txt,draft,archive'))->chunk($offset, $config->manager->per_page)->vomit()) {
        $pages = array();
        foreach ($files as $file) {
            $pages[] = Get::pageHeader($file);
        }
        unset($files);
    } else {
        if ($offset !== 1) {
            Shield::abort();
        }
    }
    Config::set(array('page_title' => $speak->pages . $config->title_separator . $config->manager->title, 'offset' => $offset, 'pages' => $pages, 'pagination' => Navigator::extract(Get::pages('DESC', "", 'txt,draft,archive'), $offset, $config->manager->per_page, $config->manager->slug . '/page'), 'cargo' => DECK . DS . 'workers' . DS . 'cargo.page.php'));
    Shield::lot('segment', 'page')->attach('manager', false);
});
/**
 * Page Composer/Updater
 * ---------------------
 */
Route::accept(array($config->manager->slug . '/page/ignite', $config->manager->slug . '/page/repair/id:(:num)'), function ($id = false) use($config, $speak) {
    Config::set('cargo', DECK . DS . 'workers' . DS . 'repair.page.php');
    if ($id && ($page = Get::page($id, array('content', 'excerpt', 'tags', 'comments')))) {
        $extension_o = $page->state === 'published' ? '.txt' : '.draft';
        if (Guardian::get('status') !== 'pilot' && Guardian::get('author') !== $page->author) {
            Shield::abort();
        }
        if (!isset($page->fields)) {
            $page->fields = array();
Exemple #8
0
})(window.Zepto || window.jQuery);
</script>';
            }, 11);
        }
    }
    $plugins = array();
    $folders = glob(PLUGIN . DS . Request::get('id', '*'), GLOB_NOSORT | GLOB_ONLYDIR);
    sort($folders);
    if ($files = Mecha::eat($folders)->chunk($offset, $config->manager->per_page)->vomit()) {
        for ($i = 0, $count = count($files); $i < $count; ++$i) {
            $plugins[$i]['slug'] = File::B($files[$i]);
            $plugins[$i]['about'] = Plugin::info(File::B($files[$i]), true);
        }
        unset($files);
    }
    Config::set(array('page_title' => $speak->plugins . $config->title_separator . $config->manager->title, 'offset' => $offset, 'files' => !empty($plugins) ? $plugins : false, 'pagination' => Navigator::extract($folders, $offset, $config->manager->per_page, $config->manager->slug . '/plugin'), 'cargo' => DECK . DS . 'workers' . DS . 'cargo.plugin.php'));
    Shield::lot('segment', 'plugin')->attach('manager', false);
});
/**
 * Plugin Configurator
 * -------------------
 */
Route::accept($config->manager->slug . '/plugin/(:any)', function ($slug = "") use($config, $speak) {
    if (Guardian::get('status') !== 'pilot') {
        Shield::abort();
    }
    if (!File::exist(PLUGIN . DS . $slug . DS . 'launch.php')) {
        Shield::abort();
    }
    $info = Plugin::info($slug, true);
    if (!isset($info['url']) && preg_match('#(.*?) *\\<(https?\\:\\/\\/)(.*?)\\>#i', $info['author'], $matches)) {