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.
 
 
 
 
 

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