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.
 
 
 
 
 

237 lines
8.8 KiB

  1. {{define "collection"}}<!DOCTYPE HTML>
  2. <html {{if .Language}}lang="{{.Language}}"{{end}} dir="{{.Direction}}">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>{{.DisplayTitle}}{{if not .SingleUser}} &mdash; {{.SiteName}}{{end}}</title>
  6. <link rel="stylesheet" type="text/css" href="/css/write.css" />
  7. {{if .CustomCSS}}<link rel="stylesheet" type="text/css" href="/local/custom.css" />{{end}}
  8. <link rel="shortcut icon" href="/favicon.ico" />
  9. <link rel="canonical" href="{{.CanonicalURL}}">
  10. {{if gt .CurrentPage 1}}<link rel="prev" href="{{.PrevPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">{{end}}
  11. {{if lt .CurrentPage .TotalPages}}<link rel="next" href="{{.NextPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">{{end}}
  12. {{if not .IsPrivate}}<link rel="alternate" type="application/rss+xml" title="{{.DisplayTitle}} &raquo; Feed" href="{{.CanonicalURL}}feed/" />{{end}}
  13. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  14. <meta name="generator" content="WriteFreely">
  15. <meta name="description" content="{{.Description}}">
  16. <meta itemprop="name" content="{{.DisplayTitle}}">
  17. <meta itemprop="description" content="{{.Description}}">
  18. <meta name="twitter:card" content="summary">
  19. <meta name="twitter:title" content="{{.DisplayTitle}}">
  20. <meta name="twitter:image" content="{{.AvatarURL}}">
  21. <meta name="twitter:description" content="{{.Description}}">
  22. <meta property="og:title" content="{{.DisplayTitle}}" />
  23. <meta property="og:site_name" content="{{.DisplayTitle}}" />
  24. <meta property="og:type" content="article" />
  25. <meta property="og:url" content="{{.CanonicalURL}}" />
  26. <meta property="og:description" content="{{.Description}}" />
  27. <meta property="og:image" content="{{.AvatarURL}}">
  28. {{template "collection-meta" .}}
  29. {{if .StyleSheet}}<style type="text/css">{{.StyleSheetDisplay}}</style>{{end}}
  30. <style type="text/css">
  31. body#collection header {
  32. max-width: 40em;
  33. margin: 1em auto;
  34. text-align: left;
  35. padding: 0;
  36. }
  37. body#collection header.multiuser {
  38. max-width: 100%;
  39. margin: 1em;
  40. }
  41. body#collection header nav:not(.pinned-posts) {
  42. display: inline;
  43. }
  44. body#collection header nav.dropdown-nav,
  45. body#collection header nav.tabs,
  46. body#collection header nav.tabs a:first-child {
  47. margin: 0 0 0 1em;
  48. }
  49. </style>
  50. {{if .RenderMathJax}}
  51. <!-- Add mathjax logic -->
  52. {{template "mathjax" .}}
  53. {{end}}
  54. <!-- Add highlighting logic -->
  55. {{template "highlighting" . }}
  56. </head>
  57. <body id="collection" itemscope itemtype="http://schema.org/WebPage">
  58. {{template "user-navigation" .}}
  59. {{if .Silenced}}
  60. {{template "user-silenced"}}
  61. {{end}}
  62. <header>
  63. <h1 dir="{{.Direction}}" id="blog-title"><a href="/{{if .IsTopLevel}}{{else}}{{.Prefix}}{{.Alias}}/{{end}}" class="h-card p-author u-url" rel="me author">{{.DisplayTitle}}</a></h1>
  64. {{if .Description}}<p class="description p-note">{{.Description}}</p>{{end}}
  65. {{/*if not .Public/*}}
  66. <!--p class="meta-note"><span>Private collection</span>. Only you can see this page.</p-->
  67. {{/*end*/}}
  68. {{if .PinnedPosts}}<nav class="pinned-posts">
  69. {{range .PinnedPosts}}<a class="pinned" href="{{if not $.SingleUser}}/{{$.Alias}}/{{.Slug.String}}{{else}}{{.CanonicalURL $.Host}}{{end}}">{{.PlainDisplayTitle}}</a>{{end}}</nav>
  70. {{end}}
  71. </header>
  72. {{if .Posts}}<section id="wrapper" itemscope itemtype="http://schema.org/Blog">{{else}}<div id="wrapper">{{end}}
  73. {{if .IsWelcome}}
  74. <div id="welcome">
  75. <h2>Welcome, <strong>{{.Username}}</strong>!</h2>
  76. <p>This is your new blog.</p>
  77. <p><a class="simple-cta" href="/#{{.Alias}}">Start writing</a>, or <a class="simple-cta" href="/me/c/{{.Alias}}">customize</a> your blog.</p>
  78. <p>Check out our <a class="simple-cta" href="https://guides.write.as/writing/?pk_campaign=welcome">writing guide</a> to see what else you can do, and <a class="simple-cta" href="/contact">get in touch</a> anytime with questions or feedback.</p>
  79. </div>
  80. {{end}}
  81. {{template "posts" .}}
  82. {{if gt .TotalPages 1}}<nav id="paging" class="content-container clearfix">
  83. {{if or (and .Format.Ascending (le .CurrentPage .TotalPages)) (isRTL .Direction)}}
  84. {{if gt .CurrentPage 1}}<a href="{{.PrevPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">&#8672; {{if and .Format.Ascending (le .CurrentPage .TotalPages)}}Previous{{else}}Newer{{end}}</a>{{end}}
  85. {{if lt .CurrentPage .TotalPages}}<a style="float:right;" href="{{.NextPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">{{if and .Format.Ascending (lt .CurrentPage .TotalPages)}}Next{{else}}Older{{end}} &#8674;</a>{{end}}
  86. {{else}}
  87. {{if lt .CurrentPage .TotalPages}}<a href="{{.NextPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">&#8672; Older</a>{{end}}
  88. {{if gt .CurrentPage 1}}<a style="float:right;" href="{{.PrevPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">Newer &#8674;</a>{{end}}
  89. {{end}}
  90. </nav>{{end}}
  91. {{if .Posts}}</section>{{else}}</div>{{end}}
  92. {{if .ShowFooterBranding }}
  93. <footer>
  94. <hr />
  95. <nav dir="ltr">
  96. {{if not .SingleUser}}<a class="home pubd" href="/">{{.SiteName}}</a> &middot; {{end}}powered by <a style="margin-left:0" href="https://writefreely.org">writefreely</a>
  97. </nav>
  98. </footer>
  99. {{ end }}
  100. </body>
  101. {{if .CanShowScript}}
  102. {{range .ExternalScripts}}<script type="text/javascript" src="{{.}}" async></script>{{end}}
  103. {{if .Script}}<script type="text/javascript">{{.ScriptDisplay}}</script>{{end}}
  104. {{end}}
  105. <script src="/js/h.js"></script>
  106. <script src="/js/localdate.js"></script>
  107. <script src="/js/postactions.js"></script>
  108. <script type="text/javascript">
  109. var deleting = false;
  110. function delPost(e, id, owned) {
  111. e.preventDefault();
  112. if (deleting) {
  113. return;
  114. }
  115. // TODO: UNDO!
  116. if (window.confirm('Are you sure you want to delete this post?')) {
  117. // AJAX
  118. deletePost(id, "", function() {
  119. // Remove post from list
  120. var $postEl = document.getElementById('post-' + id);
  121. $postEl.parentNode.removeChild($postEl);
  122. // TODO: add next post from this collection at the bottom
  123. });
  124. }
  125. }
  126. var deletePost = function(postID, token, callback) {
  127. deleting = true;
  128. var $delBtn = document.getElementById('post-' + postID).getElementsByClassName('delete action')[0];
  129. $delBtn.innerHTML = '...';
  130. var http = new XMLHttpRequest();
  131. var url = "/api/posts/" + postID;
  132. http.open("DELETE", url, true);
  133. http.onreadystatechange = function() {
  134. if (http.readyState == 4) {
  135. deleting = false;
  136. if (http.status == 204) {
  137. callback();
  138. } else if (http.status == 409) {
  139. $delBtn.innerHTML = 'delete';
  140. alert("Post is synced to another account. Delete the post from that account instead.");
  141. // TODO: show "remove" button instead of "delete" now
  142. // Persist that state.
  143. // Have it remove the post locally only.
  144. } else {
  145. $delBtn.innerHTML = 'delete';
  146. alert("Failed to delete." + (http.status>=500?" Please try again.":""));
  147. }
  148. }
  149. }
  150. http.send();
  151. };
  152. var pinning = false;
  153. function pinPost(e, postID, slug, title) {
  154. e.preventDefault();
  155. if (pinning) {
  156. return;
  157. }
  158. pinning = true;
  159. var callback = function() {
  160. // Visibly remove post from collection
  161. var $postEl = document.getElementById('post-' + postID);
  162. $postEl.parentNode.removeChild($postEl);
  163. var $header = document.querySelector('header:not(.multiuser)');
  164. var $pinnedNavs = $header.getElementsByTagName('nav');
  165. // Add link to nav
  166. var link = '<a class="pinned" href="/{{.Alias}}/'+slug+'">'+title+'</a>';
  167. if ($pinnedNavs.length == 0) {
  168. $header.insertAdjacentHTML("beforeend", '<nav>'+link+'</nav>');
  169. } else {
  170. $pinnedNavs[0].insertAdjacentHTML("beforeend", link);
  171. }
  172. };
  173. var $pinBtn = document.getElementById('post-' + postID).getElementsByClassName('pin action')[0];
  174. $pinBtn.innerHTML = '...';
  175. var http = new XMLHttpRequest();
  176. var url = "/api/collections/{{.Alias}}/pin";
  177. var params = [ { "id": postID } ];
  178. http.open("POST", url, true);
  179. http.setRequestHeader("Content-type", "application/json");
  180. http.onreadystatechange = function() {
  181. if (http.readyState == 4) {
  182. pinning = false;
  183. if (http.status == 200) {
  184. callback();
  185. } else if (http.status == 409) {
  186. $pinBtn.innerHTML = 'pin';
  187. alert("Post is synced to another account. Delete the post from that account instead.");
  188. // TODO: show "remove" button instead of "delete" now
  189. // Persist that state.
  190. // Have it remove the post locally only.
  191. } else {
  192. $pinBtn.innerHTML = 'pin';
  193. alert("Failed to pin." + (http.status>=500?" Please try again.":""));
  194. }
  195. }
  196. }
  197. http.send(JSON.stringify(params));
  198. };
  199. try {
  200. WebFontConfig = {
  201. custom: { families: [ 'Lora:400,700:latin', 'Open+Sans:400,700:latin' ], urls: [ '/css/fonts.css' ] }
  202. };
  203. (function() {
  204. var wf = document.createElement('script');
  205. wf.src = '/js/webfont.js';
  206. wf.type = 'text/javascript';
  207. wf.async = 'true';
  208. var s = document.getElementsByTagName('script')[0];
  209. s.parentNode.insertBefore(wf, s);
  210. })();
  211. } catch (e) {}
  212. </script>
  213. </html>{{end}}