mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Show version dates
This commit is contained in:
parent
59c4a95e4d
commit
dfa18bca5a
@ -4,6 +4,7 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-contrib/static"
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -55,6 +56,11 @@ func handlePageRequest(c *gin.Context) {
|
||||
rawHTML = GithubMarkdownToHTML(rawText)
|
||||
}
|
||||
}
|
||||
versionsInt64 := p.Text.GetSnapshots()
|
||||
versionsText := make([]string, len(versionsInt64))
|
||||
for i, v := range versionsInt64 {
|
||||
versionsText[i] = time.Unix(v/1000000000, 0).String()
|
||||
}
|
||||
c.HTML(http.StatusOK, "index.html", gin.H{
|
||||
"EditPage": command == "edit",
|
||||
"ViewPage": command == "view",
|
||||
@ -63,7 +69,8 @@ func handlePageRequest(c *gin.Context) {
|
||||
"Page": p.Name,
|
||||
"RenderedPage": template.HTML([]byte(rawHTML)),
|
||||
"RawPage": rawText,
|
||||
"Versions": p.Text.GetSnapshots(),
|
||||
"Versions": versionsInt64,
|
||||
"VersionsText": versionsText,
|
||||
"IsLocked": p.IsLocked,
|
||||
"IsEncrypted": p.IsEncrypted,
|
||||
})
|
||||
|
@ -277,8 +277,8 @@
|
||||
{{ if .EditPage }} <textarea autofocus placeholder="Start typing, it will save automatically." id="userInput">{{ .RawPage }}</textarea>{{ end }}
|
||||
{{ if .HistoryPage }}
|
||||
<ul>
|
||||
{{range .Versions}}
|
||||
<li><a href="/{{ $.Page }}/view?version={{.}}">Version #{{ . }}
|
||||
{{range $i, $e := .Versions}}
|
||||
<li><a href="/{{ $.Page }}/view?version={{$e}}">Version {{index $.VersionsText $i}}</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user