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.
 
 
 
 
 

135 lines
6.1 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. {{if .Collection.StyleSheet}}<style type="text/css">{{.Collection.StyleSheetDisplay}}</style>{{end}}
  33. {{if .Collection.RenderMathJax}}
  34. <!-- Add mathjax logic -->
  35. {{template "mathjax" . }}
  36. {{end}}
  37. <!-- Add highlighting logic -->
  38. {{template "highlighting" .}}
  39. </head>
  40. <body id="post">
  41. <div id="overlay"></div>
  42. <header>
  43. <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>
  44. <nav>
  45. {{if .PinnedPosts}}
  46. {{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}}
  47. {{end}}
  48. {{ if and .IsOwner .IsFound }}<span class="views" dir="ltr"><strong>{{largeNumFmt .Views}}</strong> {{pluralize "view" "views" .Views}}</span>
  49. <a class="xtra-feature" href="/{{if not .SingleUser}}{{.Collection.Alias}}/{{end}}{{.Slug.String}}/edit" dir="{{.Direction}}">Edit</a>
  50. {{if .IsPinned}}<a class="xtra-feature unpin" href="/{{.Collection.Alias}}/{{.Slug.String}}/unpin" dir="{{.Direction}}" onclick="unpinPost(event, '{{.ID}}')">Unpin</a>{{end}}
  51. {{ end }}
  52. </nav>
  53. </header>
  54. {{if .Silenced}}
  55. {{template "user-silenced"}}
  56. {{end}}
  57. <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 $.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>
  58. {{ if .Collection.ShowFooterBranding }}
  59. <footer dir="ltr"><hr><nav><p style="font-size: 0.9em">{{localhtml "published with write.as" .Language.String}}</p></nav></footer>
  60. {{ end }}
  61. </body>
  62. {{if .Collection.CanShowScript}}
  63. {{range .Collection.ExternalScripts}}<script type="text/javascript" src="{{.}}" async></script>{{end}}
  64. {{if .Collection.Script}}<script type="text/javascript">{{.Collection.ScriptDisplay}}</script>{{end}}
  65. {{end}}
  66. <script src="/js/localdate.js"></script>
  67. <script type="text/javascript">
  68. var pinning = false;
  69. function unpinPost(e, postID) {
  70. e.preventDefault();
  71. if (pinning) {
  72. return;
  73. }
  74. pinning = true;
  75. var $header = document.getElementsByTagName('header')[0];
  76. var callback = function() {
  77. // Hide current page
  78. var $pinnedNavLink = $header.getElementsByTagName('nav')[0].querySelector('.pinned.selected');
  79. $pinnedNavLink.style.display = 'none';
  80. };
  81. var $pinBtn = $header.getElementsByClassName('unpin')[0];
  82. $pinBtn.innerHTML = '...';
  83. var http = new XMLHttpRequest();
  84. var url = "/api/collections/{{.Collection.Alias}}/unpin";
  85. var params = [ { "id": postID } ];
  86. http.open("POST", url, true);
  87. http.setRequestHeader("Content-type", "application/json");
  88. http.onreadystatechange = function() {
  89. if (http.readyState == 4) {
  90. pinning = false;
  91. if (http.status == 200) {
  92. callback();
  93. $pinBtn.style.display = 'none';
  94. $pinBtn.innerHTML = 'Pin';
  95. } else if (http.status == 409) {
  96. $pinBtn.innerHTML = 'Unpin';
  97. } else {
  98. $pinBtn.innerHTML = 'Unpin';
  99. alert("Failed to unpin." + (http.status>=500?" Please try again.":""));
  100. }
  101. }
  102. }
  103. http.send(JSON.stringify(params));
  104. };
  105. try { // Fonts
  106. WebFontConfig = {
  107. custom: { families: [ 'Lora:400,700:latin', 'Open+Sans:400,700:latin' ], urls: [ '/css/fonts.css' ] }
  108. };
  109. (function() {
  110. var wf = document.createElement('script');
  111. wf.src = '/js/webfont.js';
  112. wf.type = 'text/javascript';
  113. wf.async = 'true';
  114. var s = document.getElementsByTagName('script')[0];
  115. s.parentNode.insertBefore(wf, s);
  116. })();
  117. } catch (e) { /* ¯\_(ツ)_/¯ */ }
  118. </script>
  119. </html>{{end}}