mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Reorganized structure; 404 support
This commit is contained in:
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,9 +1,9 @@
|
|||||||
[submodule "chibi-core"]
|
[submodule "chibi-core"]
|
||||||
path = chibi-core
|
path = lib/chibi-core
|
||||||
url = https://github.com/rr-/chibi-core.git
|
url = https://github.com/rr-/chibi-core.git
|
||||||
[submodule "php-markdown"]
|
[submodule "php-markdown"]
|
||||||
path = php-markdown
|
path = lib/php-markdown
|
||||||
url = https://github.com/michelf/php-markdown.git
|
url = https://github.com/michelf/php-markdown.git
|
||||||
[submodule "redbean"]
|
[submodule "redbean"]
|
||||||
path = redbean
|
path = lib/redbean
|
||||||
url = https://github.com/gabordemooij/redbean.git
|
url = https://github.com/gabordemooij/redbean.git
|
||||||
|
Submodule chibi-core deleted from f409272ce5
1
lib/chibi-core
Submodule
1
lib/chibi-core
Submodule
Submodule lib/chibi-core added at 8488232806
@ -1,21 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
chdir('..');
|
chdir('..');
|
||||||
require_once 'redbean/RedBean/redbean.inc.php';
|
require_once 'lib/redbean/RedBean/redbean.inc.php';
|
||||||
require_once 'chibi-core/Facade.php';
|
require_once 'lib/chibi-core/Facade.php';
|
||||||
|
require_once 'src/Bootstrap.php';
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
setlocale(LC_CTYPE, 'en_US.UTF-8');
|
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'];
|
$query = $_SERVER['REQUEST_URI'];
|
||||||
$configPaths =
|
$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)
|
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();
|
$this->attachUser();
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -40,10 +33,5 @@ abstract class AbstractController
|
|||||||
$this->context->transport->exception = $e;
|
$this->context->transport->exception = $e;
|
||||||
$this->context->transport->success = false;
|
$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.
|
Reference in New Issue
Block a user