hugo-hyperskip

Email-powered static comments for Hugo

git clone git://git.shimmy1996.com/hugo-hyperskip.git
commit 75b9f90b3afae32736c5c8d43a8191e66f7ddb42
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Sat,  4 Jan 2020 16:03:46 -0600

Initial commit

Diffstat:
ALICENSE | 20++++++++++++++++++++
AREADME.org | 7+++++++
Ai18n/en.toml | 21+++++++++++++++++++++
Ai18n/zh.toml | 21+++++++++++++++++++++
Alayouts/partials/comment_form.html | 19+++++++++++++++++++
Alayouts/partials/hyperskip.html | 8++++++++
Alayouts/partials/list_comment.html | 22++++++++++++++++++++++
Atheme.toml | 12++++++++++++
8 files changed, 130 insertions(+), 0 deletions(-)
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2020 Shimmy Xu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.org b/README.org
@@ -0,0 +1,7 @@
+* Hyperskip
+Hyperskip adds email-powered comments for Hugo.
+
+Insert comment section with
+#+BEGIN_SRC html
+{{ partial "hyperskip.html" . }}
+#+END_SRC
diff --git a/i18n/en.toml b/i18n/en.toml
@@ -0,0 +1,20 @@
+[hyperskip-header]
+other = "Comments"
+
+[hyperskip-name]
+other = "Name: "
+
+[hyperskip-name-default]
+other = "Anonymous"
+
+[hyperskip-comment]
+other = "Comment: "
+
+[hyperskip-submit]
+other = "Email Comment"
+
+[hyperskip-reply]
+other = "Reply"
+
+[hyperskip-requirement]
+other = "At least 3 characters."+
\ No newline at end of file
diff --git a/i18n/zh.toml b/i18n/zh.toml
@@ -0,0 +1,20 @@
+[hyperskip-header]
+other = "评论区"
+
+[hyperskip-name]
+other = "用户名:"
+
+[hyperskip-name-default]
+other = "无名氏"
+
+[hyperskip-comment]
+other = "评论:"
+
+[hyperskip-submit]
+other = "使用电子邮件提交"
+
+[hyperskip-reply]
+other = "回复"
+
+[hyperskip-requirement]
+other = "至少三个字符。"+
\ No newline at end of file
diff --git a/layouts/partials/comment_form.html b/layouts/partials/comment_form.html
@@ -0,0 +1,19 @@
+<form
+  action="mailto:{{ $.Site.Author.email }}?subject=RE:{{ $.Page.RelPermalink }}"
+  method="post"
+  enctype="text/plain"
+  name="comment_form">
+  <label for="name">{{ i18n "hyperskip-name" }}</label><br/>
+  <input type="text" id="name" name="name" maxlength="20"
+         placeholder="{{ i18n "hyperskip-name-default" }}"/>
+  <br/><br/>
+  <label for="comment">{{ i18n "hyperskip-comment" }}</label><br/>
+  <textarea id="comment"
+            name="comment"
+            rows="8"
+            minlength="3"
+            placeholder="{{ i18n "hyperskip-requirement"}}"
+            style="resize:vertical;min-height:3em;"></textarea>
+  <br/><br/>
+  <input type="submit" value="{{ i18n "hyperskip-submit"}}">
+</form>
diff --git a/layouts/partials/hyperskip.html b/layouts/partials/hyperskip.html
@@ -0,0 +1,8 @@
+<hr/>
+<div id="comments">
+<h1>{{ i18n "hyperskip-header" }}</h1>
+{{ partial "comment_form.html" . }}
+<br/>
+{{ partial "list_comment.html" . }}
+</div>
+<hr/><br/>
diff --git a/layouts/partials/list_comment.html b/layouts/partials/list_comment.html
@@ -0,0 +1,22 @@
+{{ with .Site.Data.comments.comments }}
+{{ range sort (where . "rel_permalink" $.Page.RelPermalink) "time" }}
+{{ $hash := (print .name .time) | md5 | last 7 }}
+<hr/>
+<div id="{{ $hash }}">
+  <b>{{ or .name (i18n "hyperskip-name-default") }}</b>&nbsp;
+  <a href="#{{ $hash }}">#{{ $hash }}</a>&nbsp;
+  <span style="float:right;">
+    {{- .time.Format "2006-01-02T15:04-07:00" -}}
+    &nbsp;&#91;&nbsp;<a href="#comment" onclick="reply({{ $hash }})">
+      {{- i18n "hyperskip-reply" -}}
+    </a>&nbsp;&#93;
+  </span>
+  <div style="margin-top:1em;">{{ .content | htmlEscape | markdownify }}</div>
+</div>
+{{ end }}
+<script>
+  function reply(hash) {
+      document.forms.comment_form.comment.value += "[RE:#" + hash + "](#" + hash + ")\n";
+  }
+</script>
+{{ end }}
diff --git a/theme.toml b/theme.toml
@@ -0,0 +1,12 @@
+name = "Hyperskip"
+license = "MIT"
+licenselink = "./LICENSE"
+description = ""
+homepage = ""
+tags = []
+features = []
+min_version = "0.41"
+
+[author]
+  name = "Shimmy Xu"
+  homepage = ""