aboutsummaryrefslogtreecommitdiff
path: root/renderer
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-02-09 13:42:16 +0000
committerr <r@freesoftwareextremist.com>2020-02-09 13:42:16 +0000
commitcfec7879e3b3fc38956f2dce0acbbeb8a578f4c1 (patch)
tree5da9a9371fd10667cd6ee68bbd07f7f0f9d8d3d3 /renderer
parenta68a09a83ef2eb411e2a7a66e919f27c040c0b6a (diff)
downloadbloat-cfec7879e3b3fc38956f2dce0acbbeb8a578f4c1.tar.gz
bloat-cfec7879e3b3fc38956f2dce0acbbeb8a578f4c1.zip
Add poll support
Currenlty only voting is possible.
Diffstat (limited to 'renderer')
-rw-r--r--renderer/renderer.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/renderer/renderer.go b/renderer/renderer.go
index 0eb229c..bd9ccd8 100644
--- a/renderer/renderer.go
+++ b/renderer/renderer.go
@@ -43,6 +43,7 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
"StatusContentFilter": StatusContentFilter,
"DisplayInteractionCount": DisplayInteractionCount,
"TimeSince": TimeSince,
+ "TimeUntil": TimeUntil,
"FormatTimeRFC3339": FormatTimeRFC3339,
"FormatTimeRFC822": FormatTimeRFC822,
"WithContext": WithContext,
@@ -86,7 +87,7 @@ func (r *renderer) RenderUserPage(ctx *Context, writer io.Writer,
return r.template.ExecuteTemplate(writer, "user.tmpl", WithContext(data, ctx))
}
-func (r *renderer) RenderUserSearchPage(ctx *Context, writer io.Writer,
+func (r *renderer) RenderUserSearchPage(ctx *Context, writer io.Writer,
data *UserSearchData) (err error) {
return r.template.ExecuteTemplate(writer, "usersearch.tmpl", WithContext(data, ctx))
}
@@ -158,8 +159,7 @@ func DisplayInteractionCount(c int64) string {
return ""
}
-func TimeSince(t time.Time) string {
- dur := time.Since(t)
+func DurToStr(dur time.Duration) string {
s := dur.Seconds()
if s < 60 {
return strconv.Itoa(int(s)) + "s"
@@ -184,6 +184,14 @@ func TimeSince(t time.Time) string {
return strconv.Itoa(int(y)) + "y"
}
+func TimeSince(t time.Time) string {
+ return DurToStr(time.Since(t))
+}
+
+func TimeUntil(t time.Time) string {
+ return DurToStr(time.Until(t))
+}
+
func FormatTimeRFC3339(t time.Time) string {
return t.Format(time.RFC3339)
}