posts.tx 8.3 KB

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