tilde.chat/wiki/index.php

76 lines
2.2 KiB
PHP
Raw Normal View History

2018-08-30 05:40:29 +00:00
<?php
require __DIR__.'/../vendor/autoload.php';
2019-07-03 05:11:55 +00:00
use Tildeverse\Wiki\Parser;
2018-08-30 05:40:29 +00:00
$additional_head = "
<style>
:target:before {
content:\"\";
display:block;
height:90px; /* fixed header height*/
margin:-90px 0 0; /* negative fixed header height */
}
</style>
<meta property='og:type' content='website'>
<meta property='og:site_name' content='tilde.chat wiki'>
";
2019-07-03 05:11:55 +00:00
$parser = Parser::factory();
2018-08-30 05:40:29 +00:00
if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
$title = "tilde.chat~wiki";
$additional_head .= "
<meta property='og:title' content='$title'>
<meta property='og:url' content='https://tilde.chat{$_SERVER['REQUEST_URI']}'>
<meta property='og:description' content='tilde.chat wiki'>
";
include __DIR__.'/../header.php';
// render wiki index ?>
<h1>tilde.chat wiki</h1>
<p>welcome to the tilde.chat wiki!</p>
<p>if you want to contribute, check out the
2018-10-15 22:29:34 +00:00
<a href="https://tildegit.org/tildeverse/tilde.chat/src/branch/master/wiki">source</a> and open a PR!
2018-08-30 05:40:29 +00:00
</p>
<hr>
<h3>pages:</h3>
<?php
foreach (glob("pages/*.md") as $page) {
$yaml = $parser->parse(file_get_contents($page))->getYAML();
if (!$yaml["published"]) continue; ?>
<a href="?page=<?=basename($page, ".md")?>"><?=$yaml["title"]?></a><br>
<?php }
} else {
$pg = $parser->parse(file_get_contents("pages/{$_GET["page"]}.md"));
$yml = $pg->getYAML();
$title = $yml['title'] . " | tilde.chat~wiki";
$description = $yml['description'] ?? "tilde.chat wiki article {$yml['title']}";
$additional_head .= "
<meta property='og:title' content='$title'>
<meta property='og:url' content='https://tilde.chat{$_SERVER['REQUEST_URI']}'>
<meta property='og:description' content='$description'>
";
include __DIR__.'/../header.php';
// show a single page ?>
<a href=".">&lt; ~wiki</a>
<hr>
2019-07-03 05:11:55 +00:00
<?=$pg->getContent()?>
2018-08-30 05:40:29 +00:00
<hr>
2018-10-15 22:29:34 +00:00
<a href="https://tildegit.org/tildeverse/tilde.chat/src/branch/master/wiki/pages/<?=$_GET["page"]?>.md">
2018-08-30 05:40:29 +00:00
<i class="fa fa-edit"></i> source
</a>
<?php }
include __DIR__.'/../footer.php';