A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

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