111 lines
3.0 KiB
PHP
111 lines
3.0 KiB
PHP
<?php
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
use tildeteam\wiki;
|
|
|
|
$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'>
|
|
";
|
|
|
|
$parser = wiki::factory(true);
|
|
|
|
if(isset($_GET["page"])) {
|
|
$page=$_GET["page"];
|
|
} else {
|
|
$page="";
|
|
}
|
|
|
|
if(preg_match("/[^a-z0-9_-]/", $page)) {
|
|
$page="";
|
|
}
|
|
|
|
if ($page=="" || !file_exists("pages/$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';
|
|
|
|
$pages = [];
|
|
foreach (glob("pages/*.md") as $page) {
|
|
$yaml = $parser->parse(file_get_contents($page))->getYAML();
|
|
if (!$yaml["published"]) continue;
|
|
|
|
$pages[] = [
|
|
"title" => $yaml["title"],
|
|
"description" => $yaml["description"],
|
|
"name" => basename($page, ".md"),
|
|
];
|
|
}
|
|
usort($pages, function($a, $b) { return $a["title"] <=> $b["title"]; });
|
|
|
|
// 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
|
|
<a href="https://tildegit.org/tildeverse/tilde.chat/src/branch/master/wiki">source</a> and open a PR!
|
|
</p>
|
|
<p>commits to master will be automatically deployed</p>
|
|
|
|
<hr>
|
|
<h2>pages:</h2>
|
|
<table class="table table-responsive table-hover table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>title</th>
|
|
<th>description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($pages as $page) { ?>
|
|
<tr>
|
|
<td><a href="<?=$page["name"]?>"><?=$page["title"]?></a></td>
|
|
<td><?=$page["description"] ?? ""?></td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
|
|
} else {
|
|
|
|
$pg = $parser->parse(file_get_contents("pages/$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=".">< ~wiki</a>
|
|
<h1><?=$yml['title']?></h1>
|
|
|
|
<hr>
|
|
<?=$pg->getContent()?>
|
|
<hr>
|
|
<a href="https://tildegit.org/tildeverse/tilde.chat/src/branch/master/wiki/pages/<?=$page?>.md">
|
|
<i class="fa fa-edit"></i> source
|
|
</a>
|
|
|
|
<?php }
|
|
|
|
include __DIR__.'/../footer.php';
|