From 760f7e4d2cfd066daff11e19839692023345b303 Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Fri, 26 Aug 2022 16:04:16 +0700 Subject: [PATCH] Theme config --- .github/workflows/docker-publish.yml | 2 +- Makefile | 3 ++- README.md | 2 ++ docker-compose.yml | 3 ++- src/getconfig.go | 2 ++ src/index.go | 2 +- src/main.go | 1 + src/templates/footer.html | 9 +++++++++ src/templates/header.html | 5 ----- src/templates/index.html | 10 +++++++--- 10 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 src/templates/footer.html diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index ca732c1..a0ba681 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -14,7 +14,7 @@ on: env: IMAGE_NAME: watchyourlan - TAGS: latest, v0.7.1 + TAGS: latest, v0.7.2 jobs: diff --git a/Makefile b/Makefile index f48a26a..5d352cc 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ DNAME=watchyourlan IFACE=virbr-bw DBPATH=data/hosts.db SHOUTRRR_URL=gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes +THEME=darkly mod: cd src && \ @@ -14,7 +15,7 @@ mod: run: cd src && \ sudo \ - env IFACE=$(IFACE) DBPATH=$(DBPATH) \ + env IFACE=$(IFACE) DBPATH=$(DBPATH) THEME=$(THEME) \ go run . go-build: diff --git a/README.md b/README.md index 1341955..d610fe7 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Configuration can be done through config file or environment variables | GUIPORT | Port for web GUI | 8840 | | TIMEOUT | Time between scans (seconds) | 60 (1 minute) | | SHOUTRRR_URL | Url to any notification service supported by https://github.com/containrrr/shoutrrr | "" | +| THEME | Any theme name from https://bootswatch.com in lowcase | solar | ## Config file @@ -57,4 +58,5 @@ GUIIP="192.168.2.1" # To access from LAN GUIPORT="8840" TIMEOUT="300" # 5 minutes SHOUTRRR_URL="gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes" # Url to notify +THEME="darkly" ``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e96a80f..58f1493 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,4 +13,5 @@ services: GUIIP: "0.0.0.0" # optional, default: localhost GUIPORT: "8840" # optional, default: 8840 TIMEOUT: "120" # optional, time in seconds, default: 60 - SHOUTRRR_URL: "" # optional, set url to notify \ No newline at end of file + SHOUTRRR_URL: "" # optional, set url to notify + THEME: "darkly" # optional \ No newline at end of file diff --git a/src/getconfig.go b/src/getconfig.go index bce77c7..24f8271 100644 --- a/src/getconfig.go +++ b/src/getconfig.go @@ -11,6 +11,7 @@ func get_config(path string) (config Conf) { viper.SetDefault("GUIPORT", "8840") viper.SetDefault("TIMEOUT", "60") viper.SetDefault("SHOUTRRR_URL", "") + viper.SetDefault("THEME", "solar") viper.SetConfigFile(path) viper.SetConfigType("env") @@ -24,6 +25,7 @@ func get_config(path string) (config Conf) { config.GuiPort = viper.Get("GUIPORT").(string) config.Timeout = viper.GetInt("TIMEOUT") config.ShoutUrl = viper.Get("SHOUTRRR_URL").(string) + config.Theme = viper.Get("THEME").(string) return config } \ No newline at end of file diff --git a/src/index.go b/src/index.go index 7935bd8..fac63f5 100644 --- a/src/index.go +++ b/src/index.go @@ -16,7 +16,7 @@ func index(w http.ResponseWriter, r *http.Request) { guiData.Config = AppConfig guiData.Hosts = AllHosts - tmpl, _ := template.ParseFiles("templates/index.html", "templates/header.html") + tmpl, _ := template.ParseFiles("templates/index.html", "templates/header.html", "templates/footer.html") tmpl.ExecuteTemplate(w, "index", guiData) } diff --git a/src/main.go b/src/main.go index 3e0e5e2..be3c1ed 100644 --- a/src/main.go +++ b/src/main.go @@ -22,6 +22,7 @@ type Conf struct { GuiPort string Timeout int ShoutUrl string + Theme string } var AppConfig Conf diff --git a/src/templates/footer.html b/src/templates/footer.html new file mode 100644 index 0000000..0032e6a --- /dev/null +++ b/src/templates/footer.html @@ -0,0 +1,9 @@ +{{ define "footer"}} + + + +{{ end }} \ No newline at end of file diff --git a/src/templates/header.html b/src/templates/header.html index 4c42cbb..03471c2 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -3,12 +3,7 @@ Watch Your LAN - - - - - {{ end }} \ No newline at end of file diff --git a/src/templates/index.html b/src/templates/index.html index e94d82e..36ecd0c 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,7 +1,11 @@ {{ define "index"}} {{ template "header" }} - + + + + +

Online

@@ -65,6 +69,6 @@ {{ end }}
- - + +{{ template "footer" }} {{ end }} \ No newline at end of file