diff --git a/README.md b/README.md index 0da4652..47be9cc 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,10 @@ docker-compose up | `WGUI_TABLE` | The default WireGuard table value settings | `auto` | | `WGUI_CONFIG_FILE_PATH` | The default WireGuard config file path used in global settings | `/etc/wireguard/wg0.conf` | | `WGUI_LOG_LEVEL` | The default log level. Possible values: `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF` | `INFO` | +| `WGUI_BRAND_TEXT` | The brand text of the web application | `WireGuard UI` | +| `WGUI_ACCENT_COLOR` | The color of the interface sidebar | `#343a40` | +| `WGUI_LOGO_FILE_PATH` | The file path of the website logo | Embedded WireGuard logo | +| `WGUI_PAGE_TITLE_PREFIX` | The HTML title prefix for all pages | N/A | | `WG_CONF_TEMPLATE` | The custom `wg.conf` config file template. Please refer to our [default template](https://github.com/ngoduykhanh/wireguard-ui/blob/master/templates/wg.conf) | N/A | | `EMAIL_FROM_ADDRESS` | The sender email address | N/A | | `EMAIL_FROM_NAME` | The sender name | `WireGuard UI` | diff --git a/custom/img/logo.png b/custom/img/logo.png new file mode 100644 index 0000000..5425633 Binary files /dev/null and b/custom/img/logo.png differ diff --git a/handler/routes.go b/handler/routes.go index a2ceeaf..b5b274a 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -42,6 +42,15 @@ func Favicon() echo.HandlerFunc { } } +func Logo() echo.HandlerFunc { + return func(c echo.Context) error { + if logo, ok := os.LookupEnv(util.LogoFilePathEnvVar); ok { + return c.File(logo) + } + return c.Redirect(http.StatusFound, util.BasePath+"/static/custom/img/logo.png") + } +} + // LoginPage handler func LoginPage() echo.HandlerFunc { return func(c echo.Context) error { diff --git a/main.go b/main.go index 0131208..9d0977b 100644 --- a/main.go +++ b/main.go @@ -41,6 +41,9 @@ var ( flagSessionSecret string = util.RandomString(32) flagWgConfTemplate string flagBasePath string + flagBrandText string = "WireGuard UI" + flagAccentColor string = "#343a40" + flagPageTitlePrefix string ) const ( @@ -80,6 +83,10 @@ func init() { flag.StringVar(&flagSessionSecret, "session-secret", util.LookupEnvOrString("SESSION_SECRET", flagSessionSecret), "The key used to encrypt session cookies.") flag.StringVar(&flagWgConfTemplate, "wg-conf-template", util.LookupEnvOrString("WG_CONF_TEMPLATE", flagWgConfTemplate), "Path to custom wg.conf template.") flag.StringVar(&flagBasePath, "base-path", util.LookupEnvOrString("BASE_PATH", flagBasePath), "The base path of the URL") + flag.StringVar(&flagBrandText, "brand-text", util.LookupEnvOrString("WGUI_BRAND_TEXT", flagBrandText), "The UI brand text or name") + flag.StringVar(&flagAccentColor, "accent-color", util.LookupEnvOrString("WGUI_ACCENT_COLOR", flagAccentColor), "The UI accent color") + flag.StringVar(&flagPageTitlePrefix, "page-title-prefix", util.LookupEnvOrString("WGUI_PAGE_TITLE_PREFIX", flagPageTitlePrefix), "The prefix of the page title") + flag.Parse() // update runtime config @@ -98,7 +105,10 @@ func init() { util.SessionSecret = []byte(flagSessionSecret) util.WgConfTemplate = flagWgConfTemplate util.BasePath = util.ParseBasePath(flagBasePath) - + util.BrandText = flagBrandText + util.AccentColor = flagAccentColor + util.PageTitlePrefix = flagPageTitlePrefix + // print only if log level is INFO or lower if lvl, _ := util.ParseLogLevel(util.LookupEnvOrString(util.LogLevel, "INFO")); lvl <= log.INFO { // print app information @@ -133,6 +143,9 @@ func main() { extraData["gitCommit"] = gitCommit extraData["basePath"] = util.BasePath extraData["loginDisabled"] = flagDisableLogin + extraData["brandText"] = flagBrandText; + extraData["accentColor"] = flagAccentColor; + extraData["pageTitlePrefix"] = flagPageTitlePrefix; // strip the "templates/" prefix from the embedded directory so files can be read by their direct name (e.g. // "base.html" instead of "templates/base.html") @@ -170,6 +183,7 @@ func main() { app.GET(util.BasePath+"/about", handler.AboutPage()) app.GET(util.BasePath+"/_health", handler.Health()) app.GET(util.BasePath+"/favicon", handler.Favicon()) + app.GET(util.BasePath+"/logo", handler.Logo()) app.POST(util.BasePath+"/new-client", handler.NewClient(db), handler.ValidSession, handler.ContentTypeJson) app.POST(util.BasePath+"/update-client", handler.UpdateClient(db), handler.ValidSession, handler.ContentTypeJson) app.POST(util.BasePath+"/email-client", handler.EmailClient(db, sendmail, defaultEmailSubject, defaultEmailContent), handler.ValidSession, handler.ContentTypeJson) diff --git a/templates/base.html b/templates/base.html index 0865ff3..88bb49d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,7 +5,7 @@
-