support sub dirs
authorMichael Wallner <mike@php.net>
Wed, 6 Nov 2013 15:10:19 +0000 (16:10 +0100)
committerMichael Wallner <mike@php.net>
Wed, 6 Nov 2013 15:10:19 +0000 (16:10 +0100)
.htaccess [new file with mode: 0644]
http.md
index.js
index.php
propro.md

diff --git a/.htaccess b/.htaccess
new file mode 100644 (file)
index 0000000..479cadf
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,2 @@
+RewriteEngine On
+RewriteRule ^ index.php
diff --git a/http.md b/http.md
index bf651e2003b9de25efad5113eab990764002e2d1..a2d427b816702d57235aa9133b08d4ad24970373 100644 (file)
--- a/http.md
+++ b/http.md
@@ -13,6 +13,12 @@ Extended HTTP support. Again. Keep in mind that it's got the major version 2, be
 * Errors triggered by the extension can be configured statically by http\Object::$defaultErrorHandling or inherited http\Object->errorHandling.
 * The request ecosystem has been modularized to support different libraries, though for the moment only libcurl is supported.
 
+## Installation:
+
+This extension is hosted at PECL (<http://pecl.php.net>) and can be installed eith PEAR's pecl command:
+
+    # pecl install pecl_http
+
 ## INI Directives:
 
 * http.etag.mode = "crc32b"  
index a6c39342de32691896e6890b274c8735219e57b9..5f384ca09d2d24129d0dab53bbd93eeb76cbf57e 100644 (file)
--- a/index.js
+++ b/index.js
@@ -83,11 +83,11 @@ function type(s, nn) {
                t = s.substring(i+2);
                if (!is_constant(t) && !is_variable(t)) {
                        // methods
-                       return "<a href=\"/" + s.replace(/::|\\/g, "/") + "\">";
+                       return "<a href=\"" + s.replace(/::|\\/g, "/") + "\">";
                }
        }
        if (-1 !== (j = s.indexOf("\\")) && s.substr(j+1,1) !== "n") {
-               return "<a href=\"/" + s.replace(/\\/g, "/").replace(/::|$/, "#") + "\">";
+               return "<a href=\"" + s.replace(/\\/g, "/").replace(/::|$/, "#") + "\">";
        }
        
        switch (s.toLowerCase()) {
index 53c652913cae1b0804bbac55e7dd177fb257acfa..7ae8e478efa5eac7432ab39c0d68dd2e4b524cd4 100644 (file)
--- a/index.php
+++ b/index.php
@@ -91,9 +91,9 @@ function urlpath($dir, $file) {
 function ls($dir) {
        $dir = rtrim(is_dir($dir) ? $dir : dirname($dir) ."/". basename($dir, ".md"), "/");
        printf("<ul>\n");
-       printf("<li>&lArr; <a href=/>Home</a></li>\n");
+       printf("<li>&lArr; <a href=>Home</a></li>\n");
        if ($dir !== "." && ($dn = dirname($dir)) !== ".") {
-               printf("<li>&uArr; <a href=/%s>%s</a></li>\n", 
+               printf("<li>&uArr; <a href=%s>%s</a></li>\n", 
                        urlpath($dir, ".."),
                        ns($dn));
        }
@@ -127,7 +127,7 @@ function ls($dir) {
                                }
                        }
                        
-                       printf("<li>&rArr; <a href=\"/%s\">%s</a></li>\n", 
+                       printf("<li>&rArr; <a href=\"%s\">%s</a></li>\n", 
                                urlpath($dir, $file),
                                ns("$dir/".basename($file, ".md")));
                }
@@ -158,7 +158,7 @@ function ml($file) {
                                if ($file{0} === "." || !is_file("$dir/$file") || ctype_upper($file{0})) {
                                        continue;
                                }
-                               printf("<li><h3><a href=\"/%s\">%s</a></h3><p>%s</p><p>%s</p></li>\n",
+                               printf("<li><h3><a href=\"%s\">%s</a></h3><p>%s</p><p>%s</p></li>\n",
                                        urlpath($dir, $file),
                                        basename($file, ".md"),
                                        @end(head("$dir/$file", 3)),
@@ -177,7 +177,7 @@ function ml($file) {
                                if ($file{0} === "." || !is_file("$dir/$file") || ctype_upper($file{0})) {
                                        continue;
                                }
-                               printf("<li><h3><a href=\"/%s\">%s</a></h3><p>%s</p><p>%s</p></li>\n",
+                               printf("<li><h3><a href=\"%s\">%s</a></h3><p>%s</p><p>%s</p></li>\n",
                                        urlpath($dir, $file),
                                        basename($file, ".md"),
                                        @end(head("$dir/$file", 3)),
@@ -215,12 +215,13 @@ function md($file, $res) {
        }
 }
 
-chdir($_SERVER["DOCUMENT_ROOT"]);
+chdir(__DIR__);
 $t = ["css"=>"text/css", "js"=>"application/javascript"];
 $r = new http\Env\Request;
 $u = new http\Url($r->getRequestUrl());
 $s = new http\Env\Response;
-$p = ".". $u->path;
+$b = dirname($_SERVER["SCRIPT_NAME"]);
+$p = ".". substr($u->path, strlen($b));
 
 switch($p) {
 case "./index.php":
@@ -241,11 +242,9 @@ ob_start($s);
 <head>
        <meta charset="utf-8">
        <title><?=ns($p)?></title>
-       <link rel="stylesheet" href="/index.css">
+       <base href="<?=$b?>/">
+       <link rel="stylesheet" href="index.css">
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
-       <?php if (!extension_loaded("discount") || !getenv("DISCOUNT")) : ?>
-       <script src="/markdown.js"></script>
-       <?php endif; ?>
 </head>
 <body>
        <div class="sidebar">
@@ -262,15 +261,14 @@ ob_start($s);
                        ob_end_flush();
                ?></pre>
        <?php else: ?>
-               <?php if (!md($p, $s)): ?>
-               <?php endif; ?>
+               <?php md($p, $s); ?>
        <?php endif; ?>
        <footer>
-               <a href="/VERSION">Version</a>
-               <a href="/AUTHORS">Authors</a>
-               <a href="/LICENSE">License</a>
+               <a href="VERSION">Version</a>
+               <a href="AUTHORS">Authors</a>
+               <a href="LICENSE">License</a>
        </footer>
-       <script src="/index.js"></script>
+       <script src="index.js"></script>
 </body>
 </html>
 <?php
index bd0150359c6da5d6c8cc4b73411c723f61293a4a..a5ee6fe4eeb14ae95430e5347cc618762f9a90b7 100644 (file)
--- a/propro.md
+++ b/propro.md
@@ -7,3 +7,10 @@ The "Property Proxy" extension provides a fairly transparent proxy for internal
 > **Note:** This extension mostly only provides infrastructure for other extensions.
 
 See the php\PropertyProxy class, for the user-land visible part of the implementation.
+
+## Installation:
+
+This extension is hosted at PECL (<http://pecl.php.net>) and can be installed eith PEAR's pecl command:
+
+    # pecl install propro
+