From a3fce34cbab54e89b28b356816c6ebbcbf904540 Mon Sep 17 00:00:00 2001 From: sentriz Date: Thu, 12 Mar 2020 00:59:56 +0000 Subject: [PATCH] add nocache template func --- assets/assets_gen.go | 38 +++++++++++++++++++------------------- assets/partials/head.tmpl | 2 +- server/ctrladmin/ctrl.go | 8 ++++++++ 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/assets/assets_gen.go b/assets/assets_gen.go index 6d9cb26..43c679f 100644 --- a/assets/assets_gen.go +++ b/assets/assets_gen.go @@ -62,7 +62,7 @@ var Bytes = map[string]*EmbeddedAsset{ 0x7b,0x20,0x65,0x6e,0x64,0x20,0x7d,0x7d,0x0a, }}, "pages/home.tmpl": &EmbeddedAsset{ - ModTime: time.Unix(1583972849, 0), + ModTime: time.Unix(1583975009, 0), Bytes: []byte{ 0x7b,0x7b,0x20,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x22,0x75,0x73,0x65,0x72,0x22,0x20,0x7d,0x7d,0x0a,0x3c,0x64,0x69,0x76, 0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x70,0x61,0x64,0x64,0x65,0x64,0x20,0x62,0x6f,0x78,0x22,0x3e,0x0a,0x20,0x20,0x20, @@ -390,7 +390,7 @@ var Bytes = map[string]*EmbeddedAsset{ 0x2f,0x64,0x69,0x76,0x3e,0x0a,0x7b,0x7b,0x20,0x65,0x6e,0x64,0x20,0x7d,0x7d,0x0a, }}, "pages/update_lastfm_api_key.tmpl": &EmbeddedAsset{ - ModTime: time.Unix(1583954426, 0), + ModTime: time.Unix(1583975009, 0), Bytes: []byte{ 0x7b,0x7b,0x20,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x22,0x75,0x73,0x65,0x72,0x22,0x20,0x7d,0x7d,0x0a,0x3c,0x64,0x69,0x76, 0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x70,0x61,0x64,0x64,0x65,0x64,0x20,0x62,0x6f,0x78,0x22,0x3e,0x0a,0x20,0x20,0x20, @@ -494,7 +494,7 @@ var Bytes = map[string]*EmbeddedAsset{ 0x20,0x7d,0x7d,0x0a, }}, "static/reset.css": &EmbeddedAsset{ - ModTime: time.Unix(1583954426, 0), + ModTime: time.Unix(1583975009, 0), Bytes: []byte{ 0x2f,0x2a,0x20,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6d,0x65,0x79,0x65,0x72,0x77,0x65,0x62,0x2e,0x63,0x6f,0x6d,0x2f,0x65, 0x72,0x69,0x63,0x2f,0x74,0x6f,0x6f,0x6c,0x73,0x2f,0x63,0x73,0x73,0x2f,0x72,0x65,0x73,0x65,0x74,0x2f,0x0a,0x20,0x20,0x20, @@ -10803,7 +10803,7 @@ var Bytes = map[string]*EmbeddedAsset{ 0x55,0x23,0xfe,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, }}, "static/main.css": &EmbeddedAsset{ - ModTime: time.Unix(1583954493, 0), + ModTime: time.Unix(1583975009, 0), Bytes: []byte{ 0x3a,0x72,0x6f,0x6f,0x74,0x20,0x7b,0x0a,0x20,0x20,0x2d,0x2d,0x70,0x61,0x64,0x2d,0x73,0x69,0x7a,0x65,0x3a,0x20,0x31,0x2e, 0x37,0x35,0x72,0x65,0x6d,0x3b,0x0a,0x7d,0x0a,0x0a,0x2a,0x2c,0x0a,0x73,0x70,0x61,0x6e,0x2c,0x0a,0x64,0x69,0x76,0x2c,0x0a, @@ -10890,7 +10890,7 @@ var Bytes = map[string]*EmbeddedAsset{ 0x69,0x74,0x61,0x6c,0x69,0x63,0x3b,0x0a,0x7d,0x0a, }}, "partials/head.tmpl": &EmbeddedAsset{ - ModTime: time.Unix(1582000031, 0), + ModTime: time.Unix(1583975009, 0), Bytes: []byte{ 0x7b,0x7b,0x20,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x22,0x68,0x65,0x61,0x64,0x22,0x20,0x7d,0x7d,0x0a,0x3c,0x6c,0x69,0x6e, 0x6b,0x20,0x72,0x65,0x6c,0x3d,0x22,0x73,0x74,0x79,0x6c,0x65,0x73,0x68,0x65,0x65,0x74,0x22,0x20,0x68,0x72,0x65,0x66,0x3d, @@ -10902,22 +10902,22 @@ var Bytes = map[string]*EmbeddedAsset{ 0x72,0x69,0x61,0x6c,0x64,0x65,0x73,0x69,0x67,0x6e,0x69,0x63,0x6f,0x6e,0x73,0x2e,0x6d,0x69,0x6e,0x2e,0x63,0x73,0x73,0x22, 0x3e,0x0a,0x3c,0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c,0x3d,0x22,0x73,0x74,0x79,0x6c,0x65,0x73,0x68,0x65,0x65,0x74,0x22, 0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x7b,0x7b,0x20,0x70,0x61,0x74,0x68,0x20,0x22,0x2f,0x61,0x64,0x6d,0x69,0x6e,0x2f,0x73, -0x74,0x61,0x74,0x69,0x63,0x2f,0x6d,0x61,0x69,0x6e,0x2e,0x63,0x73,0x73,0x22,0x20,0x7d,0x7d,0x22,0x3e,0x0a,0x3c,0x6c,0x69, -0x6e,0x6b,0x20,0x72,0x65,0x6c,0x3d,0x22,0x73,0x68,0x6f,0x72,0x74,0x63,0x75,0x74,0x20,0x69,0x63,0x6f,0x6e,0x22,0x20,0x68, -0x72,0x65,0x66,0x3d,0x22,0x7b,0x7b,0x20,0x70,0x61,0x74,0x68,0x20,0x22,0x2f,0x61,0x64,0x6d,0x69,0x6e,0x2f,0x73,0x74,0x61, -0x74,0x69,0x63,0x2f,0x66,0x61,0x76,0x69,0x63,0x6f,0x6e,0x2e,0x69,0x63,0x6f,0x22,0x20,0x7d,0x7d,0x22,0x20,0x74,0x79,0x70, -0x65,0x3d,0x22,0x69,0x6d,0x61,0x67,0x65,0x2f,0x78,0x2d,0x69,0x63,0x6f,0x6e,0x22,0x3e,0x0a,0x3c,0x6c,0x69,0x6e,0x6b,0x20, -0x72,0x65,0x6c,0x3d,0x22,0x69,0x63,0x6f,0x6e,0x22,0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x7b,0x7b,0x20,0x70,0x61,0x74,0x68, -0x20,0x22,0x2f,0x61,0x64,0x6d,0x69,0x6e,0x2f,0x73,0x74,0x61,0x74,0x69,0x63,0x2f,0x66,0x61,0x76,0x69,0x63,0x6f,0x6e,0x2e, -0x69,0x63,0x6f,0x22,0x20,0x7d,0x7d,0x22,0x20,0x74,0x79,0x70,0x65,0x3d,0x22,0x69,0x6d,0x61,0x67,0x65,0x2f,0x78,0x2d,0x69, -0x63,0x6f,0x6e,0x22,0x3e,0x0a,0x3c,0x6d,0x65,0x74,0x61,0x20,0x6e,0x61,0x6d,0x65,0x3d,0x22,0x76,0x69,0x65,0x77,0x70,0x6f, -0x72,0x74,0x22,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x22,0x77,0x69,0x64,0x74,0x68,0x3d,0x64,0x65,0x76,0x69,0x63, -0x65,0x2d,0x77,0x69,0x64,0x74,0x68,0x2c,0x20,0x69,0x6e,0x69,0x74,0x69,0x61,0x6c,0x2d,0x73,0x63,0x61,0x6c,0x65,0x3d,0x31, -0x2c,0x20,0x75,0x73,0x65,0x72,0x2d,0x73,0x63,0x61,0x6c,0x61,0x62,0x6c,0x65,0x3d,0x6e,0x6f,0x22,0x3e,0x0a,0x7b,0x7b,0x20, -0x65,0x6e,0x64,0x20,0x7d,0x7d,0x0a, +0x74,0x61,0x74,0x69,0x63,0x2f,0x6d,0x61,0x69,0x6e,0x2e,0x63,0x73,0x73,0x22,0x20,0x7c,0x20,0x6e,0x6f,0x43,0x61,0x63,0x68, +0x65,0x20,0x7d,0x7d,0x22,0x3e,0x0a,0x3c,0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c,0x3d,0x22,0x73,0x68,0x6f,0x72,0x74,0x63, +0x75,0x74,0x20,0x69,0x63,0x6f,0x6e,0x22,0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x7b,0x7b,0x20,0x70,0x61,0x74,0x68,0x20,0x22, +0x2f,0x61,0x64,0x6d,0x69,0x6e,0x2f,0x73,0x74,0x61,0x74,0x69,0x63,0x2f,0x66,0x61,0x76,0x69,0x63,0x6f,0x6e,0x2e,0x69,0x63, +0x6f,0x22,0x20,0x7d,0x7d,0x22,0x20,0x74,0x79,0x70,0x65,0x3d,0x22,0x69,0x6d,0x61,0x67,0x65,0x2f,0x78,0x2d,0x69,0x63,0x6f, +0x6e,0x22,0x3e,0x0a,0x3c,0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c,0x3d,0x22,0x69,0x63,0x6f,0x6e,0x22,0x20,0x68,0x72,0x65, +0x66,0x3d,0x22,0x7b,0x7b,0x20,0x70,0x61,0x74,0x68,0x20,0x22,0x2f,0x61,0x64,0x6d,0x69,0x6e,0x2f,0x73,0x74,0x61,0x74,0x69, +0x63,0x2f,0x66,0x61,0x76,0x69,0x63,0x6f,0x6e,0x2e,0x69,0x63,0x6f,0x22,0x20,0x7d,0x7d,0x22,0x20,0x74,0x79,0x70,0x65,0x3d, +0x22,0x69,0x6d,0x61,0x67,0x65,0x2f,0x78,0x2d,0x69,0x63,0x6f,0x6e,0x22,0x3e,0x0a,0x3c,0x6d,0x65,0x74,0x61,0x20,0x6e,0x61, +0x6d,0x65,0x3d,0x22,0x76,0x69,0x65,0x77,0x70,0x6f,0x72,0x74,0x22,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x22,0x77, +0x69,0x64,0x74,0x68,0x3d,0x64,0x65,0x76,0x69,0x63,0x65,0x2d,0x77,0x69,0x64,0x74,0x68,0x2c,0x20,0x69,0x6e,0x69,0x74,0x69, +0x61,0x6c,0x2d,0x73,0x63,0x61,0x6c,0x65,0x3d,0x31,0x2c,0x20,0x75,0x73,0x65,0x72,0x2d,0x73,0x63,0x61,0x6c,0x61,0x62,0x6c, +0x65,0x3d,0x6e,0x6f,0x22,0x3e,0x0a,0x7b,0x7b,0x20,0x65,0x6e,0x64,0x20,0x7d,0x7d,0x0a, }}, "layouts/base.tmpl": &EmbeddedAsset{ - ModTime: time.Unix(1583954426, 0), + ModTime: time.Unix(1583975009, 0), Bytes: []byte{ 0x7b,0x7b,0x20,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x22,0x6c,0x61,0x79,0x6f,0x75,0x74,0x22,0x20,0x7d,0x7d,0x0a,0x3c,0x21, 0x64,0x6f,0x63,0x74,0x79,0x70,0x65,0x20,0x68,0x74,0x6d,0x6c,0x3e,0x0a,0x3c,0x68,0x74,0x6d,0x6c,0x3e,0x0a,0x20,0x20,0x20, diff --git a/assets/partials/head.tmpl b/assets/partials/head.tmpl index 77772fb..7fe8e8f 100644 --- a/assets/partials/head.tmpl +++ b/assets/partials/head.tmpl @@ -1,7 +1,7 @@ {{ define "head" }} - + diff --git a/server/ctrladmin/ctrl.go b/server/ctrladmin/ctrl.go index 4b33f7c..92f8871 100644 --- a/server/ctrladmin/ctrl.go +++ b/server/ctrladmin/ctrl.go @@ -6,6 +6,7 @@ import ( "html/template" "log" "net/http" + "net/url" "path/filepath" "strings" "time" @@ -83,6 +84,13 @@ func New(base *ctrlbase.Controller) *Controller { "date": func(in time.Time) string { return strings.ToLower(in.Format("Jan 02, 2006")) }, + "noCache": func(in string) string { + parsed, _ := url.Parse(in) + params := parsed.Query() + params.Set("v", version.VERSION) + parsed.RawQuery = params.Encode() + return parsed.String() + }, "dateHuman": humanize.Time, "path": base.Path, })