posts.tx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. : if ( $can_edit ) {
  2. <script type="text/javascript" src="/scripts/post.js"></script>
  3. : if (!$direct) {
  4. : if ($to) {
  5. : include "jsalert.tx";
  6. : }
  7. : if ($edittype) {
  8. <a style="cursor:pointer" onclick="switchMenu('submissions')">[Add Post]</a><hr />
  9. <div id="submissions" style="display:none">
  10. : include $edittype;
  11. </div>
  12. : }
  13. <script type="text/javascript" src="/scripts/fgEmojiPicker.js"></script>
  14. <script type="text/javascript">
  15. new FgEmojiPicker({
  16. trigger: ['button.emojiPicker'],
  17. position: ['bottom'],
  18. dir: `/scripts/`,
  19. emit(obj, triggerElement) {
  20. const emoji = obj.emoji;
  21. document.querySelector('textarea').value += emoji;
  22. }
  23. });
  24. </script>
  25. : }
  26. : }
  27. <span class="title">
  28. : if ( $rss ) {
  29. <a title="RSS" class="rss" href="<: $route :>?format=rss"></a>
  30. <: $category :>:
  31. : }
  32. </span>
  33. : if ( $in_series && $rss ) {
  34. <div class="subhead">
  35. <: $subhead | mark_raw :>
  36. </div>
  37. : }
  38. : if ( $header ) {
  39. <: $header | mark_raw :>
  40. : }
  41. : if (!$style) {
  42. <hr class="divider" />
  43. : }
  44. : for $posts -> $post {
  45. : if ( !$post.form ) {
  46. : next;
  47. : }
  48. :if ( $tiled ) {
  49. <a href="<: $post.local_href :>" class="tile">
  50. : if ($post.is_video) {
  51. <video preload="none" class="responsive" controls poster="<: $post.preview :>" >
  52. <source src="<: $post.href :>" type="<: $post.content_type :>" />
  53. Your browser does not support the video tag.
  54. </video>
  55. : } else {
  56. : if ($post.is_profile) {
  57. <div class="square circle bigprofile preview" style="background-image:url(<: $post.preview :>)"></div>
  58. : } else {
  59. <div class="responsive preview" style="background-image:url(<: $post.preview :>)"></div>
  60. : }
  61. : }
  62. <p class="midtitle"><: $post.title :></p>
  63. </a>
  64. : } else {
  65. <div class="post <: $style :>">
  66. : if (!$post.is_profile) {
  67. <h3 class='blogtitles'>
  68. : if (!$style || $style == 'embed') {
  69. <a ><a href='<: $post.href :>' ><: $post.title :></a>
  70. <a class="undecorated" href='<: $post.local_href :>'>🔗</a>
  71. : }
  72. : if (!$style) {
  73. : if ( $post.version_max && !$rss ) {
  74. <form method="GET" action="<: $post.local_href :>" style="float:right;">
  75. <select id="<: $post.id :>-<: $post.version :>-version" name="version" class="coolbutton">
  76. : for [0..$post.version_max] -> $version {
  77. <option value="<: $version :>" <: if ($post.version == $version ) { :>selected<: } :> >v<: $version :></option>
  78. : }
  79. </select>
  80. </form>
  81. : }
  82. <span id="<: $post.id :>-<: $post.version :>-time" class="responsive-hide" style="float:right;"><: $post.created :></span>
  83. <a href="/users/<: $post.user :>" class='postericon <: $post.user :>' title='Posted by <: $post.user :>'>&nbsp;</a>
  84. : }
  85. </h3>
  86. : }
  87. : if ( !$post.video_href && !$post.is_image && !$post.is_video && !$post.is_profile && $post.preview ) {
  88. <div style="background-image:url(<: $post.preview :>);" class="responsive preview"></div>
  89. : }
  90. : if ( $post.video_href ) {
  91. <video preload="none" class="responsive" controls poster="<: $post.preview :>" >
  92. <source src="<: $post.video_href :>" type="<: $post.video_content_type :>" />
  93. Your browser does not support the video tag.
  94. </video>
  95. : }
  96. : if ( $post.audio_href ) {
  97. <audio controls>
  98. <source src="<: $post.audio_href :>" type="<: $post.audio_content_type :>" />
  99. Your browser does not support the audio tag.
  100. </audio>
  101. : }
  102. : if ( $post.is_video ) {
  103. <video preload="none" class="responsive" controls poster="<: $post.preview :>" >
  104. <source src="<: $post.href :>" type="<: $post.content_type :>" />
  105. Your browser does not support the video tag.
  106. </video>
  107. : }
  108. : if ( $post.is_audio ) {
  109. <audio controls>
  110. <source src="<: $post.href :>" type="<: $post.content_type :>" />
  111. Your browser does not support the audio tag.
  112. </audio>
  113. : }
  114. : if ( $post.is_image ) {
  115. <div style="background-image:url(<: $post.href :>);" class="responsive preview"></div>
  116. : }
  117. : if ( $post.is_profile ) {
  118. <a href="<: $post.local_href :>" title="<: $post.title :> poasts">
  119. <div style="background-image:url(<: $post.wallpaper :>);" class="banner profile">
  120. <div style="background-image:url(<: $post.preview :>);" class="circle portrait"></div>
  121. : }
  122. : if( $post.data ) {
  123. : if ($post.is_video || $post.is_image) {
  124. <div id="postData" class="responsive-text">
  125. : } elsif ($post.is_profile) {
  126. <div id="postData" class="nameBadge">
  127. : } else {
  128. <div id="postData">
  129. : }
  130. : if ( $post.is_profile ) {
  131. <big><: $post.title :></big><br /><br />
  132. : }
  133. : if ( $style != 'media' ) {
  134. <: render_it($post.data) | mark_raw :>
  135. : }
  136. </div>
  137. : }
  138. : if( $post.is_profile ) {
  139. </div></a><br />
  140. : }
  141. : if ( $can_edit ) {
  142. <br />
  143. <a style="display: inline-block;cursor:pointer;" onclick="switchMenu('<: $post.id :>-<: $post.version :>');">[Edit]</a>
  144. <div id="<: $post.id :>-<: $post.version :>" style="display:none;">
  145. : include $post.form { post => $post };
  146. <form class="Submissions" action="/post/delete" method="POST" class="inline">
  147. <input type="hidden" name="id" value="<: $post.id :>"></input>
  148. <input type="hidden" name="to" value="<: $route :>"></input>
  149. <input class="coolbutton" type="submit" value="Delete"></input>
  150. </form>
  151. </div>
  152. : }
  153. : if (!$post.is_profile) {
  154. <script type="text/javascript">
  155. document.addEventListener("DOMContentLoaded", function(event) {
  156. // Fix post dates to be localized
  157. var e = document.getElementById("<: $post.id :>-<: $post.version :>-time");
  158. if (!e) {
  159. return;
  160. }
  161. var d = new Date(0);
  162. d.setUTCSeconds(e.innerText);
  163. e.innerHTML = "&nbsp;" + d.toDateString();
  164. //Make the version switcher do things
  165. var swit = document.getElementById("<: $post.id :>-<: $post.version :>-version"); // I am an elder scrolls fan
  166. if (swit) {
  167. swit.onchange = function (evt) {
  168. this.form.submit();
  169. };
  170. }
  171. });
  172. </script>
  173. : }
  174. </div>
  175. : if ($posts.size() > 1) {
  176. <hr class="divider" />
  177. : }
  178. : }
  179. : }
  180. : if ( !$direct && ( $rss || $older ) ) {
  181. : include "paginator.tx";
  182. : }
  183. : if ( $footer ) {
  184. <: $footer | mark_raw :>
  185. : }
  186. <script>
  187. document.addEventListener("DOMContentLoaded", function(event) {
  188. var pagin = document.getElementById("paginatorTime");
  189. if (pagin) {
  190. var dracula = new Date(0);
  191. dracula.setUTCSeconds(pagin.innerText);
  192. pagin.innerHTML = "&nbsp;" + dracula.toDateString();
  193. }
  194. });
  195. </script>