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.
 
 
 
 
 

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