added support for Dark Reader
This commit is contained in:
parent
485d969506
commit
60b4040895
15 changed files with 49 additions and 3 deletions
2
files.go
2
files.go
|
@ -71,6 +71,7 @@ func handleFileSearch(w http.ResponseWriter, settings UserSettings, query string
|
||||||
CurrentLang string
|
CurrentLang string
|
||||||
Theme string
|
Theme string
|
||||||
Safe string
|
Safe string
|
||||||
|
IsThemeDark bool
|
||||||
}{
|
}{
|
||||||
Results: combinedResults,
|
Results: combinedResults,
|
||||||
Query: query,
|
Query: query,
|
||||||
|
@ -84,6 +85,7 @@ func handleFileSearch(w http.ResponseWriter, settings UserSettings, query string
|
||||||
CurrentLang: settings.Language,
|
CurrentLang: settings.Language,
|
||||||
Theme: settings.Theme,
|
Theme: settings.Theme,
|
||||||
Safe: settings.SafeSearch,
|
Safe: settings.SafeSearch,
|
||||||
|
IsThemeDark: settings.IsThemeDark,
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Debugging: Print results before rendering template
|
// // Debugging: Print results before rendering template
|
||||||
|
|
|
@ -115,6 +115,7 @@ func handleForumsSearch(w http.ResponseWriter, settings UserSettings, query stri
|
||||||
CurrentLang string
|
CurrentLang string
|
||||||
Theme string
|
Theme string
|
||||||
Safe string
|
Safe string
|
||||||
|
IsThemeDark bool
|
||||||
}{
|
}{
|
||||||
Query: query,
|
Query: query,
|
||||||
Results: results,
|
Results: results,
|
||||||
|
@ -125,6 +126,7 @@ func handleForumsSearch(w http.ResponseWriter, settings UserSettings, query stri
|
||||||
CurrentLang: settings.Language,
|
CurrentLang: settings.Language,
|
||||||
Theme: settings.Theme,
|
Theme: settings.Theme,
|
||||||
Safe: settings.SafeSearch,
|
Safe: settings.SafeSearch,
|
||||||
|
IsThemeDark: settings.IsThemeDark,
|
||||||
}
|
}
|
||||||
|
|
||||||
funcMap := template.FuncMap{
|
funcMap := template.FuncMap{
|
||||||
|
|
|
@ -44,6 +44,7 @@ func handleImageSearch(w http.ResponseWriter, settings UserSettings, query strin
|
||||||
CurrentLang string
|
CurrentLang string
|
||||||
Theme string
|
Theme string
|
||||||
Safe string
|
Safe string
|
||||||
|
IsThemeDark bool
|
||||||
}{
|
}{
|
||||||
Results: combinedResults,
|
Results: combinedResults,
|
||||||
Query: query,
|
Query: query,
|
||||||
|
@ -56,6 +57,7 @@ func handleImageSearch(w http.ResponseWriter, settings UserSettings, query strin
|
||||||
CurrentLang: settings.Language,
|
CurrentLang: settings.Language,
|
||||||
Theme: settings.Theme,
|
Theme: settings.Theme,
|
||||||
Safe: settings.SafeSearch,
|
Safe: settings.SafeSearch,
|
||||||
|
IsThemeDark: settings.IsThemeDark,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tmpl.Execute(w, data)
|
err = tmpl.Execute(w, data)
|
||||||
|
|
10
main.go
10
main.go
|
@ -91,6 +91,14 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
saveUserSettings(w, settings)
|
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
|
// Check if there is a search query
|
||||||
if query == "" {
|
if query == "" {
|
||||||
// If no query is provided, render the search page template
|
// If no query is provided, render the search page template
|
||||||
|
@ -99,11 +107,13 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
CurrentLang string
|
CurrentLang string
|
||||||
Theme string
|
Theme string
|
||||||
Safe string
|
Safe string
|
||||||
|
IsThemeDark bool
|
||||||
}{
|
}{
|
||||||
LanguageOptions: languageOptions,
|
LanguageOptions: languageOptions,
|
||||||
CurrentLang: settings.Language,
|
CurrentLang: settings.Language,
|
||||||
Theme: settings.Theme,
|
Theme: settings.Theme,
|
||||||
Safe: settings.SafeSearch,
|
Safe: settings.SafeSearch,
|
||||||
|
IsThemeDark: settings.IsThemeDark,
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles("templates/search.html"))
|
tmpl := template.Must(template.ParseFiles("templates/search.html"))
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
{{ if .IsThemeDark }}
|
||||||
|
<meta name="darkreader-lock">
|
||||||
|
{{ end }}
|
||||||
<title>{{.Query}} - Ocásek</title>
|
<title>{{.Query}} - Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
{{ if .IsThemeDark }}
|
||||||
|
<meta name="darkreader-lock">
|
||||||
|
{{ end }}
|
||||||
<title>{{.Query}} - Ocásek</title>
|
<title>{{.Query}} - Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
{{ if .IsThemeDark }}
|
||||||
|
<meta name="darkreader-lock">
|
||||||
|
{{ end }}
|
||||||
<title>{{.Query}} - Ocásek</title>
|
<title>{{.Query}} - Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
{{ if .IsThemeDark }}
|
||||||
|
<meta name="darkreader-lock">
|
||||||
|
{{ end }}
|
||||||
<title>{{ .Query }} - Ocásek</title>
|
<title>{{ .Query }} - Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
{{ if .IsThemeDark }}
|
||||||
|
<meta name="darkreader-lock">
|
||||||
|
{{ end }}
|
||||||
<title>Search with Ocásek</title>
|
<title>Search with Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
{{ if .IsThemeDark }}
|
||||||
|
<meta name="darkreader-lock">
|
||||||
|
{{ end }}
|
||||||
<title>Settings - Ocásek</title>
|
<title>Settings - Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
{{ if .IsThemeDark }}
|
||||||
|
<meta name="darkreader-lock">
|
||||||
|
{{ end }}
|
||||||
<title>{{.Query}} - Ocásek</title>
|
<title>{{.Query}} - Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
{{ if .IsThemeDark }}
|
||||||
|
<meta name="darkreader-lock">
|
||||||
|
{{ end }}
|
||||||
<title>{{.Query}} - Ocásek</title>
|
<title>{{.Query}} - Ocásek</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||||
|
|
2
text.go
2
text.go
|
@ -55,6 +55,7 @@ func HandleTextSearch(w http.ResponseWriter, settings UserSettings, query string
|
||||||
CurrentLang string
|
CurrentLang string
|
||||||
Theme string
|
Theme string
|
||||||
Safe string
|
Safe string
|
||||||
|
IsThemeDark bool
|
||||||
}{
|
}{
|
||||||
Results: combinedResults,
|
Results: combinedResults,
|
||||||
Query: query,
|
Query: query,
|
||||||
|
@ -67,6 +68,7 @@ func HandleTextSearch(w http.ResponseWriter, settings UserSettings, query string
|
||||||
CurrentLang: settings.Language,
|
CurrentLang: settings.Language,
|
||||||
Theme: settings.Theme,
|
Theme: settings.Theme,
|
||||||
Safe: settings.SafeSearch,
|
Safe: settings.SafeSearch,
|
||||||
|
IsThemeDark: settings.IsThemeDark,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tmpl.Execute(w, data)
|
err = tmpl.Execute(w, data)
|
||||||
|
|
|
@ -10,6 +10,7 @@ type UserSettings struct {
|
||||||
Theme string
|
Theme string
|
||||||
Language string
|
Language string
|
||||||
SafeSearch string
|
SafeSearch string
|
||||||
|
IsThemeDark bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadUserSettings(r *http.Request) UserSettings {
|
func loadUserSettings(r *http.Request) UserSettings {
|
||||||
|
@ -103,11 +104,13 @@ func handleSettings(w http.ResponseWriter, r *http.Request) {
|
||||||
CurrentLang string
|
CurrentLang string
|
||||||
Theme string
|
Theme string
|
||||||
Safe string
|
Safe string
|
||||||
|
IsThemeDark bool
|
||||||
}{
|
}{
|
||||||
LanguageOptions: languageOptions,
|
LanguageOptions: languageOptions,
|
||||||
CurrentLang: settings.Language,
|
CurrentLang: settings.Language,
|
||||||
Theme: settings.Theme,
|
Theme: settings.Theme,
|
||||||
Safe: settings.SafeSearch,
|
Safe: settings.SafeSearch,
|
||||||
|
IsThemeDark: settings.IsThemeDark,
|
||||||
}
|
}
|
||||||
|
|
||||||
printDebug("Rendering settings with data: %+v", data)
|
printDebug("Rendering settings with data: %+v", data)
|
||||||
|
|
1
video.go
1
video.go
|
@ -176,6 +176,7 @@ func handleVideoSearch(w http.ResponseWriter, settings UserSettings, query strin
|
||||||
"CurrentLang": settings.Language,
|
"CurrentLang": settings.Language,
|
||||||
"Theme": settings.Theme,
|
"Theme": settings.Theme,
|
||||||
"Safe": settings.SafeSearch,
|
"Safe": settings.SafeSearch,
|
||||||
|
"IsThemeDark": settings.IsThemeDark,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
printErr("Error executing template: %v", err)
|
printErr("Error executing template: %v", err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue