diff --git a/server/README.md b/server/README.md
index 28e93b0..efdc297 100644
--- a/server/README.md
+++ b/server/README.md
@@ -10,7 +10,6 @@
- full-text-search: https://www.sqlite.org/fts5.html#contentless_tables
- - dark mode toggle for html
- app-store link in HTML
- route to re-check all pro-token
diff --git a/server/api/handler/website.go b/server/api/handler/website.go
index a9923db..4e0b610 100644
--- a/server/api/handler/website.go
+++ b/server/api/handler/website.go
@@ -6,6 +6,7 @@ import (
"blackforestbytes.com/simplecloudnotifier/website"
"errors"
"github.com/gin-gonic/gin"
+ "github.com/rs/zerolog/log"
"net/http"
"regexp"
"strings"
@@ -20,7 +21,7 @@ type WebsiteHandler struct {
func NewWebsiteHandler(app *logic.Application) WebsiteHandler {
return WebsiteHandler{
app: app,
- rexTemplate: regexp.MustCompile("{{template\\|[A-Za-z0-9_\\-.]+}}"),
+ rexTemplate: regexp.MustCompile("{{template\\|[A-Za-z0-9_\\-\\[\\].]+}}"),
rexConfig: regexp.MustCompile("{{config\\|[A-Za-z0-9_\\-.]+}}"),
}
}
@@ -86,9 +87,13 @@ func (h WebsiteHandler) serveAsset(g *gin.Context, fn string, repl bool) ginresp
data = h.rexTemplate.ReplaceAllFunc(data, func(match []byte) []byte {
prefix := len("{{template|")
suffix := len("}}")
- fnSub := match[prefix : len(match)-suffix]
- subdata, err := website.Assets.ReadFile(string(fnSub))
+ fnSub := string(match[prefix : len(match)-suffix])
+
+ fnSub = strings.ReplaceAll(fnSub, "[theme]", h.getTheme(g))
+
+ subdata, err := website.Assets.ReadFile(fnSub)
if err != nil {
+ log.Error().Str("templ", string(match)).Str("fnSub", fnSub).Str("source", fn).Msg("Failed to replace template")
failed = true
}
return subdata
@@ -104,6 +109,7 @@ func (h WebsiteHandler) serveAsset(g *gin.Context, fn string, repl bool) ginresp
cval, ok := h.getReplConfig(string(cfgKey))
if !ok {
+ log.Error().Str("templ", string(match)).Str("source", fn).Msg("Failed to replace config")
failed = true
}
return []byte(cval)
@@ -154,3 +160,15 @@ func (h WebsiteHandler) getReplConfig(key string) (string, bool) {
return "", false
}
+
+func (h WebsiteHandler) getTheme(g *gin.Context) string {
+ if c, err := g.Cookie("theme"); err != nil {
+ return "light"
+ } else if c == "light" {
+ return "light"
+ } else if c == "dark" {
+ return "dark"
+ } else {
+ return "light"
+ }
+}
diff --git a/server/test/common_test.go b/server/test/common_test.go
index 051f9cf..ef6f75e 100644
--- a/server/test/common_test.go
+++ b/server/test/common_test.go
@@ -5,6 +5,7 @@ import (
"blackforestbytes.com/simplecloudnotifier/api"
"blackforestbytes.com/simplecloudnotifier/common/ginext"
"blackforestbytes.com/simplecloudnotifier/db"
+ "blackforestbytes.com/simplecloudnotifier/google"
"blackforestbytes.com/simplecloudnotifier/jobs"
"blackforestbytes.com/simplecloudnotifier/logic"
"blackforestbytes.com/simplecloudnotifier/push"
diff --git a/server/website/api.html b/server/website/api.html
index 366afe3..0a25ae0 100644
--- a/server/website/api.html
+++ b/server/website/api.html
@@ -1,15 +1,7 @@
-
-
API Documentation
+ {{template|theme_switch.[theme].html}}
-
Send
+
+
API Documentation
+
+
Send
Simple Cloud Notifier
diff --git a/server/website/api_more.html b/server/website/api_more.html
index 9add34a..88174ba 100644
--- a/server/website/api_more.html
+++ b/server/website/api_more.html
@@ -1,15 +1,7 @@
-
-
-
Simple Cloud Notifications - API
-
-
-
-
-
-
+ {{template|header.[theme].html}}
@@ -18,10 +10,12 @@
made by Mike Schwörer
-
-
API Documentation
+ {{template|theme_switch.[theme].html}}
-
Send
+
+
API Documentation
+
+
Send
Simple Cloud Notifier
@@ -70,16 +64,10 @@
{
"success":true,
"message":"Message sent",
- "response":
- {
- "multicast_id":8000000000000000006,
- "success":1,
- "failure":0,
- "canonical_ids":0,
- "results": [{"message_id":"0:10000000000000000000000000000000d"}]
- },
+ "messagecount": 634,
"quota":17,
- "quota_max":100
+ "quota_max":100,
+ "scn_msg_id":993625
}
If the operation is not successful the API will respond with a 4xx or 500 HTTP statuscode.
@@ -116,7 +104,7 @@
There is also always a JSON payload with additional information.
- The success
field is always there and in the error state you the message
field to get a descritpion of the problem.
+ The success
field is always there and in the error case you can read the message
field to get a more information about the problem.
{
"success": false,
@@ -162,7 +150,7 @@
{{config|baseURL}}/
-
Channels
+
Channel
By default all messages are sent to the user default channel (typically main
)
@@ -222,7 +210,7 @@
Depending on your use case it can be useful to create a bash script that handles things like resending messages if you have connection problems or waiting if there is no quota left.
Here is an example how such a scrippt could look like, you can put it into /usr/local/sbin
and call it with scn_send "title" "content"
(or with more parameters, see the script itself)
-
{{template|scn_send.html}}
+ {{template|scn_send.[theme].html}}
diff --git a/server/website/css/style-dark.css b/server/website/css/style-dark.css
new file mode 100644
index 0000000..823ff5b
--- /dev/null
+++ b/server/website/css/style-dark.css
@@ -0,0 +1,34 @@
+
+
+
+#mainpnl {
+ box-shadow: initial;
+}
+
+#mainpnl h1
+{
+ text-align: center;
+ margin-top: 0;
+ margin-bottom: 24px;
+ font-weight: bold;
+ color: #CFCFCF;
+ text-shadow: #000 0 0 2px, #666 0 0 8px;
+}
+
+.edge-btn {
+ position: absolute;
+ border-color: #888 !important;
+}
+
+pre.yellow-code,
+pre.yellow-code span {
+ background: none;
+}
+
+#theme-switch {
+ fill: #EA0;
+}
+
+#theme-switch:hover {
+ fill: #88F;
+}
\ No newline at end of file
diff --git a/server/website/css/style.css b/server/website/css/style.css
index 0e04e7e..13c80c8 100644
--- a/server/website/css/style.css
+++ b/server/website/css/style.css
@@ -113,9 +113,12 @@ body
color: #0288D1;
}
+.edge-btn {
+ position: absolute;
+}
+
#tr_link
{
- position: absolute;
top: 0;
right: 0;
margin: -1px -1px 0 0;
@@ -127,7 +130,6 @@ body
#tl_link1
{
- position: absolute;
top: 0;
left: 0;
margin: -1px 0 0 -1px;
@@ -138,7 +140,6 @@ body
#tl_link2
{
- position: absolute;
top: 0;
left: 48px;
margin: -1px 0 0 -1px;
@@ -149,7 +150,6 @@ body
#tl_linkDocs
{
- position: absolute;
top: 0;
left: 0;
margin: -1px 0 0 -1px;
@@ -297,4 +297,17 @@ pre, pre span
.display_none {
display: none;
-}
\ No newline at end of file
+}
+
+#theme-switch {
+ position: absolute;
+ top: 0.75rem;
+ right: 0.75rem;
+ cursor: pointer;
+ fill: #000;
+}
+
+#theme-switch:hover {
+ filter: blur(1px);
+ fill: #008;
+}
diff --git a/server/website/header.dark.html b/server/website/header.dark.html
new file mode 100644
index 0000000..eb52789
--- /dev/null
+++ b/server/website/header.dark.html
@@ -0,0 +1,14 @@
+
+
Simple Cloud Notifications
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/server/website/header.light.html b/server/website/header.light.html
new file mode 100644
index 0000000..aa4b231
--- /dev/null
+++ b/server/website/header.light.html
@@ -0,0 +1,11 @@
+
+
Simple Cloud Notifications
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/server/website/index.html b/server/website/index.html
index 0a29f1a..c22d682 100644
--- a/server/website/index.html
+++ b/server/website/index.html
@@ -1,16 +1,7 @@
-
-
Simple Cloud Notifications
-
-
-
-
-
-
-
-
+ {{template|header.[theme].html}}
@@ -19,12 +10,14 @@
made by Mike Schwörer
+ {{template|theme_switch.[theme].html}}
+