hide "map" on no-js website type, fix2

This commit is contained in:
dez 2024-04-17 15:02:52 +02:00
parent ab04ad1930
commit 1e0fabd7c0
4 changed files with 14 additions and 11 deletions

View file

@ -66,6 +66,8 @@ func fetchImageResults(query string, safe, lang string, page int) ([]ImageSearch
lang = "en_CA"
}
// Format &lang=lang_de is incorret, implement fix !
apiURL := fmt.Sprintf("https://api.qwant.com/v3/search/images?t=images&q=%s&count=%d&locale=%s&offset=%d&device=desktop&tgp=2&safesearch=%s",
url.QueryEscape(query),
resultsPerPage,
@ -100,11 +102,11 @@ func fetchImageResults(query string, safe, lang string, page int) ([]ImageSearch
var results []ImageSearchResult
for _, item := range apiResp.Data.Result.Items {
results = append(results, ImageSearchResult{
Thumbnail: item.Thumbnail, // Thumbnail URL
Title: item.Title, // Image title
Media: item.Media, // Direct link to the image - Ensure this field is used appropriately in your template
Source: item.Media, // Using item.Media here ensures the direct image link is used
ThumbProxy: "/img_proxy?url=" + url.QueryEscape(item.Media), // Proxy URL for the thumbnail, if needed
Thumbnail: item.Thumbnail, // Thumbnail URL
Title: item.Title, // Image title
Media: item.Media, // Direct link to the image
Source: item.Url,
ThumbProxy: "/img_proxy?url=" + url.QueryEscape(item.Media),
Width: item.Width,
Height: item.Height,
})

View file

@ -110,7 +110,7 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
case "video":
videoSearchEndpointHandler(w, r)
case "map":
handleMapSearch(w, query, safe) // implement map results
handleMapSearch(w, query, safe)
default:
http.ServeFile(w, r, "templates/search.html")
}

View file

@ -1138,6 +1138,10 @@ p {
text-decoration: none;
}
.js-enabled {
display: none;
}
.logomobile {
position: absolute;
margin-top: 0px;

View file

@ -5,9 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.Query}} - Ocásek</title>
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
<style>
.js-enabled { display: none; }
</style>
</head>
<body>
<form action="/search" id="prev-next-form" class="results-search-container" method="GET" autocomplete="off">
@ -58,8 +55,8 @@
<option value="{{.Code}}" {{if eq .Code $.CurrentLang}}selected{{end}}>{{.Name}}</option>
{{end}}
</select>
<button class="results-save" type="submit">Apply settings</button>
</form>
<button class="results-save" name="t" value="image">Apply settings</button>
</form>
<div class="search-results">
<!-- Results go here -->
{{ if .Results }}