Пример #1
0
<?php

return function ($site, $pages, $page) {
    if (c::get('cache.cheatsheet')) {
        $cache = new Cache\Driver\File(kirby()->roots()->cache());
        $cacheId = sha1($page->id()) . '.main';
        $content = $cache->get($cacheId);
    } else {
        $content = null;
    }
    if (empty($content)) {
        $content = snippet('cheatsheet', array('page' => $page), true);
        if (c::get('cache.cheatsheet')) {
            $cache->set($cacheId, $content);
        }
    }
    return compact('content');
};
Пример #2
0
<?php

c::set('markdown.extra', true);
c::set('cache.driver', 'file');
c::set('routes', array(array('pattern' => 'docs.json', 'action' => function () {
    $cache = new Cache\Driver\File(kirby()->roots()->cache());
    $data = $cache->get('docs');
    if (empty($data)) {
        $data = page('docs')->index()->visible()->sortBy('title', 'asc')->toArray(function ($item) {
            return array('title' => $item->title()->toString(), 'uri' => $item->uri());
        });
        $data = array_values($data);
        $cache->set('docs', $data);
    }
    return response::json($data);
}), array('pattern' => 'docs/toolkit/generate', 'action' => function () {
    if (c::get('documentor')) {
        $documentor = new Documentor();
        $data = $documentor->start();
        dump($data);
    } else {
        go();
    }
}), array('pattern' => 'docs/inspect', 'action' => function () {
    if (c::get('inspector')) {
        $inspector = new Inspector();
        var_dump($inspector->results());
    } else {
        go();
    }
}), array('pattern' => 'blog/feed', 'action' => function () {