diff --git a/Makefile b/Makefile index f6e388bb..2686438f 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ FRONTEND_YARN_MODULES = frontend/node_modules FRONTEND_DIST = frontend/dist FRONTEND_DEPS = \ $(FRONTEND_YARN_MODULES) \ + frontend/index.html \ frontend/package.json \ frontend/vite.config.js \ frontend/.eslintrc.js \ diff --git a/cmd/handlers.go b/cmd/handlers.go index af92a5a4..9cc4f88b 100644 --- a/cmd/handlers.go +++ b/cmd/handlers.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "crypto/subtle" "net/http" "path" @@ -237,6 +238,8 @@ func handleAdminPage(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } + b = bytes.ReplaceAll(b, []byte("asset_version"), []byte(app.constants.AssetVersion)) + return c.HTMLBlob(http.StatusOK, b) } diff --git a/cmd/init.go b/cmd/init.go index 8905f113..56cb6c48 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "crypto/md5" "encoding/json" "fmt" "html/template" @@ -94,6 +95,7 @@ type constants struct { OptinURL string MessageURL string ArchiveURL string + AssetVersion string MediaUpload struct { Provider string @@ -414,6 +416,9 @@ func initConstants() *constants { c.BounceSendgridEnabled = ko.Bool("bounce.sendgrid_enabled") c.BouncePostmarkEnabled = ko.Bool("bounce.postmark.enabled") + b := md5.Sum([]byte(time.Now().String())) + c.AssetVersion = fmt.Sprintf("%x", b)[0:10] + return &c } @@ -756,6 +761,7 @@ func initHTTPServer(app *App) *echo.Echo { RootURL: app.constants.RootURL, LogoURL: app.constants.LogoURL, FaviconURL: app.constants.FaviconURL, + AssetVersion: app.constants.AssetVersion, EnablePublicSubPage: app.constants.EnablePublicSubPage, EnablePublicArchive: app.constants.EnablePublicArchive, } diff --git a/cmd/public.go b/cmd/public.go index ff61637a..9ed9228b 100644 --- a/cmd/public.go +++ b/cmd/public.go @@ -30,6 +30,7 @@ type tplRenderer struct { RootURL string LogoURL string FaviconURL string + AssetVersion string EnablePublicSubPage bool EnablePublicArchive bool } @@ -41,6 +42,7 @@ type tplData struct { RootURL string LogoURL string FaviconURL string + AssetVersion string EnablePublicSubPage bool EnablePublicArchive bool Data interface{} @@ -94,6 +96,7 @@ func (t *tplRenderer) Render(w io.Writer, name string, data interface{}, c echo. RootURL: t.RootURL, LogoURL: t.LogoURL, FaviconURL: t.FaviconURL, + AssetVersion: t.AssetVersion, EnablePublicSubPage: t.EnablePublicSubPage, EnablePublicArchive: t.EnablePublicArchive, Data: data, diff --git a/frontend/index.html b/frontend/index.html index bcf87f48..07d91a7a 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,9 +4,9 @@ - - - + + + listmonk diff --git a/static/public/templates/index.html b/static/public/templates/index.html index 004ea079..057ab87f 100644 --- a/static/public/templates/index.html +++ b/static/public/templates/index.html @@ -12,14 +12,14 @@ href="{{ .RootURL }}/archive.xml" /> {{ end }} - - - + + + {{ if ne .FaviconURL "" }} {{ else }} - + {{ end }} @@ -30,7 +30,7 @@ {{ if ne .LogoURL "" }} {{ .Data.Title }} {{ else }} - {{ .Data.Title }} + {{ .Data.Title }} {{ end }}