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.
 
 
 
 
 

145 lines
6.2 KiB

  1. {{define "post"}}<!DOCTYPE HTML>
  2. <html {{if .Language.Valid}}lang="{{.Language.String}}"{{end}} dir="{{.Direction}}">
  3. <head prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article#">
  4. <meta charset="utf-8">
  5. <title>{{.PlainDisplayTitle}} {{localhtml "title dash" .Language.String}} {{.Collection.DisplayTitle}}</title>
  6. <link rel="stylesheet" type="text/css" href="/css/write.css" />
  7. <link rel="shortcut icon" href="/favicon.ico" />
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  9. <link rel="canonical" href="{{.CanonicalURL .Host}}" />
  10. <meta name="generator" content="WriteFreely">
  11. <meta name="title" content="{{.PlainDisplayTitle}} {{localhtml "title dash" .Language.String}} {{if .Collection.Title}}{{.Collection.Title}}{{else}}{{.Collection.Alias}}{{end}}">
  12. <meta name="description" content="{{.Summary}}">
  13. {{if gt .Views 1}}<meta name="twitter:label1" value="Views">
  14. <meta name="twitter:data1" value="{{largeNumFmt .Views}}">{{end}}
  15. <meta name="author" content="{{.Collection.Title}}" />
  16. <meta itemprop="description" content="{{.Summary}}">
  17. <meta itemprop="datePublished" content="{{.CreatedDate}}" />
  18. <meta name="twitter:card" content="summary">
  19. <meta name="twitter:description" content="{{.Summary}}">
  20. <meta name="twitter:title" content="{{.PlainDisplayTitle}} {{localhtml "title dash" .Language.String}} {{if .Collection.Title}}{{.Collection.Title}}{{else}}{{.Collection.Alias}}{{end}}">
  21. {{if gt (len .Images) 0}}<meta name="twitter:image" content="{{index .Images 0}}">{{else}}<meta name="twitter:image" content="{{.Collection.AvatarURL}}">{{end}}
  22. <meta property="og:title" content="{{.PlainDisplayTitle}}" />
  23. <meta property="og:description" content="{{.Summary}}" />
  24. <meta property="og:site_name" content="{{.Collection.DisplayTitle}}" />
  25. <meta property="og:type" content="article" />
  26. <meta property="og:url" content="{{.CanonicalURL .Host}}" />
  27. <meta property="og:updated_time" content="{{.Created8601}}" />
  28. {{range .Images}}<meta property="og:image" content="{{.}}" />{{else}}<meta property="og:image" content="{{.Collection.AvatarURL}}">{{end}}
  29. <meta property="article:published_time" content="{{.Created8601}}">
  30. {{if .Collection.StyleSheet}}<style type="text/css">{{.Collection.StyleSheetDisplay}}</style>{{end}}
  31. <style type="text/css">
  32. body footer {
  33. max-width: 40rem;
  34. margin: 0 auto;
  35. }
  36. body#post header {
  37. padding: 1em 1rem;
  38. }
  39. </style>
  40. {{if .Collection.RenderMathJax}}
  41. <!-- Add mathjax logic -->
  42. {{template "mathjax" . }}
  43. {{end}}
  44. <!-- Add highlighting logic -->
  45. {{template "highlighting" .}}
  46. </head>
  47. <body id="post">
  48. <div id="overlay"></div>
  49. {{template "user-navigation" .}}
  50. {{if .Silenced}}
  51. {{template "user-silenced"}}
  52. {{end}}
  53. <article id="post-body" class="{{.Font}} h-entry">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name{{if $.Collection.Format.ShowDates}} dated{{end}}">{{.FormattedDisplayTitle}}</h2>{{end}}{{if $.Collection.Format.ShowDates}}<time class="dt-published" datetime="{{.Created8601}}" pubdate itemprop="datePublished" content="{{.Created}}">{{.DisplayDate}}</time>{{end}}<div class="e-content">{{.HTMLContent}}</div></article>
  54. {{ if .Collection.ShowFooterBranding }}
  55. <footer dir="ltr">
  56. <p style="text-align: left">Published by <a rel="author" href="{{if .IsTopLevel}}/{{else}}/{{.Collection.Alias}}/{{end}}" class="h-card p-author">{{.Collection.DisplayTitle}}</a>
  57. {{ if .IsOwner }} &middot; <span class="views" dir="ltr"><strong>{{largeNumFmt .Views}}</strong> {{pluralize "view" "views" .Views}}</span>
  58. &middot; <a class="xtra-feature" href="/{{if not .SingleUser}}{{.Collection.Alias}}/{{end}}{{.Slug.String}}/edit" dir="{{.Direction}}">Edit</a>
  59. {{if .IsPinned}} &middot; <a class="xtra-feature unpin" href="/{{.Collection.Alias}}/{{.Slug.String}}/unpin" dir="{{.Direction}}" onclick="unpinPost(event, '{{.ID}}')">Unpin</a>{{end}}
  60. {{ end }}
  61. </p>
  62. <nav>
  63. {{if .PinnedPosts}}
  64. {{range .PinnedPosts}}<a class="pinned{{if eq .Slug.String $.Slug.String}} selected{{end}}" href="{{if not $.SingleUser}}/{{$.Collection.Alias}}/{{.Slug.String}}{{else}}{{.CanonicalURL $.Host}}{{end}}">{{.PlainDisplayTitle}}</a>{{end}}
  65. {{end}}
  66. </nav>
  67. <hr>
  68. <nav><p style="font-size: 0.9em">{{localhtml "published with write.as" .Language.String}}</p></nav>
  69. </footer>
  70. {{ end }}
  71. </body>
  72. {{if .Collection.CanShowScript}}
  73. {{range .Collection.ExternalScripts}}<script type="text/javascript" src="{{.}}" async></script>{{end}}
  74. {{if .Collection.Script}}<script type="text/javascript">{{.Collection.ScriptDisplay}}</script>{{end}}
  75. {{end}}
  76. <script src="/js/localdate.js"></script>
  77. <script type="text/javascript">
  78. var pinning = false;
  79. function unpinPost(e, postID) {
  80. e.preventDefault();
  81. if (pinning) {
  82. return;
  83. }
  84. pinning = true;
  85. var $footer = document.getElementsByTagName('footer')[0];
  86. var callback = function() {
  87. // Hide current page
  88. var $pinnedNavLink = $footer.getElementsByTagName('nav')[0].querySelector('.pinned.selected');
  89. $pinnedNavLink.style.display = 'none';
  90. };
  91. var $pinBtn = $footer.getElementsByClassName('unpin')[0];
  92. $pinBtn.innerHTML = '...';
  93. var http = new XMLHttpRequest();
  94. var url = "/api/collections/{{.Collection.Alias}}/unpin";
  95. var params = [ { "id": postID } ];
  96. http.open("POST", url, true);
  97. http.setRequestHeader("Content-type", "application/json");
  98. http.onreadystatechange = function() {
  99. if (http.readyState == 4) {
  100. pinning = false;
  101. if (http.status == 200) {
  102. callback();
  103. $pinBtn.style.display = 'none';
  104. $pinBtn.innerHTML = 'Pin';
  105. } else if (http.status == 409) {
  106. $pinBtn.innerHTML = 'Unpin';
  107. } else {
  108. $pinBtn.innerHTML = 'Unpin';
  109. alert("Failed to unpin." + (http.status>=500?" Please try again.":""));
  110. }
  111. }
  112. }
  113. http.send(JSON.stringify(params));
  114. };
  115. try { // Fonts
  116. WebFontConfig = {
  117. custom: { families: [ 'Lora:400,700:latin', 'Open+Sans:400,700:latin' ], urls: [ '/css/fonts.css' ] }
  118. };
  119. (function() {
  120. var wf = document.createElement('script');
  121. wf.src = '/js/webfont.js';
  122. wf.type = 'text/javascript';
  123. wf.async = 'true';
  124. var s = document.getElementsByTagName('script')[0];
  125. s.parentNode.insertBefore(wf, s);
  126. })();
  127. } catch (e) { /* ¯\_(ツ)_/¯ */ }
  128. </script>
  129. </html>{{end}}