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
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
$blogPostsPerPage = 4;
if (isset($_SERVER['HTTPS'])) {
    $protocol = $_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off" ? "https" : "http";
} else {
    $protocol = 'http';
}
$url = $protocol . "://" . $_SERVER['HTTP_HOST'];
//include cockpit
include_once 'lib/parsedown/Parsedown.php';
include_once 'cockpit/bootstrap.php';
$app = new Lime\App();
function get404($message = "Whatever you're looking for, it's not here...")
{
    global $app;
    $app->response->status = "404";
    $data = ['title' => '404 Not Found', 'description' => 'This page was not found. Please let me know if you this is in error.', 'message' => $message];
    return $app->render('views/404.php with views/layout.php', $data);
}
function getBlogPosts($filter, $page)
{
    global $blogPostsPerPage;
    $collection = collection('Blog Posts');
    $count = $collection->count($filter);
    $pages = ceil($count / $blogPostsPerPage);
    if ($page > $pages && $page != 1) {
        return null;