init
This commit is contained in:
commit
fa6a4c650f
93 files changed
+6555
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func templateFuncMap() template.FuncMap {
|
||||
|
||||
return template.FuncMap{
|
||||
|
||||
"safeHTML": func(
|
||||
s string,
|
||||
) template.HTML {
|
||||
|
||||
return template.HTML(s)
|
||||
},
|
||||
|
||||
"formatTime": func(
|
||||
ts int64,
|
||||
) string {
|
||||
|
||||
return time.Unix(
|
||||
ts,
|
||||
0,
|
||||
).Format(time.RFC3339)
|
||||
},
|
||||
|
||||
"parentPath": func(
|
||||
p string,
|
||||
) string {
|
||||
|
||||
parts :=
|
||||
strings.Split(
|
||||
strings.Trim(p, "/"),
|
||||
"/",
|
||||
)
|
||||
|
||||
if len(parts) <= 1 {
|
||||
return "/"
|
||||
}
|
||||
|
||||
parts =
|
||||
parts[:len(parts)-1]
|
||||
|
||||
return "/" +
|
||||
strings.Join(
|
||||
parts,
|
||||
"/",
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user