site for the tildeverse irc network https://tilde.chat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <?php
  2. require __DIR__.'/../vendor/autoload.php';
  3. use Tildeverse\Wiki\Parser;
  4. $additional_head = "
  5. <style>
  6. :target:before {
  7. content:\"\";
  8. display:block;
  9. height:90px; /* fixed header height*/
  10. margin:-90px 0 0; /* negative fixed header height */
  11. }
  12. </style>
  13. <meta property='og:type' content='website'>
  14. <meta property='og:site_name' content='tilde.chat wiki'>
  15. ";
  16. $parser = Parser::factory();
  17. if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
  18. $title = "tilde.chat~wiki";
  19. $additional_head .= "
  20. <meta property='og:title' content='$title'>
  21. <meta property='og:url' content='https://tilde.chat{$_SERVER['REQUEST_URI']}'>
  22. <meta property='og:description' content='tilde.chat wiki'>
  23. ";
  24. include __DIR__.'/../header.php';
  25. // render wiki index ?>
  26. <h1>tilde.chat wiki</h1>
  27. <p>welcome to the tilde.chat wiki!</p>
  28. <p>if you want to contribute, check out the
  29. <a href="https://tildegit.org/tildeverse/tilde.chat/src/branch/master/wiki">source</a> and open a PR!
  30. </p>
  31. <hr>
  32. <h3>pages:</h3>
  33. <?php
  34. foreach (glob("pages/*.md") as $page) {
  35. $yaml = $parser->parse(file_get_contents($page))->getYAML();
  36. if (!$yaml["published"]) continue; ?>
  37. <a href="?page=<?=basename($page, ".md")?>"><?=$yaml["title"]?></a><br>
  38. <?php }
  39. } else {
  40. $pg = $parser->parse(file_get_contents("pages/{$_GET["page"]}.md"));
  41. $yml = $pg->getYAML();
  42. $title = $yml['title'] . " | tilde.chat~wiki";
  43. $description = $yml['description'] ?? "tilde.chat wiki article {$yml['title']}";
  44. $additional_head .= "
  45. <meta property='og:title' content='$title'>
  46. <meta property='og:url' content='https://tilde.chat{$_SERVER['REQUEST_URI']}'>
  47. <meta property='og:description' content='$description'>
  48. ";
  49. include __DIR__.'/../header.php';
  50. // show a single page ?>
  51. <a href=".">&lt; ~wiki</a>
  52. <hr>
  53. <?=$pg->getContent()?>
  54. <hr>
  55. <a href="https://tildegit.org/tildeverse/tilde.chat/src/branch/master/wiki/pages/<?=$_GET["page"]?>.md">
  56. <i class="fa fa-edit"></i> source
  57. </a>
  58. <?php }
  59. include __DIR__.'/../footer.php';