diff --git a/handlers/cache.go b/handlers/cache.go index 0a8c4364..e3c103aa 100644 --- a/handlers/cache.go +++ b/handlers/cache.go @@ -14,6 +14,7 @@ type Cacher interface { Get(key string) []byte Delete(key string) Set(key string, content []byte, duration time.Duration) + List() map[string]Item } // Item is a cached reference @@ -44,6 +45,10 @@ func NewStorage() *Storage { } } +func (s Storage) List() map[string]Item { + return s.items +} + //Get a cached content by key func (s Storage) Get(key string) []byte { item := s.items[key] diff --git a/handlers/functions.go b/handlers/functions.go index c1b7361a..2790b7fb 100644 --- a/handlers/functions.go +++ b/handlers/functions.go @@ -82,6 +82,9 @@ var handlerFuncs = func(w http.ResponseWriter, r *http.Request) template.FuncMap "Error": func() string { return "" }, + "Cache": func() Cacher { + return CacheStorage + }, "ToString": func(v interface{}) string { return utils.ToString(v) }, @@ -98,6 +101,12 @@ var handlerFuncs = func(w http.ResponseWriter, r *http.Request) template.FuncMap "FromUnix": func(t int64) string { return utils.Timezoner(time.Unix(t, 0), core.CoreApp.Timezone).Format("Monday, January 02") }, + "UnixTime": func(t int64, nano bool) string { + if nano { + t = t / 1e9 + } + return utils.Timezoner(time.Unix(t, 0), core.CoreApp.Timezone).String() + }, "NewService": func() *types.Service { return new(types.Service) }, diff --git a/source/tmpl/settings.gohtml b/source/tmpl/settings.gohtml index 8c3d3c9d..7678084c 100644 --- a/source/tmpl/settings.gohtml +++ b/source/tmpl/settings.gohtml @@ -8,6 +8,7 @@