generate static pages with league/commonmark
[mdref/mdref] / public / index.php
index 1e6d37f83bcf26f45822e31c68db7065f5d65b45..65ad2d2e033f457b91500e7a444d65fd46c9b450 100644 (file)
@@ -1,27 +1,29 @@
 <?php
 
-define("ROOT", dirname(__DIR__));
-define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*")));
+namespace mdref;
 
-ini_set("open_basedir", ROOT.":".REFS);
+use http\Env\Request;
+use http\Env\Response;
+use function ini_get;
+use function ini_set;
+use const GLOB_ONLYDIR;
+use const PATH_SEPARATOR;
+use const REFS;
+use const ROOT;
 
-$loader = require ROOT . "/vendor/autoload.php";
-/* @var $loader \Composer\Autoload\ClassLoader */
-$loader->add("mdref", ROOT);
+define("ROOT", dirname(__DIR__));
+define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*", GLOB_ONLYDIR)));
 
-use http\Controller;
-use http\Controller\Url;
-use http\Controller\Observer\Layout;
+ini_set("open_basedir", ROOT.PATH_SEPARATOR.REFS);
 
-use mdref\ExceptionHandler;
-use mdref\Action;
+if (!ini_get("date.timezone")) {
+       date_default_timezone_set("UTC");
+}
 
-new ExceptionHandler;
+require_once __DIR__ . "/../vendor/autoload.php";
 
-$ctl = new Controller;
-$ctl->setDependency("baseUrl", new Url)
-       ->attach(new Action(["refpath" => REFS]))
-       ->attach(new Layout)
-       ->notify()
-       ->getResponse()
-       ->send();
+$response = new Response;
+$ehandler = new ExceptionHandler($response);
+$reference = new Reference(explode(PATH_SEPARATOR, REFS));
+$action = new Action($reference, new Request, $response, new BaseUrl);
+$action->handle();