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.
 
 
 
 
 

200 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. {{template "collection-meta" .}}
  31. {{if .Collection.StyleSheet}}<style type="text/css">{{.Collection.StyleSheetDisplay}}</style>{{end}}
  32. {{if .Collection.RenderMathJax}}
  33. <!-- Add mathjax logic -->
  34. {{template "mathjax" .}}
  35. {{end}}
  36. <!-- Add highlighting logic -->
  37. {{template "highlighting" . }}
  38. </head>
  39. <body id="subpage">
  40. <div id="overlay"></div>
  41. <header>
  42. <h1 dir="{{.Direction}}" id="blog-title"><a href="{{if .IsTopLevel}}/{{else}}/{{.Collection.Alias}}/{{end}}" class="h-card p-author">{{.Collection.DisplayTitle}}</a></h1>
  43. <nav>
  44. {{if .PinnedPosts}}
  45. {{range .PinnedPosts}}<a class="pinned" href="{{if not $.SingleUser}}/{{$.Collection.Alias}}/{{.Slug.String}}{{else}}{{.CanonicalURL $.Host}}{{end}}">{{.DisplayTitle}}</a>{{end}}
  46. {{end}}
  47. </nav>
  48. </header>
  49. {{if .Silenced}}
  50. {{template "user-silenced"}}
  51. {{end}}
  52. {{if .Posts}}<section id="wrapper" itemscope itemtype="http://schema.org/Blog">{{else}}<div id="wrapper">{{end}}
  53. <h1>{{.Tag}}</h1>
  54. {{template "posts" .}}
  55. {{if .Posts}}</section>{{else}}</div>{{end}}
  56. {{ if .Collection.ShowFooterBranding }}
  57. <footer dir="ltr">
  58. <hr>
  59. <nav>
  60. <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>
  61. </nav>
  62. </footer>
  63. {{ end }}
  64. </body>
  65. {{if .CanShowScript}}
  66. {{range .ExternalScripts}}<script type="text/javascript" src="{{.}}" async></script>{{end}}
  67. {{if .Collection.Script}}<script type="text/javascript">{{.ScriptDisplay}}</script>{{end}}
  68. {{end}}
  69. <script src="/js/localdate.js"></script>
  70. {{if .IsOwner}}
  71. <script src="/js/h.js"></script>
  72. <script src="/js/postactions.js"></script>
  73. {{end}}
  74. <script type="text/javascript">
  75. {{if .IsOwner}}
  76. var deleting = false;
  77. function delPost(e, id, owned) {
  78. e.preventDefault();
  79. if (deleting) {
  80. return;
  81. }
  82. // TODO: UNDO!
  83. if (window.confirm('Are you sure you want to delete this post?')) {
  84. // AJAX
  85. deletePost(id, "", function() {
  86. // Remove post from list
  87. var $postEl = document.getElementById('post-' + id);
  88. $postEl.parentNode.removeChild($postEl);
  89. // TODO: add next post from this collection at the bottom
  90. });
  91. }
  92. }
  93. var deletePost = function(postID, token, callback) {
  94. deleting = true;
  95. var $delBtn = document.getElementById('post-' + postID).getElementsByClassName('delete action')[0];
  96. $delBtn.innerHTML = '...';
  97. var http = new XMLHttpRequest();
  98. var url = "/api/posts/" + postID;
  99. http.open("DELETE", url, true);
  100. http.onreadystatechange = function() {
  101. if (http.readyState == 4) {
  102. deleting = false;
  103. if (http.status == 204) {
  104. callback();
  105. } else if (http.status == 409) {
  106. $delBtn.innerHTML = 'delete';
  107. alert("Post is synced to another account. Delete the post from that account instead.");
  108. // TODO: show "remove" button instead of "delete" now
  109. // Persist that state.
  110. // Have it remove the post locally only.
  111. } else {
  112. $delBtn.innerHTML = 'delete';
  113. alert("Failed to delete." + (http.status>=500?" Please try again.":""));
  114. }
  115. }
  116. }
  117. http.send();
  118. };
  119. var pinning = false;
  120. function pinPost(e, postID, slug, title) {
  121. e.preventDefault();
  122. if (pinning) {
  123. return;
  124. }
  125. pinning = true;
  126. var callback = function() {
  127. // Visibly remove post from collection
  128. var $postEl = document.getElementById('post-' + postID);
  129. $postEl.parentNode.removeChild($postEl);
  130. var $header = document.getElementsByTagName('header')[0];
  131. var $pinnedNavs = $header.getElementsByTagName('nav');
  132. // Add link to nav
  133. var link = '<a class="pinned" href="{{if not .SingleUser}}/{{.Alias}}/{{end}}'+slug+'">'+title+'</a>';
  134. if ($pinnedNavs.length == 0) {
  135. $header.insertAdjacentHTML("beforeend", '<nav>'+link+'</nav>');
  136. } else {
  137. $pinnedNavs[0].insertAdjacentHTML("beforeend", link);
  138. }
  139. };
  140. var $pinBtn = document.getElementById('post-' + postID).getElementsByClassName('pin action')[0];
  141. $pinBtn.innerHTML = '...';
  142. var http = new XMLHttpRequest();
  143. var url = "/api/collections/{{.Alias}}/pin";
  144. var params = [ { "id": postID } ];
  145. http.open("POST", url, true);
  146. http.setRequestHeader("Content-type", "application/json");
  147. http.onreadystatechange = function() {
  148. if (http.readyState == 4) {
  149. pinning = false;
  150. if (http.status == 200) {
  151. callback();
  152. } else if (http.status == 409) {
  153. $pinBtn.innerHTML = 'pin';
  154. alert("Post is synced to another account. Delete the post from that account instead.");
  155. // TODO: show "remove" button instead of "delete" now
  156. // Persist that state.
  157. // Have it remove the post locally only.
  158. } else {
  159. $pinBtn.innerHTML = 'pin';
  160. alert("Failed to pin." + (http.status>=500?" Please try again.":""));
  161. }
  162. }
  163. }
  164. http.send(JSON.stringify(params));
  165. };
  166. {{end}}
  167. try { // Fonts
  168. WebFontConfig = {
  169. custom: { families: [ 'Lora:400,700:latin', 'Open+Sans:400,700:latin' ], urls: [ '/css/fonts.css' ] }
  170. };
  171. (function() {
  172. var wf = document.createElement('script');
  173. wf.src = '/js/webfont.js';
  174. wf.type = 'text/javascript';
  175. wf.async = 'true';
  176. var s = document.getElementsByTagName('script')[0];
  177. s.parentNode.insertBefore(wf, s);
  178. })();
  179. } catch (e) { /* ¯\_(ツ)_/¯ */ }
  180. </script>
  181. </html>{{end}}