index_template.php 4.2 KB

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