Add staticman support (static comments coupled with Github pull request)
This commit is contained in:
parent
7cdd0e0b3d
commit
8a0d06525d
16 changed files with 264 additions and 7 deletions
|
|
@ -58,6 +58,9 @@
|
|||
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
<script src="{{ "js/main.js" | absURL }}"></script>
|
||||
{{- if .Site.Params.staticman }}
|
||||
<script src="{{ "js/staticman.js" | absURL }}"></script>
|
||||
{{- end }}
|
||||
{{- if (not ( .Site.Params.UseChroma )) }}
|
||||
<script src="{{ "js/highlight.min.js" | absURL }}"></script>
|
||||
<script> hljs.initHighlightingOnLoad(); </script>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@
|
|||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{{ "css/main.css" | absURL }}" />
|
||||
{{- if .Site.Params.staticman -}}
|
||||
<link rel="stylesheet" href="{{ "css/staticman.css" | absURL }}" />
|
||||
{{- end -}}
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" />
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" />
|
||||
{{- if (not ( .Site.Params.UseChroma )) }}
|
||||
|
|
@ -52,6 +55,10 @@
|
|||
<link rel="stylesheet" href="{{ "css/syntax.css" | absURL }}" />
|
||||
{{- end -}}
|
||||
|
||||
{{- if .Site.Params.staticman.recaptcha -}}
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
{{- end -}}
|
||||
|
||||
{{- partial "head_custom.html" . }}
|
||||
{{- partial "load-photoswipe-theme.html" . }}
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
|
|
|
|||
84
layouts/partials/staticman-comments.html
Normal file
84
layouts/partials/staticman-comments.html
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<section class="js-comments staticman-comments">
|
||||
<h3>Comments</h3>
|
||||
|
||||
{{ $slug := replace .URL "/" "" }}
|
||||
{{ $.Scratch.Add "hasComments" 0 }}
|
||||
|
||||
<!-- Parse all parent comment -->
|
||||
{{ range $index, $comments := (index $.Site.Data.comments $slug ) }}
|
||||
<!-- Check if comment has 0 parent -->
|
||||
{{ if eq $index "0" }}
|
||||
{{ range $comments}}
|
||||
{{ $.Scratch.Add "hasComments" 1 }}
|
||||
<article id="comment-{{ $.Scratch.Get "hasComments" }}" class="static-comment">
|
||||
<img class="comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=48">
|
||||
{{ if .website }}
|
||||
<h4 class="comment-author"><a rel="external nofollow" href="{{ .website }}">{{ .name }}</a></h4>
|
||||
{{ else }}
|
||||
<h4 class="comment-author">{{ .name }}</h4>
|
||||
{{ end }}
|
||||
<div class="comment-timestamp"><a href="#comment-{{ $.Scratch.Get "hasComments" }}" title="Permalink to this comment"><time datetime="{{ .date }}">{{ dateFormat (default (i18n "shortdateFormat") .Site.Params.dateformat) .date}}</time></a></div>
|
||||
<div class="comment-content"><p>{{ .comment | markdownify }}</p></div>
|
||||
</article>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
|
||||
<form class="js-form form" method="post" action="{{ .Site.Params.staticman.api}}">
|
||||
<input type="hidden" name="options[slug]" value="{{ replace .URL "/" "" }}">
|
||||
<input type="hidden" name="options[parent]" value="0">
|
||||
|
||||
{{ if .Site.Params.staticman.recaptcha }}
|
||||
<input type="hidden" name="options[reCaptcha][siteKey]" value="{{ .Site.Params.staticman.recaptcha.sitekey }}">
|
||||
<input type="hidden" name="options[reCaptcha][secret]" value="{{ .Site.Params.staticman.recaptcha.secret }}">
|
||||
{{ end }}
|
||||
|
||||
<fieldset>
|
||||
<div class="textfield">
|
||||
<textarea name="fields[comment]" type="text" placeholder="You can use Markdown syntax"></textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div class="textfield">
|
||||
<input name="fields[name]" type="text" placeholder="Your name"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div class="textfield">
|
||||
<input type="email" name="fields[email]" placeholder="Your email (optional, used only to send comments.)"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div class="textfield">
|
||||
<input type="text" name="fields[website]" placeholder="Your website"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{{ if .Site.Params.staticman.recaptcha }}
|
||||
<fieldset>
|
||||
<div class="g-recaptcha" data-sitekey="{{ .Site.Params.staticman.recaptcha.sitekey }}"></div>
|
||||
</fieldset>
|
||||
{{ end }}
|
||||
|
||||
<fieldset>
|
||||
<button class="button">
|
||||
Submit
|
||||
</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<article class="modal">
|
||||
<div class="title">
|
||||
<h2 class="js-modal-title"></h2>
|
||||
</div>
|
||||
<div class="js-modal-text"></div>
|
||||
<div>
|
||||
<button class="js-close-modal">Close</button>
|
||||
</div>
|
||||
</article>
|
||||
Loading…
Add table
Add a link
Reference in a new issue