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.
 
 
 
 
 

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