A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

198 řádky
6.9 KiB

  1. {{define "collection-tags"}}<!DOCTYPE HTML>
  2. <html>
  3. <head prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article#">
  4. <meta charset="utf-8">
  5. <title>{{.Tag}} &mdash; {{.Collection.DisplayTitle}}</title>
  6. <link rel="stylesheet" type="text/css" href="/css/write.css" />
  7. <link rel="shortcut icon" href="/favicon.ico" />
  8. {{if not .Collection.IsPrivate}}<link rel="alternate" type="application/rss+xml" title="{{.Tag}} posts on {{.DisplayTitle}}" href="{{.CanonicalURL}}tag:{{.Tag}}/feed/" />{{end}}
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  10. <link rel="canonical" href="{{.CanonicalURL}}tag:{{.Tag | tolower}}" />
  11. <meta name="generator" content="Write.as">
  12. <meta name="title" content="{{.Tag}} &mdash; {{.Collection.DisplayTitle}}">
  13. <meta name="description" content="{{.Tag}} posts on {{.Collection.DisplayTitle}}">
  14. <meta name="application-name" content="Write.as">
  15. <meta name="application-url" content="https://write.as">
  16. {{if gt .Views 1}}<meta name="twitter:label1" value="Views">
  17. <meta name="twitter:data1" value="{{largeNumFmt .Views}}">{{end}}
  18. <meta itemprop="name" content="{{.Collection.DisplayTitle}}">
  19. <meta itemprop="description" content="{{.Tag}} posts on {{.Collection.DisplayTitle}}">
  20. <meta name="twitter:card" content="summary">
  21. <meta name="twitter:site" content="@writeas__">
  22. <meta name="twitter:description" content="{{.Tag}} posts on {{.Collection.DisplayTitle}}">
  23. <meta name="twitter:title" content="{{.Tag}} &mdash; {{.Collection.DisplayTitle}}">
  24. <meta name="twitter:image" content="{{.Collection.AvatarURL}}">
  25. <meta property="og:title" content="{{.Tag}} &mdash; {{.Collection.DisplayTitle}}" />
  26. <meta property="og:site_name" content="{{.DisplayTitle}}" />
  27. <meta property="og:type" content="article" />
  28. <meta property="og:url" content="{{.CanonicalURL}}tag:{{.Tag}}" />
  29. <meta property="og:image" content="{{.Collection.AvatarURL}}">
  30. {{if .Collection.StyleSheet}}<style type="text/css">{{.Collection.StyleSheetDisplay}}</style>{{end}}
  31. {{if .Collection.RenderMathJax}}
  32. <!-- Add mathjax logic -->
  33. {{template "mathjax" .}}
  34. {{end}}
  35. <!-- Add highlighting logic -->
  36. {{template "highlighting" . }}
  37. </head>
  38. <body id="subpage">
  39. <div id="overlay"></div>
  40. <header>
  41. <h1 dir="{{.Direction}}" id="blog-title"><a href="{{if .IsTopLevel}}/{{else}}/{{.Collection.Alias}}/{{end}}" class="h-card p-author">{{.Collection.DisplayTitle}}</a></h1>
  42. <nav>
  43. {{if .PinnedPosts}}
  44. {{range .PinnedPosts}}<a class="pinned" href="{{if not $.SingleUser}}/{{$.Collection.Alias}}/{{.Slug.String}}{{else}}{{.CanonicalURL $.Host}}{{end}}">{{.DisplayTitle}}</a>{{end}}
  45. {{end}}
  46. </nav>
  47. </header>
  48. {{if .Suspended}}
  49. {{template "user-suspended"}}
  50. {{end}}
  51. {{if .Posts}}<section id="wrapper" itemscope itemtype="http://schema.org/Blog">{{else}}<div id="wrapper">{{end}}
  52. <h1>{{.Tag}}</h1>
  53. {{template "posts" .}}
  54. {{if .Posts}}</section>{{else}}</div>{{end}}
  55. {{ if .Collection.ShowFooterBranding }}
  56. <footer dir="ltr">
  57. <hr>
  58. <nav>
  59. <p style="font-size: 0.9em"><a class="home pubd" href="/">{{.SiteName}}</a> &middot; powered by <a style="margin-left:0" href="https://writefreely.org">writefreely</a></p>
  60. </nav>
  61. </footer>
  62. {{ end }}
  63. </body>
  64. {{if .CanShowScript}}
  65. {{range .ExternalScripts}}<script type="text/javascript" src="{{.}}" async></script>{{end}}
  66. {{if .Collection.Script}}<script type="text/javascript">{{.ScriptDisplay}}</script>{{end}}
  67. {{end}}
  68. {{if .IsOwner}}
  69. <script src="/js/h.js"></script>
  70. <script src="/js/postactions.js"></script>
  71. {{end}}
  72. <script type="text/javascript">
  73. {{if .IsOwner}}
  74. var deleting = false;
  75. function delPost(e, id, owned) {
  76. e.preventDefault();
  77. if (deleting) {
  78. return;
  79. }
  80. // TODO: UNDO!
  81. if (window.confirm('Are you sure you want to delete this post?')) {
  82. // AJAX
  83. deletePost(id, "", function() {
  84. // Remove post from list
  85. var $postEl = document.getElementById('post-' + id);
  86. $postEl.parentNode.removeChild($postEl);
  87. // TODO: add next post from this collection at the bottom
  88. });
  89. }
  90. }
  91. var deletePost = function(postID, token, callback) {
  92. deleting = true;
  93. var $delBtn = document.getElementById('post-' + postID).getElementsByClassName('delete action')[0];
  94. $delBtn.innerHTML = '...';
  95. var http = new XMLHttpRequest();
  96. var url = "/api/posts/" + postID;
  97. http.open("DELETE", url, true);
  98. http.onreadystatechange = function() {
  99. if (http.readyState == 4) {
  100. deleting = false;
  101. if (http.status == 204) {
  102. callback();
  103. } else if (http.status == 409) {
  104. $delBtn.innerHTML = 'delete';
  105. alert("Post is synced to another account. Delete the post from that account instead.");
  106. // TODO: show "remove" button instead of "delete" now
  107. // Persist that state.
  108. // Have it remove the post locally only.
  109. } else {
  110. $delBtn.innerHTML = 'delete';
  111. alert("Failed to delete." + (http.status>=500?" Please try again.":""));
  112. }
  113. }
  114. }
  115. http.send();
  116. };
  117. var pinning = false;
  118. function pinPost(e, postID, slug, title) {
  119. e.preventDefault();
  120. if (pinning) {
  121. return;
  122. }
  123. pinning = true;
  124. var callback = function() {
  125. // Visibly remove post from collection
  126. var $postEl = document.getElementById('post-' + postID);
  127. $postEl.parentNode.removeChild($postEl);
  128. var $header = document.getElementsByTagName('header')[0];
  129. var $pinnedNavs = $header.getElementsByTagName('nav');
  130. // Add link to nav
  131. var link = '<a class="pinned" href="{{if not .SingleUser}}/{{.Alias}}/{{end}}'+slug+'">'+title+'</a>';
  132. if ($pinnedNavs.length == 0) {
  133. $header.insertAdjacentHTML("beforeend", '<nav>'+link+'</nav>');
  134. } else {
  135. $pinnedNavs[0].insertAdjacentHTML("beforeend", link);
  136. }
  137. };
  138. var $pinBtn = document.getElementById('post-' + postID).getElementsByClassName('pin action')[0];
  139. $pinBtn.innerHTML = '...';
  140. var http = new XMLHttpRequest();
  141. var url = "/api/collections/{{.Alias}}/pin";
  142. var params = [ { "id": postID } ];
  143. http.open("POST", url, true);
  144. http.setRequestHeader("Content-type", "application/json");
  145. http.onreadystatechange = function() {
  146. if (http.readyState == 4) {
  147. pinning = false;
  148. if (http.status == 200) {
  149. callback();
  150. } else if (http.status == 409) {
  151. $pinBtn.innerHTML = 'pin';
  152. alert("Post is synced to another account. Delete the post from that account instead.");
  153. // TODO: show "remove" button instead of "delete" now
  154. // Persist that state.
  155. // Have it remove the post locally only.
  156. } else {
  157. $pinBtn.innerHTML = 'pin';
  158. alert("Failed to pin." + (http.status>=500?" Please try again.":""));
  159. }
  160. }
  161. }
  162. http.send(JSON.stringify(params));
  163. };
  164. {{end}}
  165. try { // Fonts
  166. WebFontConfig = {
  167. custom: { families: [ 'Lora:400,700:latin', 'Open+Sans:400,700:latin' ], urls: [ '/css/fonts.css' ] }
  168. };
  169. (function() {
  170. var wf = document.createElement('script');
  171. wf.src = '/js/webfont.js';
  172. wf.type = 'text/javascript';
  173. wf.async = 'true';
  174. var s = document.getElementsByTagName('script')[0];
  175. s.parentNode.insertBefore(wf, s);
  176. })();
  177. } catch (e) { /* ¯\_(ツ)_/¯ */ }
  178. </script>
  179. </html>{{end}}