-class Action extends Observer
-{
- private function serveReference(\http\Controller $ctl) {
- $payload = $ctl->getPayload();
- $finder = new Finder($this->baseUrl, REFS);
- $path = $finder->find(new \http\Url($ctl->getRequest()->getRequestUrl()));
- $payload->listing = new RefListing($path,
- $finder->glob($path, "/[_a-zA-Z]*.md"));
- $payload->title = $payload->listing->getSelf()->formatLink();
- $payload->refs = $finder;
- if ($path->isFile()) {
- $payload->html = new Markdown($path);
- $payload->sublisting = new RefListing($path,
- $finder->glob($path, "/[_a-z]*.md"));
- return true;
+/**
+ * Request handler
+ */
+class Action extends Observer {
+ /**
+ * Reference paths
+ * @var string
+ */
+ protected $refpath;
+
+ /**
+ * The reference
+ * @var \mdref\Reference
+ */
+ private $reference;
+
+ /**
+ * Initialize the reference
+ */
+ protected function init() {
+ $this->reference = new Reference(explode(PATH_SEPARATOR, $this->refpath));
+ }
+
+ /**
+ * Create the view payload
+ * @param \http\Controller $ctl
+ * @return \stdClass
+ */
+ private function createPayload(\http\Controller $ctl) {
+ $pld = new \stdClass;
+
+ try {
+ $pld->quick = [$this->reference, "formatString"];
+ $pld->file = [$this->reference, "formatFile"];
+
+ $pld->ref = implode("/", $this->baseUrl->params(
+ $this->baseUrl->mod($ctl->getRequest()->getRequestUrl())));
+
+ $pld->refs = $this->reference;
+ $pld->baseUrl = $this->baseUrl;
+
+ } catch (\Exception $e) {
+ $pld->exception = $e;