posts.tx 4.6 KB

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