posts.tx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. : if ( $can_edit ) {
  2. <script type="text/javascript" src="/scripts/post.js"></script>
  3. : if (!$direct) {
  4. : include "jsalert.tx";
  5. <a style="cursor:pointer" onclick="switchMenu('submissions')">[Add Post]</a><hr />
  6. <div id="submissions" style="display:none">
  7. : include $edittype ~ ".tx";
  8. </div>
  9. <script type="text/javascript" src="/scripts/fgEmojiPicker.js"></script>
  10. <script type="text/javascript">
  11. new FgEmojiPicker({
  12. trigger: ['button.emojiPicker'],
  13. position: ['bottom'],
  14. dir: `/scripts/`,
  15. emit(obj, triggerElement) {
  16. const emoji = obj.emoji;
  17. document.querySelector('textarea').value += emoji;
  18. }
  19. });
  20. </script>
  21. : }
  22. : }
  23. <span class="title">
  24. : if ( $rss ) {
  25. <a title="RSS" class="rss" href="<: $route :>?format=rss"></a>
  26. <: $category :>:
  27. : }
  28. </span>
  29. : if ( $in_series && $rss ) {
  30. <div class="subhead">
  31. <: $subhead | mark_raw :>
  32. </div>
  33. : }
  34. : if ( $header ) {
  35. <: $header | mark_raw :>
  36. : }
  37. : if (!$style) {
  38. <hr class="divider" />
  39. : }
  40. : for $posts -> $post {
  41. : if ( $post.aclname && $in_series ) {
  42. : next;
  43. : }
  44. : if ( $post.is_profile && $post.user == 'Nobody' ) {
  45. : next;
  46. : }
  47. :if ( $tiled ) {
  48. : if ($post.is_profile) {
  49. <a href="/users/<: $post.user :>" class="tile">
  50. : } else {
  51. <a href="<: $route :>/<: $post.id :>" class="tile">
  52. : }
  53. : if ($post.is_video) {
  54. <video preload="none" class="responsive" controls poster="<: $post.preview :>" >
  55. <source src="<: $post.href :>" type="<: $post.content_type :>" />
  56. Your browser does not support the video tag.
  57. </video>
  58. : } else {
  59. : if ($post.is_profile) {
  60. <div class="square circle bigprofile preview" style="background-image:url(<: $post.preview :>)"></div>
  61. : } else {
  62. <div class="responsive preview" style="background-image:url(<: $post.preview :>)"></div>
  63. : }
  64. : }
  65. <p class="midtitle"><: $post.title :></p>
  66. </a>
  67. : } else {
  68. <div class="post <: $style :>">
  69. : if (!$post.is_profile) {
  70. <h3 class='blogtitles'>
  71. : if (!$style || $style == 'embed') {
  72. <a ><a href='<: $post.href :>' ><: $post.title :></a>
  73. <a class="undecorated" href='/posts/<: $post.id :>'>🔗</a>
  74. : }
  75. : if (!$style) {
  76. : if ( $post.version_max && !$rss ) {
  77. <form method="GET" action="/posts/<: $post.id :>" style="float:right;">
  78. <select id="<: $post.id :>-<: $post.version :>-version" name="version" class="coolbutton">
  79. : for [0..$post.version_max] -> $version {
  80. <option value="<: $version :>" <: if ($post.version == $version ) { :>selected<: } :> >v<: $version :></option>
  81. : }
  82. </select>
  83. </form>
  84. : }
  85. <span id="<: $post.id :>-<: $post.version :>-time" class="responsive-hide" style="float:right;"><: $post.created :></span>
  86. <a class='postericon <: $post.user :>' title='Posted by <: $post.user :>'>&nbsp;</a>
  87. : }
  88. </h3>
  89. : }
  90. : if ( !$post.video_href && !$post.is_image && !$post.is_video && !$post.is_profile && $post.preview ) {
  91. <div style="background-image:url(<: $post.preview :>);" class="responsive preview"></div>
  92. : }
  93. : if ( $post.video_href ) {
  94. <video preload="none" class="responsive" controls poster="<: $post.preview :>" >
  95. <source src="<: $post.video_href :>" type="<: $post.video_content_type :>" />
  96. Your browser does not support the video tag.
  97. </video>
  98. : }
  99. : if ( $post.audio_href ) {
  100. <audio controls>
  101. <source src="<: $post.audio_href :>" type="<: $post.audio_content_type :>" />
  102. Your browser does not support the audio tag.
  103. </audio>
  104. : }
  105. : if ( $post.is_video ) {
  106. <video preload="none" class="responsive" controls poster="<: $post.preview :>" >
  107. <source src="<: $post.href :>" type="<: $post.content_type :>" />
  108. Your browser does not support the video tag.
  109. </video>
  110. : }
  111. : if ( $post.is_audio ) {
  112. <audio controls>
  113. <source src="<: $post.href :>" type="<: $post.content_type :>" />
  114. Your browser does not support the audio tag.
  115. </audio>
  116. : }
  117. : if ( $post.is_image ) {
  118. <div style="background-image:url(<: $post.href :>);" class="responsive preview"></div>
  119. : }
  120. : if ( $post.is_profile ) {
  121. <div style="background-image:url(<: $post.wallpaper :>);" class="banner profile">
  122. <div style="background-image:url(<: $post.preview :>);" class="circle portrait"></div>
  123. : }
  124. : if( $post.data ) {
  125. : if ($post.is_video || $post.is_image) {
  126. <div id="postData" class="responsive-text">
  127. : } else {
  128. <div id="postData">
  129. : }
  130. : if ( $post.is_profile ) {
  131. <h3><: $post.title :></h3>
  132. : }
  133. : if ( $style != 'media' ) {
  134. <: render_it($post.data) | mark_raw :>
  135. : }
  136. </div>
  137. : }
  138. : if( $post.is_profile ) {
  139. </div><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.type ~ ".tx" { 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 ( $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>