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