added lang support to all html templates and cleaned up template rendering
This commit is contained in:
parent
5dd3114e2d
commit
d9d0301548
18 changed files with 645 additions and 410 deletions
18
main.go
18
main.go
|
@ -126,11 +126,25 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
|
|||
IsThemeDark: settings.IsThemeDark,
|
||||
}
|
||||
|
||||
tmpl := template.Must(template.ParseFiles("templates/search.html"))
|
||||
tmpl.Execute(w, data)
|
||||
// Add Translate to the template functions
|
||||
tmpl, err := template.New("search.html").Funcs(template.FuncMap{
|
||||
"translate": Translate,
|
||||
}).ParseFiles("templates/search.html")
|
||||
if err != nil {
|
||||
printErr("Error parsing template: %v", err)
|
||||
http.Error(w, Translate("internal_server_error"), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
err = tmpl.Execute(w, data)
|
||||
if err != nil {
|
||||
printErr("Error executing template: %v", err)
|
||||
http.Error(w, Translate("internal_server_error"), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Handle different search types
|
||||
switch searchType {
|
||||
case "image":
|
||||
handleImageSearch(w, settings, query, page)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue