Example #1
0
<?php

// make cockpit api available
require 'admin/bootstrap.php';
$app = new Lime\App();
$app->path('template', __DIR__ . '/template');
$app->path('views', __DIR__ . '/views');
require 'config.php';
// bind routes
$app->bind("/", function () use($app, $config) {
    return $app->render('views:home.php with template:template.php', array_merge($config, []));
});
// handle error pages
$app->on("after", function () use($app, $baseVars) {
    switch ($app->response->status) {
        case 404:
            if ($app->req_is('ajax')) {
                $app->response->body = '{"error": "404", "message":"File not found"}';
            } else {
                $app->response->body = $app->render('views:error/404.php with template:template.php', $baseVars);
            }
            break;
    }
});
$app->run();
Example #2
0
<?php

require_once "src/Lime/App.php";
$app = new Lime\App();
$app->bind("/", function () use($app) {
    return "Hello World!";
});
$app->run();
Example #3
0
<?php

//include cockpit
include_once 'cockpit/bootstrap.php';
$app = new Lime\App();
// bind routes
$app->bind("/", function () use($app) {
    return $app->render('views/index.php');
});
$app->bind("/posts", function () use($app) {
    // $posts = collection('Posts')->find(["public"=>true])->sort(["created"=>1])->toArray();
    //get posts with related categories
    $posts = cockpit('collections')->populate('Posts', cockpit('collections')->find('Posts'))->toArray();
    return $app->render('views/posts.php', ['posts' => $posts]);
});
$app->bind("/pages", function () use($app) {
    $posts = collection('Pages')->find(["public" => true])->sort(["created" => 1])->toArray();
    return $app->render('views/pages.php', ['pages' => $posts]);
});
$app->bind("/projects", function () use($app) {
    //get projects with related categories
    $posts = cockpit('collections')->populate('Projects', cockpit('collections')->find('Projects'))->toArray();
    return $app->render('views/projects.php', ['projects' => $posts]);
});
// $app->bind("/article/:title_slug", function($params) use($app) {
//     $post = collection('blog')->findOne(["title_slug"=>$params['title_slug']]);
//     return $app->render('views/article.php', ['post' => $post]);
// });
$app->run();
Example #4
0
<?php

//include cockpit
include_once 'cockpit/bootstrap.php';
$app = new Lime\App();
// bind routes
$app->bind("/article/:id", function ($params) use($app) {
    $post = collection('blog')->findOne(["_id" => $params['id']]);
    return $app->render('views/article.php', ['post' => $post]);
});
$app->bind("/", function () use($app) {
    $limit = 5;
    $page = $app->param("page", 1);
    $count = collection('blog')->count(["public" => true]);
    $pages = ceil($count / $limit);
    // get posts
    $posts = collection('blog')->find(["public" => true]);
    // apply pagination
    $posts->limit($limit)->skip(($page - 1) * $limit);
    // apply sorting
    $posts->sort(["created" => 1]);
    return $app->render('views/index.php', ['posts' => $posts->toArray(), 'page' => $page, 'pages' => $pages]);
});
$app->run();
Example #5
0
<?php

/* *
 *	cockpit-test
 *  index.php
 *	Created on 7-1-2015 19:55
 *  
 *  @author Matthijs
 *  @copyright Copyright (C)2015 Bixie.nl
 *
 */
// make cockpit api available
require 'cockpit/bootstrap.php';
$app = new Lime\App();
$baseVars = ['pageTitle' => 'Bixie Cockpit', 'min' => get_registry('minify', 0) ? '.min' : ''];
// bind routes
$app->bind("/", function () use($app, $baseVars) {
    $nieuwsList = collection('Nieuws')->find(['active' => true])->sort(['created' => 1])->toArray();
    $homeContent = collection('Content')->findOne(["title_slug" => 'home']);
    return $app->render('views/index.php with template/template.php', array_merge($baseVars, ['nieuwsList' => $nieuwsList, 'homeContent' => $homeContent]));
});
$app->bind("/nieuws/:title_slug", function ($params) use($app, $baseVars) {
    $post = collection('Nieuws')->findOne(["title_slug" => $params['title_slug']]);
    $pageTitle = $post['title'];
    return $app->render('views/article.php with template/template.php', array_merge($baseVars, ['pageTitle' => $pageTitle, 'post' => $post]));
});
$app->run();
Example #6
0
<?php

require_once "admin/bootstrap.php";
$app = new Lime\App();
$app->bind("/", function () use($app) {
    return $app->render('views/index.php');
});
$app->bind("/gallery/:gallery_slug", function ($params) use($app) {
    $gallery = cockpit("galleries")->gallery($params['gallery_slug']);
    return $app->render('views/gallery.php', ['gallery' => $gallery]);
});
$app->bind("/about", function () use($app) {
    return $app->render('views/about.php');
});
$app->bind("/contact", function () use($app) {
    return $app->render('views/contact.php');
});
$app->run();
Example #7
0
    $pages = ceil($count / $blogPostsPerPage);
    if ($page > $pages && $page != 1) {
        return null;
    }
    $posts = $collection->find($filter);
    $posts->limit($blogPostsPerPage)->skip(($page - 1) * $blogPostsPerPage);
    $posts->sort(["posted_date" => -1]);
    return ['posts' => $posts->toArray(), 'page' => $page, 'pages' => $pages];
}
function fixRelativeLinks($content)
{
    global $url;
    return preg_replace('/(href|src)="\\/([a-zA-Z0-9])/', '${1}="' . $url . '/${2}', $content);
}
$app->bind("/", function () use($app) {
    $staticContent = collection('Static Content')->findOne(['name_slug' => 'about-me']);
    return $app->render('views/static_content.php with views/layout.php', ['title' => 'About', 'staticContent' => $staticContent, 'currentPage' => 'about']);
});
$app->bind("/blog", function () use($app) {
    $data = ['title' => 'Blog Index', 'description' => "The index of Fisher Evans' Blog. Find his most recent musings, browse by tag, or browse the whole archive.", 'currentPage' => 'blog'];
    return $app->render('views/blog/blogIndex.php with views/layout.php', $data);
});
$app->bind("/blog/recent", function () use($app) {
    $this->reroute("/blog/recent/1");
});
// bind routes
$app->bind("/blog/recent/:page", function ($params) use($app) {
    $blog = getBlogPosts(["published" => true], $params['page']);
    if ($blog == null) {
        return get404("There aren't THAT many posts... Try a lower page number.");
    }
    $blog['title'] = 'Recent Posts | Blog' . ($blog['page'] != 1 ? ' | Page ' . $blog['page'] : '');