posts.tx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <span class="title">
  2. : if ( $rss ) {
  3. <a title="RSS" class="rss" href="<: $route :>?format=rss"></a>
  4. <: $category :>:
  5. : }
  6. </span>
  7. : if ( $about_header ) {
  8. <: $about_header | mark_raw :>
  9. : }
  10. <hr class="divider" />
  11. : for $posts -> $post {
  12. : if ( $post.aclname && $in_series ) {
  13. : next;
  14. : }
  15. :if ( $tiled ) {
  16. <a href="<: $route :>/<: $post.id :>" class="tile">
  17. <div class="responsive preview" style="background-image:url(<: $post.preview :>)"></div>
  18. <p class="midtitle"><: $post.title :></p>
  19. </a>
  20. : } else {
  21. <div class="post">
  22. <h3 class='blogtitles'>
  23. <a href='/posts/<: $post.id :>'><: $post.title :></a>
  24. <a class="undecorated" href='<: $post.href :>'>🔗</a>
  25. : if ( $post.version_max ) {
  26. <form method="GET" action="/posts/<: $post.id :>" style="float:right;">
  27. <select id="<: $post.id :>-<: $post.version :>-version" name="version" class="coolbutton">
  28. : for [0..$post.version_max] -> $version {
  29. <option value="<: $version :>" <: if ($post.version == $version ) { :>selected<: } :> >v<: $version :></option>
  30. : }
  31. </select>
  32. </form>
  33. : }
  34. <span id="<: $post.id :>-<: $post.version :>-time" style="float:right; margin:.25rem;"><: $post.created :></span>
  35. <a class='usericon <: $post.user :>' title='Posted by <: $post.user :>'></a>
  36. </h3>
  37. : if ( !$post.video_href && !$post.is_image && $post.preview ) {
  38. <div style="background-image:url(<: $post.preview :>);" class="responsive preview"></div>
  39. : }
  40. : if ( $post.video_href ) {
  41. <video class="responsive" controls poster="<: $post.preview :>" >
  42. <source src="<: $post.video_href :>" type="<: $post.video_content_type :>" />
  43. Your browser does not support the video tag.
  44. </video>
  45. : }
  46. : if ( $post.audio_href ) {
  47. <audio controls>
  48. <source src="<: $post.audio_href :>" type="<: $post.audio_content_type :>" />
  49. Your browser does not support the audio tag.
  50. </audio>
  51. : }
  52. : if ( $post.is_video ) {
  53. <video class="responsive" controls poster="<: $post.preview :>" >
  54. <source src="<: $post.href :>" type="<: $post.content_type :>" />
  55. Your browser does not support the video tag.
  56. </video>
  57. : }
  58. : if ( $post.is_audio ) {
  59. <audio controls>
  60. <source src="<: $post.href :>" type="<: $post.content_type :>" />
  61. Your browser does not support the audio tag.
  62. </audio>
  63. : }
  64. : if ( $post.is_image ) {
  65. <div style="background-image:url(<: $post.href :>);" class="responsive preview"></div>
  66. : }
  67. : $post.data | mark_raw;
  68. : if ( $can_edit ) {
  69. <br />
  70. <a style="display: inline-block;" onclick="switchMenu('<: $post.id :>-<: $post.version :>');">[Edit]</a>
  71. <div id="<: $post.id :>-<: $post.version :>" style="display:none;">
  72. : include $post.type ~ ".tx" { post => $post };
  73. <form class="Submissions" action="/post/delete" method="POST" class="inline">
  74. <input type="hidden" name="id" value="<: $post.id :>"></input>
  75. <input type="hidden" name="to" value="<: $route :>"></input>
  76. <input class="coolbutton" type="submit" value="Delete"></input>
  77. </form>
  78. </div>
  79. : }
  80. <script type="text/javascript">
  81. document.addEventListener("DOMContentLoaded", function(event) {
  82. // Fix post dates to be localized
  83. var e = document.getElementById("<: $post.id :>-<: $post.version :>-time");
  84. var d = new Date(Date(e.innerText));
  85. e.innerHTML = "&nbsp;" + d.toDateString();
  86. //Make the version switcher do things
  87. var swit = document.getElementById("<: $post.id :>-<: $post.version :>-version"); // I am an elder scrolls fan
  88. swit.onchange = function (evt) {
  89. this.form.submit();
  90. };
  91. });
  92. </script>
  93. </div>
  94. <hr class="divider" />
  95. : }
  96. : }
  97. : if ( $rss ) {
  98. : include "paginator.tx";
  99. : }
  100. : if ( $about_footer ) {
  101. <: $about_footer | mark_raw :>
  102. : }