diff --git a/files.go b/files.go
index 68f8742..931daaa 100755
--- a/files.go
+++ b/files.go
@@ -71,6 +71,7 @@ func handleFileSearch(w http.ResponseWriter, settings UserSettings, query string
CurrentLang string
Theme string
Safe string
+ IsThemeDark bool
}{
Results: combinedResults,
Query: query,
@@ -84,6 +85,7 @@ func handleFileSearch(w http.ResponseWriter, settings UserSettings, query string
CurrentLang: settings.Language,
Theme: settings.Theme,
Safe: settings.SafeSearch,
+ IsThemeDark: settings.IsThemeDark,
}
// // Debugging: Print results before rendering template
diff --git a/forums.go b/forums.go
index d0be4f6..4c15490 100755
--- a/forums.go
+++ b/forums.go
@@ -115,6 +115,7 @@ func handleForumsSearch(w http.ResponseWriter, settings UserSettings, query stri
CurrentLang string
Theme string
Safe string
+ IsThemeDark bool
}{
Query: query,
Results: results,
@@ -125,6 +126,7 @@ func handleForumsSearch(w http.ResponseWriter, settings UserSettings, query stri
CurrentLang: settings.Language,
Theme: settings.Theme,
Safe: settings.SafeSearch,
+ IsThemeDark: settings.IsThemeDark,
}
funcMap := template.FuncMap{
diff --git a/images.go b/images.go
index 86920e2..dc2c9b0 100755
--- a/images.go
+++ b/images.go
@@ -44,6 +44,7 @@ func handleImageSearch(w http.ResponseWriter, settings UserSettings, query strin
CurrentLang string
Theme string
Safe string
+ IsThemeDark bool
}{
Results: combinedResults,
Query: query,
@@ -56,6 +57,7 @@ func handleImageSearch(w http.ResponseWriter, settings UserSettings, query strin
CurrentLang: settings.Language,
Theme: settings.Theme,
Safe: settings.SafeSearch,
+ IsThemeDark: settings.IsThemeDark,
}
err = tmpl.Execute(w, data)
diff --git a/main.go b/main.go
index 85c10c8..9f1bef3 100755
--- a/main.go
+++ b/main.go
@@ -91,6 +91,14 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
saveUserSettings(w, settings)
}
+ // This will do for now (to handle Dark Reader addon)
+ switch settings.Theme {
+ case "dark", "black", "night", "latte":
+ settings.IsThemeDark = true
+ default:
+ settings.IsThemeDark = false
+ }
+
// Check if there is a search query
if query == "" {
// If no query is provided, render the search page template
@@ -99,11 +107,13 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
CurrentLang string
Theme string
Safe string
+ IsThemeDark bool
}{
LanguageOptions: languageOptions,
CurrentLang: settings.Language,
Theme: settings.Theme,
Safe: settings.SafeSearch,
+ IsThemeDark: settings.IsThemeDark,
}
tmpl := template.Must(template.ParseFiles("templates/search.html"))
diff --git a/templates/files.html b/templates/files.html
index 8b0edee..e119424 100755
--- a/templates/files.html
+++ b/templates/files.html
@@ -3,6 +3,9 @@
+ {{ if .IsThemeDark }}
+
+ {{ end }}
{{.Query}} - Ocásek
diff --git a/templates/forums.html b/templates/forums.html
index f1e3446..04a3c2b 100755
--- a/templates/forums.html
+++ b/templates/forums.html
@@ -3,6 +3,9 @@
+ {{ if .IsThemeDark }}
+
+ {{ end }}
{{.Query}} - Ocásek
diff --git a/templates/images.html b/templates/images.html
index 91d1360..93b5e0a 100755
--- a/templates/images.html
+++ b/templates/images.html
@@ -3,6 +3,9 @@
+ {{ if .IsThemeDark }}
+
+ {{ end }}
{{.Query}} - Ocásek
diff --git a/templates/map.html b/templates/map.html
index 458f1a3..5ce8c62 100644
--- a/templates/map.html
+++ b/templates/map.html
@@ -3,6 +3,9 @@
+ {{ if .IsThemeDark }}
+
+ {{ end }}
{{ .Query }} - Ocásek
diff --git a/templates/search.html b/templates/search.html
index 8dd0cf9..61fbb0d 100755
--- a/templates/search.html
+++ b/templates/search.html
@@ -3,6 +3,9 @@
+ {{ if .IsThemeDark }}
+
+ {{ end }}
Search with Ocásek
diff --git a/templates/settings.html b/templates/settings.html
index 73843f6..59eb844 100644
--- a/templates/settings.html
+++ b/templates/settings.html
@@ -3,6 +3,9 @@
+ {{ if .IsThemeDark }}
+
+ {{ end }}
Settings - Ocásek
diff --git a/templates/text.html b/templates/text.html
index 905d4dc..809afeb 100755
--- a/templates/text.html
+++ b/templates/text.html
@@ -3,6 +3,9 @@
+ {{ if .IsThemeDark }}
+
+ {{ end }}
{{.Query}} - Ocásek
diff --git a/templates/videos.html b/templates/videos.html
index 1365a10..3be0bc0 100644
--- a/templates/videos.html
+++ b/templates/videos.html
@@ -3,6 +3,9 @@
+ {{ if .IsThemeDark }}
+
+ {{ end }}
{{.Query}} - Ocásek
diff --git a/text.go b/text.go
index 1fed73d..7ea602d 100755
--- a/text.go
+++ b/text.go
@@ -55,6 +55,7 @@ func HandleTextSearch(w http.ResponseWriter, settings UserSettings, query string
CurrentLang string
Theme string
Safe string
+ IsThemeDark bool
}{
Results: combinedResults,
Query: query,
@@ -67,6 +68,7 @@ func HandleTextSearch(w http.ResponseWriter, settings UserSettings, query string
CurrentLang: settings.Language,
Theme: settings.Theme,
Safe: settings.SafeSearch,
+ IsThemeDark: settings.IsThemeDark,
}
err = tmpl.Execute(w, data)
diff --git a/user-settings.go b/user-settings.go
index 83fee6c..92da588 100755
--- a/user-settings.go
+++ b/user-settings.go
@@ -7,9 +7,10 @@ import (
)
type UserSettings struct {
- Theme string
- Language string
- SafeSearch string
+ Theme string
+ Language string
+ SafeSearch string
+ IsThemeDark bool
}
func loadUserSettings(r *http.Request) UserSettings {
@@ -103,11 +104,13 @@ func handleSettings(w http.ResponseWriter, r *http.Request) {
CurrentLang string
Theme string
Safe string
+ IsThemeDark bool
}{
LanguageOptions: languageOptions,
CurrentLang: settings.Language,
Theme: settings.Theme,
Safe: settings.SafeSearch,
+ IsThemeDark: settings.IsThemeDark,
}
printDebug("Rendering settings with data: %+v", data)
diff --git a/video.go b/video.go
index ccda543..15c83a3 100644
--- a/video.go
+++ b/video.go
@@ -176,6 +176,7 @@ func handleVideoSearch(w http.ResponseWriter, settings UserSettings, query strin
"CurrentLang": settings.Language,
"Theme": settings.Theme,
"Safe": settings.SafeSearch,
+ "IsThemeDark": settings.IsThemeDark,
})
if err != nil {
printErr("Error executing template: %v", err)