A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

199 lines
7.0 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 .Silenced}}
  49. {{template "user-silenced"}}
  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. <script src="/js/localdate.js"></script>
  69. {{if .IsOwner}}
  70. <script src="/js/h.js"></script>
  71. <script src="/js/postactions.js"></script>
  72. {{end}}
  73. <script type="text/javascript">
  74. {{if .IsOwner}}
  75. var deleting = false;
  76. function delPost(e, id, owned) {
  77. e.preventDefault();
  78. if (deleting) {
  79. return;
  80. }
  81. // TODO: UNDO!
  82. if (window.confirm('Are you sure you want to delete this post?')) {
  83. // AJAX
  84. deletePost(id, "", function() {
  85. // Remove post from list
  86. var $postEl = document.getElementById('post-' + id);
  87. $postEl.parentNode.removeChild($postEl);
  88. // TODO: add next post from this collection at the bottom
  89. });
  90. }
  91. }
  92. var deletePost = function(postID, token, callback) {
  93. deleting = true;
  94. var $delBtn = document.getElementById('post-' + postID).getElementsByClassName('delete action')[0];
  95. $delBtn.innerHTML = '...';
  96. var http = new XMLHttpRequest();
  97. var url = "/api/posts/" + postID;
  98. http.open("DELETE", url, true);
  99. http.onreadystatechange = function() {
  100. if (http.readyState == 4) {
  101. deleting = false;
  102. if (http.status == 204) {
  103. callback();
  104. } else if (http.status == 409) {
  105. $delBtn.innerHTML = 'delete';
  106. alert("Post is synced to another account. Delete the post from that account instead.");
  107. // TODO: show "remove" button instead of "delete" now
  108. // Persist that state.
  109. // Have it remove the post locally only.
  110. } else {
  111. $delBtn.innerHTML = 'delete';
  112. alert("Failed to delete." + (http.status>=500?" Please try again.":""));
  113. }
  114. }
  115. }
  116. http.send();
  117. };
  118. var pinning = false;
  119. function pinPost(e, postID, slug, title) {
  120. e.preventDefault();
  121. if (pinning) {
  122. return;
  123. }
  124. pinning = true;
  125. var callback = function() {
  126. // Visibly remove post from collection
  127. var $postEl = document.getElementById('post-' + postID);
  128. $postEl.parentNode.removeChild($postEl);
  129. var $header = document.getElementsByTagName('header')[0];
  130. var $pinnedNavs = $header.getElementsByTagName('nav');
  131. // Add link to nav
  132. var link = '<a class="pinned" href="{{if not .SingleUser}}/{{.Alias}}/{{end}}'+slug+'">'+title+'</a>';
  133. if ($pinnedNavs.length == 0) {
  134. $header.insertAdjacentHTML("beforeend", '<nav>'+link+'</nav>');
  135. } else {
  136. $pinnedNavs[0].insertAdjacentHTML("beforeend", link);
  137. }
  138. };
  139. var $pinBtn = document.getElementById('post-' + postID).getElementsByClassName('pin action')[0];
  140. $pinBtn.innerHTML = '...';
  141. var http = new XMLHttpRequest();
  142. var url = "/api/collections/{{.Alias}}/pin";
  143. var params = [ { "id": postID } ];
  144. http.open("POST", url, true);
  145. http.setRequestHeader("Content-type", "application/json");
  146. http.onreadystatechange = function() {
  147. if (http.readyState == 4) {
  148. pinning = false;
  149. if (http.status == 200) {
  150. callback();
  151. } else if (http.status == 409) {
  152. $pinBtn.innerHTML = 'pin';
  153. alert("Post is synced to another account. Delete the post from that account instead.");
  154. // TODO: show "remove" button instead of "delete" now
  155. // Persist that state.
  156. // Have it remove the post locally only.
  157. } else {
  158. $pinBtn.innerHTML = 'pin';
  159. alert("Failed to pin." + (http.status>=500?" Please try again.":""));
  160. }
  161. }
  162. }
  163. http.send(JSON.stringify(params));
  164. };
  165. {{end}}
  166. try { // Fonts
  167. WebFontConfig = {
  168. custom: { families: [ 'Lora:400,700:latin', 'Open+Sans:400,700:latin' ], urls: [ '/css/fonts.css' ] }
  169. };
  170. (function() {
  171. var wf = document.createElement('script');
  172. wf.src = '/js/webfont.js';
  173. wf.type = 'text/javascript';
  174. wf.async = 'true';
  175. var s = document.getElementsByTagName('script')[0];
  176. s.parentNode.insertBefore(wf, s);
  177. })();
  178. } catch (e) { /* ¯\_(ツ)_/¯ */ }
  179. </script>
  180. </html>{{end}}