High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
Add embedding of static assets for standalone dist binary
Kailash Nadh7eeb813f1960
diff --git a/Makefile b/Makefileindex 86eacf42..4a94637b 100644--- a/Makefile+++ b/Makefile@@ -1,4 +1,5 @@BIN := listmonk+STATIC := config.toml.sample schema.sql queries.sql public email-templates frontend/my/build:/frontendHASH := $(shell git rev-parse --short HEAD)COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})@@ -6,7 +7,11 @@ BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')VERSION := ${HASH} (${COMMIT_DATE})build:- go build -o ${BIN} -ldflags="-X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'"+ go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'"+ stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}++deps:+ go get -u github.com/knadh/stuffbin/...test:go testdiff --git a/config.toml.sample b/config.toml.sampleindex 337c6d5c..12472f7d 100644--- a/config.toml.sample+++ b/config.toml.sample@@ -4,7 +4,17 @@ address = "0.0.0.0:9000"# Public root URL of the listmonk installation that'll be used# in the messages for linking to images, unsubscribe page etc.-root = "http://listmonk.mysite.com"+root = "https://listmonk.mysite.com"++# (Optional) full URL to the static logo to be displayed on+# user facing view such as the unsubscription page.+# eg: https://mysite.com/images/logo.svg+logo_url = ""++# (Optional) full URL to the static favicon to be displayed on+# user facing view such as the unsubscription page.+# eg: https://mysite.com/images/favicon.png+favicon_url = ""# The default 'from' e-mail for outgoing e-mail campaigns.from_email = "listmonk <[email protected]>"@@ -22,9 +32,6 @@ upload_path = "uploads"# under this URI, for instance, list.yoursite.com/uploads.upload_uri = "/uploads"-# Directory where the app's static assets are stored (index.html, ./static etc.)-asset_path = "frontend/my/build"-# Maximum concurrent workers that will attempt to send messages# simultaneously. This should depend on the number of CPUs the# machine has and also the number of simultaenous e-mails thediff --git a/templates/base.html b/email-templates/base.htmlsimilarity index 100%rename from templates/base.htmlrename to email-templates/base.htmldiff --git a/templates/campaign-status.html b/email-templates/campaign-status.htmlsimilarity index 100%rename from templates/campaign-status.htmlrename to email-templates/campaign-status.htmldiff --git a/templates/default.tpl b/email-templates/default.tplsimilarity index 100%rename from templates/default.tplrename to email-templates/default.tpldiff --git a/templates/import-status.html b/email-templates/import-status.htmlsimilarity index 100%rename from templates/import-status.htmlrename to email-templates/import-status.htmldiff --git a/frontend/my/package.json b/frontend/my/package.jsonindex 7c90fe15..d39b1b05 100644--- a/frontend/my/package.json+++ b/frontend/my/package.json@@ -16,15 +16,9 @@"react-router-dom": "^4.3.1","react-scripts": "1.1.4"},- "xxscripts": {- "start": "react-scripts start",- "build": "react-scripts build",- "test": "react-scripts test --env=jsdom",- "eject": "react-scripts eject"- },"scripts": {"start": "react-app-rewired start",- "build": "react-app-rewired build",+ "build": "GENERATE_SOURCEMAP=false PUBLIC_URL=/frontend/ react-app-rewired build","test": "react-app-rewired test --env=jsdom","eject": "react-scripts eject"},diff --git a/frontend/my/public/index.html b/frontend/my/public/index.htmlindex 2288373b..c2f23fc4 100644--- a/frontend/my/public/index.html+++ b/frontend/my/public/index.html@@ -4,11 +4,11 @@<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="theme-color" content="#000000">- <script src="%PUBLIC_URL%/api/config.js" type="text/javascript"></script>+ <script src="/api/config.js" type="text/javascript"></script><link href="https://fonts.googleapis.com/css?family=IBM+Plex+Sans:400,600" rel="stylesheet"><link rel="manifest" href="%PUBLIC_URL%/manifest.json"><link rel="shortcut icon" href="%PUBLIC_URL%/favicon.png">- <title>%PUBLIC_URL%</title>+ <title>listmonk</title></head><body><noscript>diff --git a/handlers.go b/handlers.goindex c3350331..266c84de 100644--- a/handlers.go+++ b/handlers.go@@ -2,16 +2,14 @@ package mainimport ("encoding/json"+ "net/http""net/url"- "path/filepath""strconv""strings""github.com/asaskevich/govalidator"- "github.com/gorilla/sessions""github.com/labstack/echo"- "github.com/labstack/echo-contrib/session")const (@@ -40,39 +38,99 @@ type pagination struct {Limit int `json:"limit"`}-// auth is a middleware that handles session authentication. If a session is not set,-// it creates one and redirects the user to the login page. If a session is set,-// it's authenticated before proceeding to the handler.-func authSession(next echo.HandlerFunc) echo.HandlerFunc {- return func(c echo.Context) error {- sess, _ := session.Get("session", c)-- // It's a brand new session. Persist it.- if sess.IsNew {- sess.Options = &sessions.Options{- Path: "/",- MaxAge: 86400 * 7,- HttpOnly: true,- // Secure: true,- }-- sess.Values["user_id"] = 1- sess.Values["user"] = "kailash"- sess.Values["role"] = "superadmin"- sess.Values["user_email"] = "[email protected]"-- sess.Save(c.Request(), c.Response())- }-- return next(c)- }+// registerHandlers registers HTTP handlers.+func registerHandlers(e *echo.Echo) {+ e.GET("/", handleIndexPage)+ e.GET("/api/config.js", handleGetConfigScript)+ e.GET("/api/dashboard/stats", handleGetDashboardStats)+ e.GET("/api/users", handleGetUsers)+ e.POST("/api/users", handleCreateUser)+ e.DELETE("/api/users/:id", handleDeleteUser)++ e.GET("/api/subscribers/:id", handleGetSubscriber)+ e.POST("/api/subscribers", handleCreateSubscriber)+ e.PUT("/api/subscribers/:id", handleUpdateSubscriber)+ e.PUT("/api/subscribers/blacklist", handleBlacklistSubscribers)+ e.PUT("/api/subscribers/:id/blacklist", handleBlacklistSubscribers)+ e.PUT("/api/subscribers/lists/:id", handleManageSubscriberLists)+ e.PUT("/api/subscribers/lists", handleManageSubscriberLists)+ e.DELETE("/api/subscribers/:id", handleDeleteSubscribers)+ e.DELETE("/api/subscribers", handleDeleteSubscribers)++ // Subscriber operations based on arbitrary SQL queries.+ // These aren't very REST-like.+ e.POST("/api/subscribers/query/delete", handleDeleteSubscribersByQuery)+ e.PUT("/api/subscribers/query/blacklist", handleBlacklistSubscribersByQuery)+ e.PUT("/api/subscribers/query/lists", handleManageSubscriberListsByQuery)++ e.GET("/api/subscribers", handleQuerySubscribers)++ e.GET("/api/import/subscribers", handleGetImportSubscribers)+ e.GET("/api/import/subscribers/logs", handleGetImportSubscriberStats)+ e.POST("/api/import/subscribers", handleImportSubscribers)+ e.DELETE("/api/import/subscribers", handleStopImportSubscribers)++ e.GET("/api/lists", handleGetLists)+ e.GET("/api/lists/:id", handleGetLists)+ e.POST("/api/lists", handleCreateList)+ e.PUT("/api/lists/:id", handleUpdateList)+ e.DELETE("/api/lists/:id", handleDeleteLists)++ e.GET("/api/campaigns", handleGetCampaigns)+ e.GET("/api/campaigns/running/stats", handleGetRunningCampaignStats)+ e.GET("/api/campaigns/:id", handleGetCampaigns)+ e.GET("/api/campaigns/:id/preview", handlePreviewCampaign)+ e.POST("/api/campaigns/:id/preview", handlePreviewCampaign)+ e.POST("/api/campaigns/:id/test", handleTestCampaign)+ e.POST("/api/campaigns", handleCreateCampaign)+ e.PUT("/api/campaigns/:id", handleUpdateCampaign)+ e.PUT("/api/campaigns/:id/status", handleUpdateCampaignStatus)+ e.DELETE("/api/campaigns/:id", handleDeleteCampaign)++ e.GET("/api/media", handleGetMedia)+ e.POST("/api/media", handleUploadMedia)+ e.DELETE("/api/media/:id", handleDeleteMedia)++ e.GET("/api/templates", handleGetTemplates)+ e.GET("/api/templates/:id", handleGetTemplates)+ e.GET("/api/templates/:id/preview", handlePreviewTemplate)+ e.POST("/api/templates/preview", handlePreviewTemplate)+ e.POST("/api/templates", handleCreateTemplate)+ e.PUT("/api/templates/:id", handleUpdateTemplate)+ e.PUT("/api/templates/:id/default", handleTemplateSetDefault)+ e.DELETE("/api/templates/:id", handleDeleteTemplate)++ // Subscriber facing views.+ e.GET("/unsubscribe/:campUUID/:subUUID", handleUnsubscribePage)+ e.POST("/unsubscribe/:campUUID/:subUUID", handleUnsubscribePage)+ e.GET("/link/:linkUUID/:campUUID/:subUUID", handleLinkRedirect)+ e.GET("/campaign/:campUUID/:subUUID/px.png", handleRegisterCampaignView)++ // Static views.+ e.GET("/lists", handleIndexPage)+ e.GET("/subscribers", handleIndexPage)+ e.GET("/subscribers/lists/:listID", handleIndexPage)+ e.GET("/subscribers/import", handleIndexPage)+ e.GET("/campaigns", handleIndexPage)+ e.GET("/campaigns/new", handleIndexPage)+ e.GET("/campaigns/media", handleIndexPage)+ e.GET("/campaigns/templates", handleIndexPage)+ e.GET("/campaigns/:campignID", handleIndexPage)}// handleIndex is the root handler that renders the login page if there's no// authenticated session, or redirects to the dashboard, if there's one.func handleIndexPage(c echo.Context) error {app := c.Get("app").(*App)- return c.File(filepath.Join(app.Constants.AssetPath, "index.html"))++ b, err := app.FS.Read("/frontend/index.html")+ if err != nil {+ return echo.NewHTTPError(http.StatusInternalServerError,+ err)+ }++ c.Response().Header().Set("Content-Type", "text/html")+ return c.String(http.StatusOK, string(b))}// makeAttribsBlob takes a list of keys and values and createsdiff --git a/install.go b/install.goindex d262d8a7..7b9e9d76 100644--- a/install.go+++ b/install.go@@ -29,9 +29,10 @@ func install(app *App, qMap goyesql.Queries) {emRegex, _ = regexp.Compile("(.+?)@(.+?)"))+ fmt.Println("")fmt.Println("** First time installation. **")fmt.Println("** IMPORTANT: This will wipe existing listmonk tables and types. **")- fmt.Println("\n")+ fmt.Println("")for len(email) == 0 {fmt.Print("Enter the superadmin login e-mail: ")@@ -83,7 +84,7 @@ func install(app *App, qMap goyesql.Queries) {}// Migrate the tables.- err = installMigrate(app.DB)+ err = installMigrate(app.DB, app)if err != nil {logger.Fatalf("Error migrating DB schema: %v", err)}@@ -152,8 +153,8 @@ func install(app *App, qMap goyesql.Queries) {}// installMigrate executes the SQL schema and creates the necessary tables and types.-func installMigrate(db *sqlx.DB) error {- q, err := ioutil.ReadFile("schema.sql")+func installMigrate(db *sqlx.DB, app *App) error {+ q, err := app.FS.Read("/schema.sql")if err != nil {return err}diff --git a/main.go b/main.goindex 719b751b..e09e3ab5 100644--- a/main.go+++ b/main.go@@ -15,14 +15,16 @@ import ("github.com/knadh/listmonk/manager""github.com/knadh/listmonk/messenger""github.com/knadh/listmonk/subimporter"+ "github.com/knadh/stuffbin""github.com/labstack/echo"flag "github.com/spf13/pflag""github.com/spf13/viper")type constants struct {- AssetPath string `mapstructure:"asset_path"`RootURL string `mapstructure:"root"`+ LogoURL string `mapstructure:"logo_url"`+ FaviconURL string `mapstructure:"favicon_url"`UploadPath string `mapstructure:"upload_path"`UploadURI string `mapstructure:"upload_uri"`FromEmail string `mapstructure:"from_email"`@@ -37,6 +39,7 @@ type App struct {Queries *QueriesImporter *subimporter.ImporterManager *manager.Manager+ FS stuffbin.FileSystemLogger *log.LoggerNotifTpls *template.TemplateMessenger messenger.Messenger@@ -77,84 +80,36 @@ func init() {}}-// registerHandlers registers HTTP handlers.-func registerHandlers(e *echo.Echo) {- e.GET("/", handleIndexPage)- e.GET("/api/config.js", handleGetConfigScript)- e.GET("/api/dashboard/stats", handleGetDashboardStats)- e.GET("/api/users", handleGetUsers)- e.POST("/api/users", handleCreateUser)- e.DELETE("/api/users/:id", handleDeleteUser)-- e.GET("/api/subscribers/:id", handleGetSubscriber)- e.POST("/api/subscribers", handleCreateSubscriber)- e.PUT("/api/subscribers/:id", handleUpdateSubscriber)- e.PUT("/api/subscribers/blacklist", handleBlacklistSubscribers)- e.PUT("/api/subscribers/:id/blacklist", handleBlacklistSubscribers)- e.PUT("/api/subscribers/lists/:id", handleManageSubscriberLists)- e.PUT("/api/subscribers/lists", handleManageSubscriberLists)- e.DELETE("/api/subscribers/:id", handleDeleteSubscribers)- e.DELETE("/api/subscribers", handleDeleteSubscribers)-- // Subscriber operations based on arbitrary SQL queries.- // These aren't very REST-like.- e.POST("/api/subscribers/query/delete", handleDeleteSubscribersByQuery)- e.PUT("/api/subscribers/query/blacklist", handleBlacklistSubscribersByQuery)- e.PUT("/api/subscribers/query/lists", handleManageSubscriberListsByQuery)-- e.GET("/api/subscribers", handleQuerySubscribers)-- e.GET("/api/import/subscribers", handleGetImportSubscribers)- e.GET("/api/import/subscribers/logs", handleGetImportSubscriberStats)- e.POST("/api/import/subscribers", handleImportSubscribers)- e.DELETE("/api/import/subscribers", handleStopImportSubscribers)-- e.GET("/api/lists", handleGetLists)- e.GET("/api/lists/:id", handleGetLists)- e.POST("/api/lists", handleCreateList)- e.PUT("/api/lists/:id", handleUpdateList)- e.DELETE("/api/lists/:id", handleDeleteLists)-- e.GET("/api/campaigns", handleGetCampaigns)- e.GET("/api/campaigns/running/stats", handleGetRunningCampaignStats)- e.GET("/api/campaigns/:id", handleGetCampaigns)- e.GET("/api/campaigns/:id/preview", handlePreviewCampaign)- e.POST("/api/campaigns/:id/preview", handlePreviewCampaign)- e.POST("/api/campaigns/:id/test", handleTestCampaign)- e.POST("/api/campaigns", handleCreateCampaign)- e.PUT("/api/campaigns/:id", handleUpdateCampaign)- e.PUT("/api/campaigns/:id/status", handleUpdateCampaignStatus)- e.DELETE("/api/campaigns/:id", handleDeleteCampaign)-- e.GET("/api/media", handleGetMedia)- e.POST("/api/media", handleUploadMedia)- e.DELETE("/api/media/:id", handleDeleteMedia)-- e.GET("/api/templates", handleGetTemplates)- e.GET("/api/templates/:id", handleGetTemplates)- e.GET("/api/templates/:id/preview", handlePreviewTemplate)- e.POST("/api/templates/preview", handlePreviewTemplate)- e.POST("/api/templates", handleCreateTemplate)- e.PUT("/api/templates/:id", handleUpdateTemplate)- e.PUT("/api/templates/:id/default", handleTemplateSetDefault)- e.DELETE("/api/templates/:id", handleDeleteTemplate)-- // Subscriber facing views.- e.GET("/unsubscribe/:campUUID/:subUUID", handleUnsubscribePage)- e.POST("/unsubscribe/:campUUID/:subUUID", handleUnsubscribePage)- e.GET("/link/:linkUUID/:campUUID/:subUUID", handleLinkRedirect)- e.GET("/campaign/:campUUID/:subUUID/px.png", handleRegisterCampaignView)-- // Static views.- e.GET("/lists", handleIndexPage)- e.GET("/subscribers", handleIndexPage)- e.GET("/subscribers/lists/:listID", handleIndexPage)- e.GET("/subscribers/import", handleIndexPage)- e.GET("/campaigns", handleIndexPage)- e.GET("/campaigns/new", handleIndexPage)- e.GET("/campaigns/media", handleIndexPage)- e.GET("/campaigns/templates", handleIndexPage)- e.GET("/campaigns/:campignID", handleIndexPage)+// initFileSystem initializes the stuffbin FileSystem to provide+// access to bunded static assets to the app.+func initFileSystem(binPath string) (stuffbin.FileSystem, error) {+ fs, err := stuffbin.UnStuff("./listmonk")+ if err == nil {+ return fs, nil+ }++ // Running in local mode. Load the required static assets into+ // the in-memory stuffbin.FileSystem.+ logger.Printf("unable to initialize embedded filesystem: %v", err)+ logger.Printf("using local filesystem for static assets")+ files := []string{+ "config.toml.sample",+ "queries.sql",+ "schema.sql",+ "email-templates",+ "public",++ // The frontend app's static assets are aliased to /frontend+ // so that they are accessible at localhost:port/frontend/static/ ...+ "frontend/my/build:/frontend",+ }++ fs, err = stuffbin.NewLocalFS("/", files...)+ if err != nil {+ return nil, fmt.Errorf("failed to initialize local file for assets: %v", err)+ }++ return fs, nil}// initMessengers initializes various messaging backends.@@ -163,7 +118,7 @@ func initMessengers(r *manager.Manager) messenger.Messenger {var srv []messenger.Serverfor name := range viper.GetStringMapString("smtp") {if !viper.GetBool(fmt.Sprintf("smtp.%s.enabled", name)) {- logger.Printf("skipped SMTP config %s", name)+ logger.Printf("skipped SMTP: %s", name)continue}@@ -173,7 +128,7 @@ func initMessengers(r *manager.Manager) messenger.Messenger {s.SendTimeout = s.SendTimeout * time.Millisecondsrv = append(srv, s)- logger.Printf("loaded SMTP config %s (%s@%s)", s.Name, s.Username, s.Host)+ logger.Printf("loaded SMTP: %s (%s@%s)", s.Name, s.Username, s.Host)}msgr, err := messenger.NewEmailer(srv...)@@ -203,22 +158,34 @@ func main() {viper.UnmarshalKey("app", &c)c.RootURL = strings.TrimRight(c.RootURL, "/")c.UploadURI = filepath.Clean(c.UploadURI)- c.AssetPath = filepath.Clean(c.AssetPath)+ c.UploadPath = filepath.Clean(c.UploadPath)++ // Initialize the static file system into which all+ // required static assets (.sql, .js files etc.) are loaded.+ fs, err := initFileSystem(os.Args[0])+ if err != nil {+ logger.Fatal(err)+ }// Initialize the app context that's passed around.app := &App{Constants: &c,DB: db,Logger: logger,+ FS: fs,}// Load SQL queries.- qMap, err := goyesql.ParseFile("queries.sql")+ qB, err := fs.Read("/queries.sql")+ if err != nil {+ logger.Fatalf("error reading queries.sql: %v", err)+ }+ qMap, err := goyesql.ParseBytes(qB)if err != nil {- logger.Fatalf("error loading SQL queries: %v", err)+ logger.Fatalf("error parsing SQL queries: %v", err)}- // First time installation.+ // Run the first time installation.if viper.GetBool("install") {install(app, qMap)return@@ -231,7 +198,7 @@ func main() {}app.Queries = q- // Importer.+ // Initialize the bulk subscriber importer.importNotifCB := func(subject string, data map[string]interface{}) error {return sendNotification(notifTplImport, subject, data, app)}@@ -240,14 +207,14 @@ func main() {db.DB,importNotifCB)- // System e-mail templates.- notifTpls, err := template.ParseGlob("templates/*.html")+ // Read system e-mail templates.+ notifTpls, err := stuffbin.ParseTemplatesGlob(fs, "/email-templates/*.html")if err != nil {- logger.Fatalf("error loading system templates: %v", err)+ logger.Fatalf("error loading system e-mail templates: %v", err)}app.NotifTpls = notifTpls- // Campaign daemon.+ // Initialize the campaign manager.campNotifCB := func(subject string, data map[string]interface{}) error {return sendNotification(notifTplCampaign, subject, data, app)}@@ -270,11 +237,15 @@ func main() {// Add messengers.app.Messenger = initMessengers(app.Manager)+ // Initialize the workers that push out messages.go m.Run(time.Duration(time.Second * 5))m.SpawnWorkers()- // Initialize the server.+ // Initialize the HTTP server.var srv = echo.New()+ srv.HideBanner = true++ // Register app (*App) to be injected into all HTTP handlers.srv.Use(func(next echo.HandlerFunc) echo.HandlerFunc {return func(c echo.Context) error {c.Set("app", app)@@ -282,25 +253,22 @@ func main() {}})- // User facing templates.- tpl, err := template.ParseGlob("public/templates/*.html")+ // Parse user facing templates.+ tpl, err := stuffbin.ParseTemplatesGlob(fs, "/public/templates/*.html")if err != nil {logger.Fatalf("error parsing public templates: %v", err)}- srv.Renderer = &Template{- templates: tpl,- }- srv.HideBanner = true-- // Register HTTP middleware.- // e.Use(session.Middleware(sessions.NewCookieStore([]byte("secret"))))- // e.Use(authSession)- srv.Static("/static", filepath.Join(filepath.Clean(viper.GetString("app.asset_path")), "static"))- srv.Static("/static/public", "frontend/my/public")- srv.Static("/public/static", "public/static")- srv.Static(filepath.Clean(viper.GetString("app.upload_uri")),- filepath.Clean(viper.GetString("app.upload_path")))+ srv.Renderer = &tplRenderer{+ templates: tpl,+ RootURL: c.RootURL,+ LogoURL: c.LogoURL,+ FaviconURL: c.FaviconURL}++ // Register HTTP handlers and static file servers.+ fSrv := app.FS.FileServer()+ srv.GET("/public/*", echo.WrapHandler(fSrv))+ srv.GET("/frontend/*", echo.WrapHandler(fSrv))+ srv.Static(c.UploadURI, c.UploadURI)registerHandlers(srv)-srv.Logger.Fatal(srv.Start(viper.GetString("app.address")))}diff --git a/package.json b/package.jsondeleted file mode 100644index ec958d41..00000000--- a/package.json+++ /dev/null@@ -1,5 +0,0 @@-{- "dependencies": {- "qs": "^6.5.2"- }-}diff --git a/public.go b/public.goindex 220cefe1..b3238bca 100644--- a/public.go+++ b/public.go@@ -13,9 +13,21 @@ import ("github.com/labstack/echo")-// Template wraps a template.Template for echo.-type Template struct {- templates *template.Template+// tplRenderer wraps a template.tplRenderer for echo.+type tplRenderer struct {+ templates *template.Template+ RootURL string+ LogoURL string+ FaviconURL string+}++// tplData is the data container that is injected+// into public templates for accessing data.+type tplData struct {+ RootURL string+ LogoURL string+ FaviconURL string+ Data interface{}}type publicTpl struct {@@ -31,7 +43,6 @@ type unsubTpl struct {type errorTpl struct {publicTpl-ErrorTitle stringErrorMessage string}@@ -42,8 +53,13 @@ var ()// Render executes and renders a template for echo.-func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {- return t.templates.ExecuteTemplate(w, name, data)+func (t *tplRenderer) Render(w io.Writer, name string, data interface{}, c echo.Context) error {+ return t.templates.ExecuteTemplate(w, name, tplData{+ RootURL: t.RootURL,+ LogoURL: t.LogoURL,+ FaviconURL: t.FaviconURL,+ Data: data,+ })}// handleUnsubscribePage unsubscribes a subscriber and renders a view.@@ -66,7 +82,7 @@ func handleUnsubscribePage(c echo.Context) error {return c.Render(http.StatusBadRequest, "error",makeErrorTpl("Invalid request", "",`The unsubscription request contains invalid IDs.- Please click on the correct link.`))+ Please follow the correct link.`))}// Unsubscribe.@@ -74,7 +90,8 @@ func handleUnsubscribePage(c echo.Context) error {res, err := app.Queries.Unsubscribe.Exec(campUUID, subUUID, blacklist)if err != nil {app.Logger.Printf("Error unsubscribing : %v", err)- return echo.NewHTTPError(http.StatusBadRequest, "There was an internal error while unsubscribing you.")+ return echo.NewHTTPError(http.StatusBadRequest,+ "There was an internal error while unsubscribing you.")}if !blacklist {@@ -82,7 +99,7 @@ func handleUnsubscribePage(c echo.Context) error {if num == 0 {return c.Render(http.StatusBadRequest, "error",makeErrorTpl("Already unsubscribed", "",- `Looks like you are not subscribed to this mailing list.+ `You are not subscribed to this mailing list.You may have already unsubscribed.`))}}@@ -110,7 +127,8 @@ func handleLinkRedirect(c echo.Context) error {if err := app.Queries.RegisterLinkClick.Get(&url, linkUUID, campUUID, subUUID); err != nil {app.Logger.Printf("error fetching redirect link: %s", err)return c.Render(http.StatusInternalServerError, "error",- makeErrorTpl("Error opening link", "", "There was an error opening the link. Please try later."))+ makeErrorTpl("Error opening link", "",+ "There was an error opening the link. Please try later."))}return c.Redirect(http.StatusTemporaryRedirect, url)@@ -143,7 +161,6 @@ func drawTransparentImage(h, w int) []byte {img = image.NewRGBA(image.Rect(0, 0, w, h))out = &bytes.Buffer{})-png.Encode(out, img)return out.Bytes()}diff --git a/public/static/style.css b/public/static/style.cssindex 92d9fb16..073c41e1 100644--- a/public/static/style.css+++ b/public/static/style.css@@ -53,7 +53,7 @@ h1, h2, h3, h4 {}.header .logo img {width: auto;- max-height: 24px;+ max-width: 150px;}.unsub-all {diff --git a/public/templates/error.html b/public/templates/error.htmlindex d7190052..8a849dfc 100644--- a/public/templates/error.html+++ b/public/templates/error.html@@ -1,9 +1,9 @@{{ define "error" }}{{ template "header" .}}- <h2>{{ .ErrorTitle }}</h2>+ <h2>{{ .Data.ErrorTitle }}</h2><div>- {{ .ErrorMessage }}+ {{ .Data.ErrorMessage }}</div>{{ template "footer" .}}diff --git a/public/templates/hello.html b/public/templates/hello.htmldeleted file mode 100644index 7769d052..00000000--- a/public/templates/hello.html+++ /dev/null@@ -1,3 +0,0 @@-{{ define "hello" }}-hello-{{ end }}diff --git a/public/templates/hello2.html b/public/templates/hello2.htmldeleted file mode 100644index ffbce4cc..00000000--- a/public/templates/hello2.html+++ /dev/null@@ -1,3 +0,0 @@-{{ define "hello" }}-hello2-{{ end }}diff --git a/public/templates/index.html b/public/templates/index.htmlindex 48e4b3d6..3de651a0 100644--- a/public/templates/index.html+++ b/public/templates/index.html@@ -3,22 +3,32 @@<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <title>{{ .Title }}</title>- <meta name="description" content="{{ .Description }}" />+ <title>{{ .Data.Title }}</title>+ <meta name="description" content="{{ .Data.Description }}" /><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />- <link href='https://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>+ <link href="https://fonts.googleapis.com/css?family=IBM+Plex+Sans:400,600" rel="stylesheet"><link href="/public/static/style.css" rel="stylesheet" type="text/css" />- <link rel="shortcut icon" href="/public/static/favicon.png" type="image/x-icon" />++ {{ if ne .FaviconURL "" }}+ <link rel="shortcut icon" href="{{ .FaviconURL }}" type="image/x-icon" />+ {{ else }}+ <link rel="shortcut icon" href="/public/static/favicon.png" type="image/x-icon" />+ {{ end }}</head><body><div class="container wrap"><header class="header">- <div class="logo"><img src="/public/static/logo.svg" /></div>+ <div class="logo">+ {{ if ne .LogoURL "" }}+ <img src="{{ .LogoURL }}" alt="{{ .Data.Title }}" />+ {{ else }}+ <img src="/public/static/logo.svg" alt="{{ .Data.Title }}" />+ {{ end }}+ </div></header>{{ end }}-{{ define "footer" }}</div>diff --git a/public/templates/unsubscribe.html b/public/templates/unsubscribe.htmlindex ad784f50..906373b1 100644--- a/public/templates/unsubscribe.html+++ b/public/templates/unsubscribe.html@@ -1,7 +1,7 @@{{ define "unsubscribe" }}{{ template "header" .}}- {{ if not .Unsubscribe }}+ {{ if not .Data.Unsubscribe }}<h2>Unsubscribe</h2><p>Do you wish to unsubscribe from this mailing list?</p><form method="post">@@ -13,7 +13,7 @@{{ else }}<h2>You have been unsubscribed</h2>- {{ if not .Blacklist }}+ {{ if not .Data.Blacklist }}<div class="unsub-all"><p>Unsubscribe from all future communications?diff --git a/sqlboiler.toml b/sqlboiler.tomldeleted file mode 100644index cb88066d..00000000--- a/sqlboiler.toml+++ /dev/null@@ -1,6 +0,0 @@-[postgres]-dbname="listmonk"-host="localhost"-port=5432-user="postgres"-pass="postgres"