|
@@ -55,6 +55,8 @@ func initHTTPHandlers(e *echo.Echo, app *App) {
|
|
return c.Render(http.StatusOK, "home", publicTpl{Title: "listmonk"})
|
|
return c.Render(http.StatusOK, "home", publicTpl{Title: "listmonk"})
|
|
})
|
|
})
|
|
g.GET(path.Join(adminRoot, ""), handleAdminPage)
|
|
g.GET(path.Join(adminRoot, ""), handleAdminPage)
|
|
|
|
+ g.GET(path.Join(adminRoot, "/custom.css"), serveCustomApperance("admin.custom_css"))
|
|
|
|
+ g.GET(path.Join(adminRoot, "/custom.js"), serveCustomApperance("admin.custom_js"))
|
|
g.GET(path.Join(adminRoot, "/*"), handleAdminPage)
|
|
g.GET(path.Join(adminRoot, "/*"), handleAdminPage)
|
|
|
|
|
|
// API endpoints.
|
|
// API endpoints.
|
|
@@ -142,6 +144,7 @@ func initHTTPHandlers(e *echo.Echo, app *App) {
|
|
e.POST("/webhooks/service/:service", handleBounceWebhook)
|
|
e.POST("/webhooks/service/:service", handleBounceWebhook)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // /public/static/* file server is registered in initHTTPServer().
|
|
// Public subscriber facing views.
|
|
// Public subscriber facing views.
|
|
e.GET("/subscription/form", handleSubscriptionFormPage)
|
|
e.GET("/subscription/form", handleSubscriptionFormPage)
|
|
e.POST("/subscription/form", handleSubscriptionForm)
|
|
e.POST("/subscription/form", handleSubscriptionForm)
|
|
@@ -161,6 +164,10 @@ func initHTTPHandlers(e *echo.Echo, app *App) {
|
|
"campUUID", "subUUID")))
|
|
"campUUID", "subUUID")))
|
|
e.GET("/campaign/:campUUID/:subUUID/px.png", noIndex(validateUUID(handleRegisterCampaignView,
|
|
e.GET("/campaign/:campUUID/:subUUID/px.png", noIndex(validateUUID(handleRegisterCampaignView,
|
|
"campUUID", "subUUID")))
|
|
"campUUID", "subUUID")))
|
|
|
|
+
|
|
|
|
+ e.GET("/public/custom.css", serveCustomApperance("public.custom_css"))
|
|
|
|
+ e.GET("/public/custom.js", serveCustomApperance("public.custom_js"))
|
|
|
|
+
|
|
// Public health API endpoint.
|
|
// Public health API endpoint.
|
|
e.GET("/health", handleHealthCheck)
|
|
e.GET("/health", handleHealthCheck)
|
|
}
|
|
}
|
|
@@ -182,6 +189,39 @@ func handleHealthCheck(c echo.Context) error {
|
|
return c.JSON(http.StatusOK, okResp{true})
|
|
return c.JSON(http.StatusOK, okResp{true})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// serveCustomApperance serves the given custom CSS/JS apperance blob
|
|
|
|
+// meant for customizing public and admin pages from the admin settings UI.
|
|
|
|
+func serveCustomApperance(name string) echo.HandlerFunc {
|
|
|
|
+ return func(c echo.Context) error {
|
|
|
|
+ var (
|
|
|
|
+ app = c.Get("app").(*App)
|
|
|
|
+
|
|
|
|
+ out []byte
|
|
|
|
+ hdr string
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ switch name {
|
|
|
|
+ case "admin.custom_css":
|
|
|
|
+ out = app.constants.Appearance.AdminCSS
|
|
|
|
+ hdr = "text/css; charset=utf-8"
|
|
|
|
+
|
|
|
|
+ case "admin.custom_js":
|
|
|
|
+ out = app.constants.Appearance.AdminJS
|
|
|
|
+ hdr = "application/javascript; charset=utf-8"
|
|
|
|
+
|
|
|
|
+ case "public.custom_css":
|
|
|
|
+ out = app.constants.Appearance.PublicCSS
|
|
|
|
+ hdr = "text/css; charset=utf-8"
|
|
|
|
+
|
|
|
|
+ case "public.custom_js":
|
|
|
|
+ out = app.constants.Appearance.PublicJS
|
|
|
|
+ hdr = "application/javascript; charset=utf-8"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return c.Blob(http.StatusOK, hdr, out)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// basicAuth middleware does an HTTP BasicAuth authentication for admin handlers.
|
|
// basicAuth middleware does an HTTP BasicAuth authentication for admin handlers.
|
|
func basicAuth(username, password string, c echo.Context) (bool, error) {
|
|
func basicAuth(username, password string, c echo.Context) (bool, error) {
|
|
app := c.Get("app").(*App)
|
|
app := c.Get("app").(*App)
|