added index date to file page

This commit is contained in:
ston1th 2020-07-11 21:33:06 +02:00
commit 3f9b863171
5 changed files with 27 additions and 11 deletions

View file

@ -8,8 +8,9 @@ import (
)
const (
fileFmt = "20060102_150405"
logFmt = "2006/01/02 15:04:05: "
fileFmt = "20060102_150405"
logFmt = "2006/01/02 15:04:05: "
createdFmt = "02.01.2006 15:04:05"
)
var m sync.Mutex
@ -26,3 +27,7 @@ func FileName() string {
func LogTime() string {
return time.Now().Format(logFmt)
}
func CreatedTime(t time.Time) string {
return t.Format(createdFmt)
}

View file

@ -74,10 +74,11 @@ type webData struct {
Msg string
Query string
Path string
Paths core.Paths
Tags []string
Data interface{}
Path string
Paths core.Paths
Tags []string
Created string
Data interface{}
}
type loginData struct {

View file

@ -457,7 +457,15 @@ func dirHandler(ctx *Context) {
Title: "Document Viewer | " + path,
}
ctx.Template("fileHandler")
f := ctx.Srv.DB.IsIndexed(path)
//f := ctx.Srv.DB.IsIndexed(path)
id, err := ctx.Srv.DB.GetID(path)
f := err == nil
if id != "" {
d, err := ctx.Srv.DB.Index.Get(id)
if err == nil {
ctx.Data.Created = core.CreatedTime(d.Created)
}
}
ctx.Data.Data = core.Path{
Name: path,
Abs: core.RawPrefix + path,

View file

@ -151,16 +151,17 @@ const (
</div>
</div>
</div>
{{if .Tags}}
<div class="row">
<div class="alert alert-secondary full-width">
{{if .Tags}}
Tags
{{range $t := .Tags}}
<a href="/search?query=tags:{{$t}}" class="btn badge btn-primary tag">{{$t}}</a>
{{end}}
{{end}}
<span class="float-right">{{.Created}}</span>
</div>
</div>
{{end}}
<div class="row">
<embed src="{{.Data.Abs}}" toolbar="1" statusbar="1" navpanes="1"></embed>
</div>