92 lines
2.7 KiB
PHP
92 lines
2.7 KiB
PHP
<?php
|
|
$filepath = __FILE__;
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
use tildeteam\wiki;
|
|
|
|
$additional_head = "
|
|
<meta property='og:type' content='website'>
|
|
<meta property='og:image' content='https://tilde.team/apple-icon.png'>
|
|
<meta property='og:site_name' content='tilde.team wiki'>
|
|
";
|
|
|
|
$parser = wiki::factory(true);
|
|
|
|
if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
|
|
|
|
$title = "tilde.team~wiki";
|
|
$additional_head .= "
|
|
<meta property='og:title' content='$title'>
|
|
<meta property='og:url' content='https://tilde.team{$_SERVER['REQUEST_URI']}'>
|
|
<meta property='og:description' content='tilde.team 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.team wiki</h1>
|
|
|
|
<p>welcome to the tilde.team wiki!</p>
|
|
|
|
<p>if you want to contribute, check out the
|
|
<a href="https://tildegit.org/team/site/src/branch/master/wiki">source</a> and open a PR!
|
|
</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/{$_GET["page"]}.md"));
|
|
$yml = $pg->getYAML();
|
|
$title = $yml['title'] . " | tilde.team~wiki";
|
|
$description = $yml['description'] ?? "tilde.team wiki article {$yml['title']}";
|
|
$additional_head .= "
|
|
<meta property='og:title' content='$title'>
|
|
<meta property='og:url' content='https://tilde.team{$_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>
|
|
|
|
<?=$pg->getContent()?>
|
|
<hr>
|
|
<a href="https://tildegit.org/team/site/src/branch/master/wiki/pages/<?=$_GET["page"]?>.md">
|
|
<i class="fa fa-edit"></i> source
|
|
</a>
|
|
|
|
<?php }
|
|
|
|
include __DIR__.'/../footer.php';
|