From d7b9f83d24b7af987618921f555c9e5e2c2f4b95 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 26 Nov 2013 10:52:38 +0100 Subject: [PATCH 1/1] init --- .gitignore | 1 + VERSION | 1 + composer.json | 5 + composer.lock | 65 +++++++++ mdref/RefListing.php | 8 ++ mdref/controllers/AppController.php | 15 ++ mdref/controllers/IndexController.php | 9 ++ mdref/controllers/RefController.php | 10 ++ mdref/views/index.phtml | 1 + mdref/views/layout.phtml | 27 ++++ nbproject/project.properties | 7 + nbproject/project.xml | 9 ++ public/index.css | 162 +++++++++++++++++++++ public/index.js | 200 ++++++++++++++++++++++++++ public/index.php | 32 +++++ refs/http | 1 + 16 files changed, 553 insertions(+) create mode 100644 .gitignore create mode 100644 VERSION create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 mdref/RefListing.php create mode 100644 mdref/controllers/AppController.php create mode 100644 mdref/controllers/IndexController.php create mode 100644 mdref/controllers/RefController.php create mode 100644 mdref/views/index.phtml create mode 100644 mdref/views/layout.phtml create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml create mode 100644 public/index.css create mode 100644 public/index.js create mode 100644 public/index.php create mode 120000 refs/http diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14bc68c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/nbproject/private/ \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..a163131 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0alpha diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..2a36108 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "m6w6/autocracy": "dev-master" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..11a05e8 --- /dev/null +++ b/composer.lock @@ -0,0 +1,65 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "0147473751b895f221e765fd6fb1fc2b", + "packages": [ + { + "name": "m6w6/autocracy", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/m6w6/autocracy.git", + "reference": "b6830cfce3dc276bf67288a7c6bfe64ffd290e21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/m6w6/autocracy/zipball/b6830cfce3dc276bf67288a7c6bfe64ffd290e21", + "reference": "b6830cfce3dc276bf67288a7c6bfe64ffd290e21", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "http\\Controller": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Michael Wallner", + "email": "mike@php.net" + } + ], + "description": "http\\Controller preserves your autocracy", + "homepage": "http://github.com/m6w6/autocracy", + "keywords": [ + "controller", + "http", + "pecl", + "pecl_http" + ], + "time": "2013-10-22 11:41:09" + } + ], + "packages-dev": [ + + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": { + "m6w6/autocracy": 20 + }, + "platform": [ + + ], + "platform-dev": [ + + ] +} diff --git a/mdref/RefListing.php b/mdref/RefListing.php new file mode 100644 index 0000000..542a3ff --- /dev/null +++ b/mdref/RefListing.php @@ -0,0 +1,8 @@ +payload->title = "mdref"; + $this->payload->listing = 123; + } +} \ No newline at end of file diff --git a/mdref/controllers/IndexController.php b/mdref/controllers/IndexController.php new file mode 100644 index 0000000..771de9f --- /dev/null +++ b/mdref/controllers/IndexController.php @@ -0,0 +1,9 @@ + + + + + <?= $title ?> + + + + + + + + + +
+ + + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..d37ef95 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_54 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..5dec217 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + mdref-autocracy.git + + + diff --git a/public/index.css b/public/index.css new file mode 100644 index 0000000..a48ac00 --- /dev/null +++ b/public/index.css @@ -0,0 +1,162 @@ +* { + font-size: 99.9%; +} + +body, code { + font-family: Inconsolata, Monospace, 'Courier New', Courier, monospace; +} +body { + font-size: 1.5em; + margin: 0; + padding: 0; + color: #3f3f3f; +} + +body>* { + margin-left: 1em; +} +body>ul { + margin-left: 2em; +} + +.sidebar { + font-size: .9em; + float: right; + background: #f0f0f0; + border-bottom-left-radius: 10px; + padding: 0; + width: auto; + padding-right: 1em; +} +.sidebar>ul { +} +.sidebar ul { + margin-left: 1em; + padding: 0; + list-style-type: none; +} + +code { + display: inline-block; + border-radius: 2px; + padding: 0px 2px 2px 2px; + background: #e0e0e0; + color: #606060; + box-shadow: 0 0 1px #999; +} + +code code { + display: inline; + padding: 0; + background: transparent; + border: none; + box-shadow: none; +} + +pre>code { + padding: 1em; +} +pre>code, pre>code code { + background: #333; + color: #eee; +} + +p, pre { + margin: 1em 2em; +} + +blockquote { + border-top: 1px solid #800000; + border-bottom: 1px solid #800000; + background: #ffe4e1; + margin: 2em 0; +} + +ul { + margin-bottom: 2em; +} +li { + margin-bottom: .5em; +} +a, h1 code>a { + color: #2f4f4f; +} +a:hover { + text-decoration: none; +} + +.var { + color: #800000; +} +.constant { + color: #2e8b57; +} + +h1 { + line-height: 1.5; +} +h1 code { + font-weight: normal; + font-size: .9em; + line-height: 1.33; +} + +footer, h1, li h3 { + background: #708090; + color: #f5f5dc; +} + +footer, h1 { + margin: 0; + padding: 1em; +} + +li h3 { + border-radius: 4px; + display: inline-block; + width: auto; + padding: .2em; + margin: .5em 0 0 0; +} + +h1 .constant, pre>code .consant, li h3 .constant { + color: #98fb98; +} + +h1 .var, pre>code .var, li h3 .var { + color: #f4a460; +} + +footer a, h1 a, pre>code a, li h3 a { + color: #b0e0e6; +} + +li h3 a { + text-decoration: none; +} +li h3 a:hover { + text-decoration: underline; +} + +#disqus_thread { + margin-top: 8em; + margin-right: 2em; +} + +footer { + font-size: smaller; + text-align: center; + clear: both; + margin-top: 8em; +} + +footer ul { + margin: 0; + padding: 0; +} + +footer li { + list-style-type: none; + display: inline-block; + margin: 0 1em; +} diff --git a/public/index.js b/public/index.js new file mode 100644 index 0000000..e0f3ccf --- /dev/null +++ b/public/index.js @@ -0,0 +1,200 @@ +function log() { + // console.log.apply(console, arguments); +} + +function is_constant(s) { + s = s.replace(/v\d+(_\d+)?$/, ""); + if (s.length < 2) { + return false; + } + return s.toUpperCase(s) === s; +} + +function is_variable(s) { + return s.substring(0,1) === "$"; +} + +var is_in_string = false; + +function type(s, nn) { + var i, j, t; + //log("type", s); + // nothing + if (!s.match(/[a-zA-Z]/)) { + return; + } + + switch (s) { + // types + case "void": + case "bool": + case "int": + case "float": + case "string": + case "resource": + case "array": + case "object": + case "callable": + case "mixed": + // Zend/SPL + case "stdClass": + case "Exception": + case "ErrorException": + case "RuntimeException": + case "UnexpectedValueException": + case "DomainException": + case "InvalidArgumentException": + case "BadMethodCallException": + case "Closure": + case "Generator": + case "Countable": + case "Serializable": + case "Traversable": + case "Iterator": + case "IteratorAggregate": + case "ArrayAccess": + case "ArrayObject": + case "ArrayIterator": + case "RecursiveArrayIterator": + case "SplObserver": + case "SplSubject": + case "SplObjectStorage": + return ""; + + // keywords + case "is": + if (nn !== "H1") { + return; + } + case "extends": + case "implements": + if (nn === "H1") { + return "
 "; + } + case "class": + case "interface": + case "namespace": + case "public": + case "protected": + case "private": + case "static": + case "final": + case "abstract": + case "self": + case "parent": + // phrases + case "Optional": + case "optional": + return ""; + } + + // class members + if (-1 !== (i = s.indexOf("::"))) { + t = s.substring(i+2); + if (!is_constant(t) && !is_variable(t)) { + // methods + return ""; + } + } + if (-1 !== (j = s.indexOf("\\")) && s.substr(j+1,1) !== "n") { + return ""; + } + + switch (s.toLowerCase()) { + // variables + default: + if (!is_variable(s)) { + break; + } + // special constants + case "null": + case "true": + case "false": + return ""; + } + + // constants + if (is_constant(s)) { + return ""; + } +} + +function node(s, nn) { + //log("node", s); + + var t; + + if ((t = type(s, nn))) { + return $(t).text(s); + } + return document.createTextNode(s); +} +function wrap(n, nn) { + var $n = $(n) + var a = []; + + $n.text().split(/([^a-zA-Z0-9_\\\$:]+)/).forEach(function(v) { + a.push(node(v, nn)); + }); + $n.replaceWith(a); +} +function walk(i, e) { + log("walk", i, e); + + $.each($.makeArray(e.childNodes), function(i, n) { + switch (n.nodeName) { + case "A": + case "BR": + case "HR": + break; + case "#text": + wrap(n, e.nodeName); + break; + default: + walk(-1, n); + break; + } + }); +} + +function blink(c) { + var $c = $(c); + + $c.fadeOut("fast").queue(function(next) { + this.style.color = "red"; + next(); + }).fadeIn("fast").fadeOut("slow").queue(function(next) { + this.style.color = ""; + next(); + }).fadeIn("slow"); +} + +function hashchange() { + if (location.hash.length > 1) { + var hash = location.hash.substring(1); + var name = is_variable(hash) ? ".var" : ".constant"; + var scrolled = false; + + $(name).each(hash.substring(hash.length-1) === "_" ? function(i, c) { + if (c.textContent.substring(0, hash.length) === hash) { + if (!scrolled) { + $(window).scrollTop($(c).offset().top - 100); + scrolled = true; + } + blink(c); + } + } : function(i, c) { + if (c.textContent === hash) { + $(window).scrollTop($(c).offset().top - 100); + blink(c); + return false; + } + }); + } +} + +$(function() { + $("h1,h2,h3,h4,h5,h6,p,li,code").each(walk); + $(window).on("hashchange", hashchange); + hashchange(); +}); diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..649bb0a --- /dev/null +++ b/public/index.php @@ -0,0 +1,32 @@ +add("controllers", __DIR__ . "/../mdref"); + +use http\Controller; +use http\Controller\Url; + +use http\Controller\Observer\Callback; +use http\Controller\Observer\Params; +use http\Controller\Observer\Action; +use http\Controller\Observer\View; +use http\Controller\Observer\Layout; + + +$url = new Url; + +$ctl = new Controller; +$ctl->setDependency("baseUrl", $url); + +$ctl->attach(new Params\Action); +$ctl->attach(new Action(["controllerPrefix" => "controllers\\"])); +$ctl->attach(new Callback(function(\http\Controller $ctl) use ($url) { + $ctl->getPayload()->baseUrl = $url; +})); +$ctl->attach(new View(["directory" => __DIR__ . "/../mdref/views"])); +$ctl->attach(new Layout(["directory" => __DIR__ . "/../mdref/views"])); + +$response = $ctl->notify()->getResponse(); +$response->send(); diff --git a/refs/http b/refs/http new file mode 120000 index 0000000..924216a --- /dev/null +++ b/refs/http @@ -0,0 +1 @@ +../../mdref-http.git/ \ No newline at end of file -- 2.30.2