X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=index.php;h=5c4b909b5057fe201b23b09978d73c0a785222dd;hb=4199b3fd65d963057c82c1541df6e2f786e6bd9d;hp=8bc11f7adbcdb36bc7d99f75d2696d8a23cd3706;hpb=ec58da517d38efad66ede3ff22d2350d1e7871f2;p=mdref%2Fmdref
diff --git a/index.php b/index.php
index 8bc11f7..5c4b909 100644
--- 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("
\n");
- printf("- ⇐ Home
\n");
+ printf("- ⇐ Home
\n");
if ($dir !== "." && ($dn = dirname($dir)) !== ".") {
- printf("- ⇑ %s
\n",
+ printf("- ⇑ %s
\n",
urlpath($dir, ".."),
ns($dn));
}
@@ -101,37 +101,15 @@ function ls($dir) {
if ($dir !== ".") {
printf("\n- %s
\n", ns($dir));
}
- printf("\n");
- foreach (scandir($dir) as $file) {
- /* ignore dot-files */
- if ($file{0} === ".") {
- continue;
- }
-
- $path = "$dir/$file";
-
- if (is_file($path)) {
- $pi = pathinfo($path);
- /* ignore files not ending in .md */
- if (!isset($pi["extension"]) || $pi["extension"] != "md") {
- continue;
- }
- /* ignore files where an accompanying directory exists */
- if (is_dir("$dir/".$pi["filename"])) {
- continue;
- }
- } else {
- /* ignore directories where no accompanying file exists */
- if (!is_file("$path.md")) {
- continue;
- }
+ if (($glob = glob("$dir/[_a-zA-Z]*.md"))) {
+ printf("\n");
+ foreach ($glob as $file) {
+ printf("- ⇒ %s
\n",
+ urlpath($dir, $file),
+ ns("$dir/".basename($file, ".md")));
}
-
- printf("- ⇒ %s
\n",
- urlpath($dir, $file),
- ns("$dir/".basename($file, ".md")));
+ printf("
\n");
}
- printf("
\n");
if ($dir !== ".") {
printf("
\n");
}
@@ -148,44 +126,20 @@ function ml($file) {
if ($pi["extension"] !== "md") {
return;
}
- if (!ctype_upper($pi["filename"][0])) {
- // namespaced functions
- $dir = $pi["dirname"] . "/" . $pi["filename"];
- if (is_dir($dir)) {
- printf("Functions:
\n");
- printf("\n");
- foreach (scandir($dir) as $file) {
- if ($file{0} === "." || !is_file("$dir/$file") || ctype_upper($file{0})) {
- continue;
- }
- printf("%s
%s
\n",
- urlpath($dir, $file),
- basename($file, ".md"),
- @end(head("$dir/$file", 3)),
- join(" ", cut(head("$dir/$file"), ["f"=>"1-"]))
- );
- }
- printf("
\n");
- }
- } else {
- // methods
- $dir = $pi["dirname"] . "/" . $pi["filename"];
- if (is_dir($dir)) {
- printf("Methods:
\n");
- printf("\n");
- foreach (scandir($dir) as $file) {
- if ($file{0} === "." || !is_file("$dir/$file") || ctype_upper($file{0})) {
- continue;
- }
- printf("%s
%s
\n",
- urlpath($dir, $file),
- basename($file, ".md"),
- @end(head("$dir/$file", 3)),
- join(" ", cut(head("$dir/$file"), ["f"=>"1-"]))
- );
- }
- printf("
\n");
+ $dir = $pi["dirname"] . "/" . $pi["filename"];
+ if (($glob = glob("$dir/[_a-z]*.md"))) {
+ printf("%s:
\n", !ctype_upper($pi["filename"][0]) ?
+ "Functions" : "Methods");
+ printf("\n");
+ foreach ($glob as $file) {
+ printf("%s
%s
\n",
+ urlpath($dir, $file),
+ basename($file, ".md"),
+ @end(head($file, 3)),
+ join(" ", cut(head($file), ["f"=>"1-"]))
+ );
}
+ printf("
\n");
}
}
@@ -199,7 +153,7 @@ function md($file, $res) {
$r = fopen($file, "r");
$md = MarkdownDocument::createFromStream($r);
$md->compile(MarkdownDocument::AUTOLINK|MarkdownDocument::TOC);
- print str_replace("
","
",$md->getHtml());
+ print $md->getHtml();
fclose($r);
ml($file);
break;
@@ -215,17 +169,13 @@ function md($file, $res) {
}
}
-function index($pn) {
- ?>
- "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":
@@ -246,11 +196,9 @@ ob_start($s);
=ns($p)?>
-
+
+
-
-
-