fix the url scheme (/wiki/wikipage on main wiki, /wiki/?page=wikipage elsewhere)
This commit is contained in:
parent
9d8f63d894
commit
f1b6b4e029
19
index.php
19
index.php
|
@ -18,6 +18,23 @@ $additional_head = "
|
|||
|
||||
$parser = Tildeverse\Wiki\Parser::factory();
|
||||
|
||||
// if it's tilde.cafe's live site, use wiki/wiki-page else use wiki/?page=wiki-page
|
||||
if($_SERVER["HTTP_HOST"] == "tilde.cafe"){
|
||||
// only use slashes if it's tilde.cafe/wiki/
|
||||
// don't care if there's anything after that, such as an open wikipage
|
||||
if(explode("/",rtrim($_GET["REQUEST_URI"],"/"),3)[1] == "wiki"){
|
||||
// it's the official site
|
||||
$format="";
|
||||
} else {
|
||||
// it's a userdir
|
||||
$format="?page=";
|
||||
// $format="";
|
||||
}
|
||||
} else {
|
||||
// it's a different domain
|
||||
$format="?page=";
|
||||
}
|
||||
|
||||
|
||||
if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
|
||||
|
||||
|
@ -46,7 +63,7 @@ if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
|
|||
foreach (glob("pages/*.md") as $page) {
|
||||
$yaml = $parser->parse(file_get_contents($page))->getYAML();
|
||||
if (!$yaml["published"]) continue; ?>
|
||||
<li><a href="<?php echo(strtok($_SERVER["REQUEST_URI"], '?').basename($page, ".md"));?>"><?=$yaml["title"]?></a><br></li>
|
||||
<li><a href="<?php echo(strtok($_SERVER["REQUEST_URI"], '?').$format.basename($page, ".md"));?>"><?=$yaml["title"]?></a><br></li>
|
||||
<?php }
|
||||
echo("</ul></div>");
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue