posts.tx 8.3 KB

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