From 707cc9f89559e9df630fc7364e7abe2119e92411 Mon Sep 17 00:00:00 2001 From: dez Date: Mon, 8 Apr 2024 13:15:23 +0200 Subject: [PATCH] reformatting html --- go.mod | 2 +- images.go | 28 ++++++++++++--------- main.go | 2 +- static/search.html | 1 + templates/images.html | 56 +++++++++++++++++++++++++++++++++--------- templates/results.html | 40 +++++++++++++++++++++++------- text.go | 2 +- 7 files changed, 96 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 65c1ecc..3e53ea7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module searchengine -go 1.23 +go 1.18 require ( github.com/PuerkitoBio/goquery v1.9.1 // indirect diff --git a/images.go b/images.go index 71b838b..fe8a4e9 100644 --- a/images.go +++ b/images.go @@ -131,19 +131,23 @@ func handleImageSearch(w http.ResponseWriter, query, safe, lang string, page int } data := struct { - Results []ImageSearchResult - Query string - Page int - Fetched string - HasPrevPage bool - HasNextPage bool + Results []ImageSearchResult + Query string + Page int + Fetched string + LanguageOptions []LanguageOption + CurrentLang string + HasPrevPage bool + HasNextPage bool }{ - Results: results, - Query: query, - Page: page, - Fetched: fmt.Sprintf("%.2f seconds", time.Since(time.Now()).Seconds()), - HasPrevPage: page > 1, - HasNextPage: len(results) >= 50, + Results: results, + Query: query, + Page: page, + Fetched: fmt.Sprintf("%.2f seconds", time.Since(time.Now()).Seconds()), + LanguageOptions: languageOptions, + CurrentLang: lang, + HasPrevPage: page > 1, + HasNextPage: len(results) >= 50, } err = tmpl.Execute(w, data) diff --git a/main.go b/main.go index fd29099..af09d82 100644 --- a/main.go +++ b/main.go @@ -108,7 +108,7 @@ func handleSearch(w http.ResponseWriter, r *http.Request) { switch searchType { case "text": - handleTextSearch(w, r, query, safe, lang) // Handles fetching and rendering text search results + handleTextSearch(w, query, safe, lang) // Handles fetching and rendering text search results case "image": handleImageSearch(w, query, safe, lang, page) // Adjusted: Pass *http.Request to match the function signature default: diff --git a/static/search.html b/static/search.html index acd3057..fc381d4 100644 --- a/static/search.html +++ b/static/search.html @@ -18,6 +18,7 @@ close
+
diff --git a/templates/images.html b/templates/images.html index 39b4f97..f3c072c 100644 --- a/templates/images.html +++ b/templates/images.html @@ -3,21 +3,55 @@ - {{.Query}} - Spitfire Search - + {{.Query}} - Ocásek + -
-

Ocásek

-
-
+
+ +
+ + + + +
-

Image Search Results

{{ if .Results }}
diff --git a/templates/results.html b/templates/results.html index d9cfe04..a19127c 100644 --- a/templates/results.html +++ b/templates/results.html @@ -3,19 +3,41 @@ - {{.Query}} - Spitfire Search + {{.Query}} - Ocásek -
-

Ocásek

-
- -
+
+

Ocásek

+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+