index_template.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. function index_start($index_type, $arg) {
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="<?php echo(SITE_LANGUAGE);?>">
  6. <head>
  7. <meta charset="utf-8">
  8. <title><?php echo(PUBLICATION_NAME)?> Index - <?php echo(SITE_NAME);?></title>
  9. <link rel="stylesheet" href="<?php echo(SITE_URL);?>/vanilla.css">
  10. <link rel="alternate" type="application/rss+xml" title="<?php echo(SITE_NAME);?> RSS Feed" href="<?php echo(SITE_URL);?>/feed.rss" />
  11. <style type="text/css">
  12. aside {
  13. float: right;
  14. border: 1px solid var(--text-color);
  15. padding: 16px;
  16. max-width: 100vw;
  17. width: 316px;
  18. margin: 0px 0px 15px 0px;
  19. }
  20. ul.tags {
  21. list-style: none;
  22. padding-left: 0px;
  23. margin: 0px;
  24. }
  25. ul.tags li {
  26. display: inline;
  27. }
  28. details summary {
  29. cursor: pointer;
  30. }
  31. @media screen and (max-width: 75ch) {
  32. aside {
  33. float: none;
  34. width: 100%;
  35. }
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <header>
  41. <h1><a style="color: var(--text-color); text-decoration: none;" href="<?php echo(SITE_URL);?>"><?php echo(SITE_NAME);?></a></h1>
  42. </header>
  43. <?php
  44. if(USE_PPIX and $index_type == INDEX_TYPE_MAIN) {
  45. ?>
  46. <aside>
  47. <form action="./" >
  48. <label for="q">Search this site:</label><br>
  49. <input style="width: 100%;" type="text" id="q" name="q" placeholder="Search...">
  50. </form>
  51. <?php
  52. if(count($arg) > 0) { ?>
  53. <details>
  54. <summary>Browse by tags</summary>
  55. <ul class="tags">
  56. <?php
  57. foreach ($arg as $tag) {
  58. ?>
  59. <li><a href="?tag=<?php echo(urlencode($tag));?>"><?php echo(htmlentities($tag));?></a></li>
  60. <?php
  61. }
  62. ?>
  63. </ul>
  64. </details>
  65. <?php } ?>
  66. </aside>
  67. <?php
  68. }
  69. if($index_type == INDEX_TYPE_MAIN) {
  70. ?>
  71. <h2><?php echo(PUBLICATION_NAME)?> Index</h2>
  72. <?php
  73. }
  74. if($index_type == INDEX_TYPE_TAG) {
  75. ?>
  76. <h2>Tagged with <em><?php echo(htmlentities($arg));?></em></h2>
  77. <?php
  78. }
  79. if($index_type == INDEX_TYPE_SEARCH) {
  80. ?>
  81. <form action="./">
  82. <label for="q">Search query:</label><br>
  83. <input style="width: 100%;" type="text" id="q" name="q" value="<?php echo(htmlentities($arg));?>">
  84. </form>
  85. <!-- <hr/> -->
  86. <!-- <h2>Search Results</h2> -->
  87. <?php
  88. }
  89. ?>
  90. <dl>
  91. <?php
  92. }
  93. function index_no_content($index_type, $arg) {
  94. if($index_type == INDEX_TYPE_SEARCH) {
  95. echo("<p>Nothing found for search query &quot;" . htmlentities($arg) . "&quot.</p>");
  96. }
  97. }
  98. function index_listing($ppub, $url) {
  99. ?>
  100. <dt><a href="<?php echo($url);?>"><?php echo(htmlentities($ppub->metadata["title"]));?></a></dt>
  101. <dd><?php echo(htmlentities($ppub->metadata["description"]));?></dd>
  102. <?php
  103. }
  104. function index_end() {
  105. ?>
  106. </dl>
  107. <footer>
  108. <hr>
  109. <p><strong><?php echo($_SERVER['SERVER_NAME'])?></strong> | <a href="<?php echo(SITE_URL);?>/feed.rss">Subscribe to <?php echo(SITE_NAME);?> RSS</a>
  110. <br/><small>Powered by <a href="https://github.com/Tilo15/php-ppub">php-ppub</a> and <a href="https://parsedown.org">Parsedown</a>, styled with <a href="https://vanillacss.com/">Vanilla CSS</a>.</small></p>
  111. </footer>
  112. </body>
  113. </html>
  114. <?php
  115. }
  116. ?>