diff --git a/files.go b/files.go
index b397a99..cbafb66 100755
--- a/files.go
+++ b/files.go
@@ -59,27 +59,31 @@ func handleFileSearch(w http.ResponseWriter, settings UserSettings, query string
}
data := struct {
- Results []TorrentResult
- Query string
- Fetched string
- Category string
- Sort string
- HasPrevPage bool
- HasNextPage bool
- Page int
- Settings Settings
- Theme string
+ Results []TorrentResult
+ Query string
+ Fetched string
+ Category string
+ Sort string
+ Page int
+ HasPrevPage bool
+ HasNextPage bool
+ LanguageOptions []LanguageOption
+ CurrentLang string
+ Theme string
+ Safe string
}{
- Results: combinedResults,
- Query: query,
- Fetched: fmt.Sprintf("%.2f", elapsedTime.Seconds()),
- Category: "all",
- Sort: "seed",
- HasPrevPage: page > 1,
- HasNextPage: len(combinedResults) > 0,
- Page: page,
- Settings: Settings{UxLang: settings.Language, Safe: settings.SafeSearch}, // Now this is painful, are there two Settings variables??
- Theme: settings.Theme,
+ Results: combinedResults,
+ Query: query,
+ Fetched: fmt.Sprintf("%.2f seconds", elapsedTime.Seconds()),
+ Category: "all",
+ Sort: "seed",
+ Page: page,
+ HasPrevPage: page > 1,
+ HasNextPage: len(combinedResults) > 0,
+ LanguageOptions: languageOptions,
+ CurrentLang: settings.Language,
+ Theme: settings.Theme,
+ Safe: settings.SafeSearch,
}
// // Debugging: Print results before rendering template
diff --git a/forums.go b/forums.go
index 69f911e..d0be4f6 100755
--- a/forums.go
+++ b/forums.go
@@ -108,21 +108,23 @@ func handleForumsSearch(w http.ResponseWriter, settings UserSettings, query stri
data := struct {
Query string
Results []ForumSearchResult
- LanguageOptions []LanguageOption
- CurrentLang string
Page int
HasPrevPage bool
HasNextPage bool
+ LanguageOptions []LanguageOption
+ CurrentLang string
Theme string
+ Safe string
}{
Query: query,
Results: results,
- LanguageOptions: languageOptions,
- CurrentLang: settings.Language,
Page: page,
HasPrevPage: page > 1,
HasNextPage: len(results) == 25,
+ LanguageOptions: languageOptions,
+ CurrentLang: settings.Language,
Theme: settings.Theme,
+ Safe: settings.SafeSearch,
}
funcMap := template.FuncMap{
diff --git a/images.go b/images.go
index bf1a840..bdac1cd 100755
--- a/images.go
+++ b/images.go
@@ -37,23 +37,25 @@ func handleImageSearch(w http.ResponseWriter, settings UserSettings, query strin
Query string
Page int
Fetched string
- LanguageOptions []LanguageOption
- CurrentLang string
HasPrevPage bool
HasNextPage bool
NoResults bool
+ LanguageOptions []LanguageOption
+ CurrentLang string
Theme string
+ Safe string
}{
Results: combinedResults,
Query: query,
Page: page,
Fetched: fmt.Sprintf("%.2f seconds", elapsedTime.Seconds()),
- LanguageOptions: languageOptions,
- CurrentLang: settings.Language,
HasPrevPage: page > 1,
HasNextPage: len(combinedResults) >= 50,
NoResults: len(combinedResults) == 0,
+ LanguageOptions: languageOptions,
+ CurrentLang: settings.Language,
Theme: settings.Theme,
+ Safe: settings.SafeSearch,
}
err = tmpl.Execute(w, data)
diff --git a/main.go b/main.go
index 6c9cb2c..392aab8 100755
--- a/main.go
+++ b/main.go
@@ -92,9 +92,21 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
}
// Render the search page template if no query
+
+ data := struct {
+ LanguageOptions []LanguageOption
+ CurrentLang string
+ Theme string
+ Safe string
+ }{
+ LanguageOptions: languageOptions,
+ CurrentLang: settings.Language,
+ Theme: settings.Theme,
+ Safe: settings.SafeSearch,
+ }
if query == "" {
tmpl := template.Must(template.ParseFiles("templates/search.html"))
- tmpl.Execute(w, settings)
+ tmpl.Execute(w, data)
return
}
diff --git a/map.go b/map.go
index 8981d65..df3c7e8 100755
--- a/map.go
+++ b/map.go
@@ -59,6 +59,7 @@ func handleMapSearch(w http.ResponseWriter, settings UserSettings, query string)
"Longitude": longitude,
"Found": found,
"Theme": settings.Theme,
+ "Safe": settings.SafeSearch,
}
tmpl, err := template.ParseFiles("templates/map.html")
diff --git a/templates/files.html b/templates/files.html
old mode 100644
new mode 100755
index b1fc4cb..af39437
--- a/templates/files.html
+++ b/templates/files.html
@@ -1,113 +1,113 @@
-
-
-
-
-
- {{.Query}} - Ocásek
-
-
-
-
-
-
-
- Fetched in {{ .Fetched }} seconds
-
- {{ if .Results }}
-
-
- {{ range .Results }}
-
- {{ if .Error }}
-
{{ .Error }}
- {{ else }}
-
{{ .URL }}
-
{{ .Title }}
-
{{ if .Views }}{{ .Views }} views • {{ end }}{{ .Size }}
-
Seeders: {{ .Seeders }} | Leechers: {{ .Leechers }}
- {{ end }}
-
- {{ end }}
-
-
-
-
- {{ else }}
-
- Your search '{{ .Query }}' came back with no results.
- Try rephrasing your search term and/or recorrect any spelling mistakes.
-
- {{ end }}
-
-
-
+
+
+
+
+
+ {{.Query}} - Ocásek
+
+
+
+
+
+
+
+ Fetched in {{ .Fetched }} seconds
+
+ {{ if .Results }}
+
+
+ {{ range .Results }}
+
+ {{ if .Error }}
+
{{ .Error }}
+ {{ else }}
+
{{ .URL }}
+
{{ .Title }}
+
{{ if .Views }}{{ .Views }} views • {{ end }}{{ .Size }}
+
Seeders: {{ .Seeders }} | Leechers: {{ .Leechers }}
+ {{ end }}
+
+ {{ end }}
+
+
+
+
+ {{ else }}
+
+ Your search '{{ .Query }}' came back with no results.
+ Try rephrasing your search term and/or recorrect any spelling mistakes.
+
+ {{ end }}
+
+
+
diff --git a/templates/forums.html b/templates/forums.html
old mode 100644
new mode 100755
index 6d04557..0246110
--- a/templates/forums.html
+++ b/templates/forums.html
@@ -1,92 +1,92 @@
-
-
-
-
-
- {{.Query}} - Ocásek
-
-
-
-
-
-
-
-
- {{if .Results}}
- {{range .Results}}
-
-
- {{end}}
- {{else}}
-
No results found for '{{ .Query }}'. Try different keywords.
- {{end}}
-
-
-
-
-
-
-
+
+
+
+
+
+ {{.Query}} - Ocásek
+
+
+
+
+
+
+
+
+ {{if .Results}}
+ {{range .Results}}
+
+
+ {{end}}
+ {{else}}
+
No results found for '{{ .Query }}'. Try different keywords.
+ {{end}}
+
+
+
+
+
+
+
diff --git a/templates/images.html b/templates/images.html
old mode 100644
new mode 100755
index 7a7e07d..ee3794a
--- a/templates/images.html
+++ b/templates/images.html
@@ -1,169 +1,169 @@
-
-
-
-
-
- {{.Query}} - Ocásek
-
-
-
-
-
-
-
-
-
- {{ if .Results }}
-
-
- {{ range .Results }}
-
- {{ end }}
-
-
- {{ else if .NoResults }}
-
No results found for '{{ .Query }}'. Try different keywords.
- {{ else }}
-
Looks like this is the end of results.
- {{ end }}
-
-
- Searching for new results...
-
-
-
-
-
+
+
+
+
+
+ {{.Query}} - Ocásek
+
+
+
+
+
+
+
+
+
+ {{ if .Results }}
+
+
+ {{ range .Results }}
+
+ {{ end }}
+
+
+ {{ else if .NoResults }}
+
No results found for '{{ .Query }}'. Try different keywords.
+ {{ else }}
+
Looks like this is the end of results.
+ {{ end }}
+
+
+ Searching for new results...
+
+
+
+
+
diff --git a/templates/search.html b/templates/search.html
old mode 100644
new mode 100755
index f82599a..aa425a2
--- a/templates/search.html
+++ b/templates/search.html
@@ -1,73 +1,95 @@
-
-
-
-
-
- Search with Ocásek
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ Search with Ocásek
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/text.html b/templates/text.html
old mode 100644
new mode 100755
index 6dccaa7..12cfe53
--- a/templates/text.html
+++ b/templates/text.html
@@ -1,153 +1,153 @@
-
-
-
-
-
- {{.Query}} - Ocásek
-
-
-
-
-
-
-
-
- {{if .Results}}
- {{range .Results}}
-
-
- {{end}}
- {{else if .NoResults}}
-
No results found for '{{ .Query }}'. Try different keywords.
- {{else}}
-
Looks like this is the end of results.
- {{end}}
-
-
- Searching for new results...
-
-
-
-
-
-
-
-
+
+
+
+
+
+ {{.Query}} - Ocásek
+
+
+
+
+
+
+
+
+ {{if .Results}}
+ {{range .Results}}
+
+
+ {{end}}
+ {{else if .NoResults}}
+
No results found for '{{ .Query }}'. Try different keywords.
+ {{else}}
+
Looks like this is the end of results.
+ {{end}}
+
+
+ Searching for new results...
+
+
+
+
+
+
+
+
diff --git a/text.go b/text.go
index f7be586..d088a07 100755
--- a/text.go
+++ b/text.go
@@ -48,23 +48,25 @@ func HandleTextSearch(w http.ResponseWriter, settings UserSettings, query string
Query string
Page int
Fetched string
- LanguageOptions []LanguageOption
- CurrentLang string
HasPrevPage bool
HasNextPage bool
NoResults bool
+ LanguageOptions []LanguageOption
+ CurrentLang string
Theme string
+ Safe string
}{
Results: combinedResults,
Query: query,
Page: page,
Fetched: fmt.Sprintf("%.2f seconds", elapsedTime.Seconds()),
- LanguageOptions: languageOptions,
- CurrentLang: settings.Language,
HasPrevPage: page > 1,
HasNextPage: len(combinedResults) >= 50,
NoResults: len(combinedResults) == 0,
+ LanguageOptions: languageOptions,
+ CurrentLang: settings.Language,
Theme: settings.Theme,
+ Safe: settings.SafeSearch,
}
err = tmpl.Execute(w, data)
diff --git a/user-settings.go b/user-settings.go
old mode 100644
new mode 100755
index 41960a7..80b8b04
--- a/user-settings.go
+++ b/user-settings.go
@@ -1,54 +1,60 @@
-package main
-
-import "net/http"
-
-type UserSettings struct {
- Theme string
- Language string
- SafeSearch string
-}
-
-func loadUserSettings(r *http.Request) UserSettings {
- var settings UserSettings
-
- // Load theme
- if cookie, err := r.Cookie("theme"); err == nil {
- settings.Theme = cookie.Value
- } else {
- settings.Theme = "dark" // Default theme
- }
-
- // Load language
- if cookie, err := r.Cookie("language"); err == nil {
- settings.Language = cookie.Value
- } else {
- settings.Language = "en" // Default language
- }
-
- // Load safe search
- if cookie, err := r.Cookie("safe"); err == nil {
- settings.SafeSearch = cookie.Value
- } else {
- settings.SafeSearch = "" // Default safe search off
- }
-
- return settings
-}
-
-func saveUserSettings(w http.ResponseWriter, settings UserSettings) {
- http.SetCookie(w, &http.Cookie{
- Name: "theme",
- Value: settings.Theme,
- Path: "/",
- })
- http.SetCookie(w, &http.Cookie{
- Name: "language",
- Value: settings.Language,
- Path: "/",
- })
- http.SetCookie(w, &http.Cookie{
- Name: "safe",
- Value: settings.SafeSearch,
- Path: "/",
- })
-}
+package main
+
+import "net/http"
+
+type UserSettings struct {
+ Theme string
+ Language string
+ SafeSearch string
+}
+
+func loadUserSettings(r *http.Request) UserSettings {
+ var settings UserSettings
+
+ // Load theme
+ if cookie, err := r.Cookie("theme"); err == nil {
+ settings.Theme = cookie.Value
+ } else {
+ settings.Theme = "dark" // Default theme
+ }
+
+ // Load language
+ if cookie, err := r.Cookie("language"); err == nil {
+ settings.Language = cookie.Value
+ } else {
+ settings.Language = "en" // Default language
+ }
+
+ // Load safe search
+ if cookie, err := r.Cookie("safe"); err == nil {
+ settings.SafeSearch = cookie.Value
+ } else {
+ settings.SafeSearch = "" // Default safe search off
+ }
+
+ return settings
+}
+
+func saveUserSettings(w http.ResponseWriter, settings UserSettings) {
+ http.SetCookie(w, &http.Cookie{
+ Name: "theme",
+ Value: settings.Theme,
+ Path: "/",
+ Secure: true, // Ensure cookie is sent over HTTPS only
+ SameSite: http.SameSiteNoneMode, // Set SameSite to None
+ })
+ http.SetCookie(w, &http.Cookie{
+ Name: "language",
+ Value: settings.Language,
+ Path: "/",
+ Secure: true, // Ensure cookie is sent over HTTPS only
+ SameSite: http.SameSiteNoneMode, // Set SameSite to None
+ })
+ http.SetCookie(w, &http.Cookie{
+ Name: "safe",
+ Value: settings.SafeSearch,
+ Path: "/",
+ Secure: true, // Ensure cookie is sent over HTTPS only
+ SameSite: http.SameSiteNoneMode, // Set SameSite to None
+ })
+}
diff --git a/video.go b/video.go
index 45af48e..1633853 100755
--- a/video.go
+++ b/video.go
@@ -166,13 +166,16 @@ func handleVideoSearch(w http.ResponseWriter, settings UserSettings, query strin
}
err = tmpl.Execute(w, map[string]interface{}{
- "Results": results,
- "Query": query,
- "Fetched": fmt.Sprintf("%.2f seconds", elapsed.Seconds()),
- "Page": page,
- "HasPrevPage": page > 1,
- "HasNextPage": len(results) > 0, // no
- "Theme": settings.Theme,
+ "Results": results,
+ "Query": query,
+ "Fetched": fmt.Sprintf("%.2f seconds", elapsed.Seconds()),
+ "Page": page,
+ "HasPrevPage": page > 1,
+ "HasNextPage": len(results) > 0,
+ "LanguageOptions": languageOptions,
+ "CurrentLang": settings.Language,
+ "Theme": settings.Theme,
+ "Safe": settings.SafeSearch,
})
if err != nil {
printErr("Error executing template: %v", err)