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
|
||||
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
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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)
|
||||
|
|
10
main.go
10
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"))
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ if .IsThemeDark }}
|
||||
<meta name="darkreader-lock">
|
||||
{{ end }}
|
||||
<title>{{.Query}} - Ocásek</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ if .IsThemeDark }}
|
||||
<meta name="darkreader-lock">
|
||||
{{ end }}
|
||||
<title>{{.Query}} - Ocásek</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ if .IsThemeDark }}
|
||||
<meta name="darkreader-lock">
|
||||
{{ end }}
|
||||
<title>{{.Query}} - Ocásek</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ if .IsThemeDark }}
|
||||
<meta name="darkreader-lock">
|
||||
{{ end }}
|
||||
<title>{{ .Query }} - Ocásek</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ if .IsThemeDark }}
|
||||
<meta name="darkreader-lock">
|
||||
{{ end }}
|
||||
<title>Search with Ocásek</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ if .IsThemeDark }}
|
||||
<meta name="darkreader-lock">
|
||||
{{ end }}
|
||||
<title>Settings - Ocásek</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ if .IsThemeDark }}
|
||||
<meta name="darkreader-lock">
|
||||
{{ end }}
|
||||
<title>{{.Query}} - Ocásek</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ if .IsThemeDark }}
|
||||
<meta name="darkreader-lock">
|
||||
{{ end }}
|
||||
<title>{{.Query}} - Ocásek</title>
|
||||
<link rel="stylesheet" href="/static/css/style.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
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
|
|
1
video.go
1
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue