Reorganized structure; 404 support
This commit is contained in:
parent
a1f73d008d
commit
3ba0d60d78
9 changed files with 42 additions and 28 deletions
6
.gitmodules
vendored
6
.gitmodules
vendored
|
@ -1,9 +1,9 @@
|
|||
[submodule "chibi-core"]
|
||||
path = chibi-core
|
||||
path = lib/chibi-core
|
||||
url = https://github.com/rr-/chibi-core.git
|
||||
[submodule "php-markdown"]
|
||||
path = php-markdown
|
||||
path = lib/php-markdown
|
||||
url = https://github.com/michelf/php-markdown.git
|
||||
[submodule "redbean"]
|
||||
path = redbean
|
||||
path = lib/redbean
|
||||
url = https://github.com/gabordemooij/redbean.git
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit f409272ce5b9856c8765dc8b9b68349efde71b0c
|
1
lib/chibi-core
Submodule
1
lib/chibi-core
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 8488232806fd5ceecb25af39036f250b081ada3d
|
|
@ -1,21 +1,12 @@
|
|||
<?php
|
||||
chdir('..');
|
||||
require_once 'redbean/RedBean/redbean.inc.php';
|
||||
require_once 'chibi-core/Facade.php';
|
||||
require_once 'lib/redbean/RedBean/redbean.inc.php';
|
||||
require_once 'lib/chibi-core/Facade.php';
|
||||
require_once 'src/Bootstrap.php';
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
setlocale(LC_CTYPE, 'en_US.UTF-8');
|
||||
|
||||
class Bootstrap
|
||||
{
|
||||
public function workWrapper($workCallback)
|
||||
{
|
||||
$this->config->chibi->baseUrl = 'http://' . rtrim($_SERVER['HTTP_HOST'], '/') . '/';
|
||||
R::setup('sqlite:' . $this->config->main->dbPath);
|
||||
$workCallback();
|
||||
}
|
||||
}
|
||||
|
||||
$query = $_SERVER['REQUEST_URI'];
|
||||
$configPaths =
|
||||
[
|
||||
|
|
33
src/Bootstrap.php
Normal file
33
src/Bootstrap.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
class Bootstrap
|
||||
{
|
||||
public function workWrapper($workCallback)
|
||||
{
|
||||
session_start();
|
||||
$this->context->layoutName = isset($_GET['json'])
|
||||
? 'layout-json'
|
||||
: 'layout-normal';
|
||||
$this->context->transport = new StdClass;
|
||||
$this->context->transport->success = null;
|
||||
|
||||
$this->config->chibi->baseUrl = 'http://' . rtrim($_SERVER['HTTP_HOST'], '/') . '/';
|
||||
R::setup('sqlite:' . $this->config->main->dbPath);
|
||||
if (empty($this->context->route))
|
||||
{
|
||||
$this->context->viewName = 'error-404';
|
||||
(new \Chibi\View())->renderFile($this->context->layoutName);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$workCallback();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->context->exception = $e;
|
||||
$this->context->viewName = 'error-exception';
|
||||
(new \Chibi\View())->renderFile($this->context->layoutName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,13 +21,6 @@ abstract class AbstractController
|
|||
|
||||
public function workWrapper($workCallback)
|
||||
{
|
||||
session_start();
|
||||
$this->context->layoutName = isset($_GET['json'])
|
||||
? 'layout-json'
|
||||
: 'layout-normal';
|
||||
$this->context->transport = new StdClass;
|
||||
$this->context->transport->success = null;
|
||||
|
||||
$this->attachUser();
|
||||
|
||||
try
|
||||
|
@ -40,10 +33,5 @@ abstract class AbstractController
|
|||
$this->context->transport->exception = $e;
|
||||
$this->context->transport->success = false;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->context->exception = $e;
|
||||
$this->context->viewName = 'error-exception';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
src/Views/error-404.phtml
Normal file
2
src/Views/error-404.phtml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<h1>Error</h1>
|
||||
<?php echo $this->context->query ?> not found.
|
Loading…
Reference in a new issue