posts.tx 8.2 KB

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