-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·51 lines (42 loc) · 1.53 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* caphpuccino
* Tiny static-like website generator written in Nette (php).
*
* For the full copyright and license information, please view
* the file LICENSE.md that was distributed with this source code.
*
* @copyright Copyright (c) 2013 Tomas Vitek
* @author Tomas Vitek ~ http://tomasvitek.com
* @link http://github.com/tomikvitek/caphpuccino
* @version 0.1
*/
// Load Nette
require __DIR__ . '/app/libs/nette.min.php';
require __DIR__ . '/app/libs/ErrorPresenter.php';
use Nette\Diagnostics\Debugger,
Nette\Application\Routers\Route,
Nette\Templating\FileTemplate,
Nette\Utils\Strings;
// Debugger
$configurator = new Nette\Config\Configurator;
$configurator->enableDebugger(__DIR__ . '/app/log', '[email protected]');
$configurator->setTempDirectory(__DIR__ . '/app/temp');
$container = $configurator->createContainer();
$container->application->errorPresenter = 'Error';
$container->router[] = new Route('[<page>]', function($presenter, $page) use ($container) {
if ($page == 'index') {
$request = $container->getService('httpRequest');
return $presenter->redirectUrl($request->url->basePath);
}
if (!$page) {
$page = 'index';
}
$path = __DIR__ . '/app/templates/' . $page . '.latte';
if (!file_exists($path))
throw new \Nette\Application\BadRequestException('Page Not Found', 404);
$template = $presenter->createTemplate()
->setFile($path);
return $template;
});
$container->application->run();