added functionality HardCacheDuration to config.ini
This commit is contained in:
parent
49f613ddeb
commit
8fe6783ecb
7 changed files with 52 additions and 73 deletions
28
images.go
28
images.go
|
@ -29,18 +29,19 @@ func handleImageSearch(w http.ResponseWriter, settings UserSettings, query strin
|
|||
|
||||
// Prepare the data to pass to the template
|
||||
data := map[string]interface{}{
|
||||
"Results": combinedResults,
|
||||
"Query": query,
|
||||
"Fetched": fmt.Sprintf("%.2f %s", elapsedTime.Seconds(), Translate("seconds")), // Time for fetching
|
||||
"Page": page,
|
||||
"HasPrevPage": page > 1,
|
||||
"HasNextPage": len(combinedResults) >= 50,
|
||||
"NoResults": len(combinedResults) == 0,
|
||||
"LanguageOptions": languageOptions,
|
||||
"CurrentLang": settings.SearchLanguage,
|
||||
"Theme": settings.Theme,
|
||||
"Safe": settings.SafeSearch,
|
||||
"IsThemeDark": settings.IsThemeDark,
|
||||
"Results": combinedResults,
|
||||
"Query": query,
|
||||
"Fetched": fmt.Sprintf("%.2f %s", elapsedTime.Seconds(), Translate("seconds")), // Time for fetching
|
||||
"Page": page,
|
||||
"HasPrevPage": page > 1,
|
||||
"HasNextPage": len(combinedResults) >= 50,
|
||||
"NoResults": len(combinedResults) == 0,
|
||||
"LanguageOptions": languageOptions,
|
||||
"CurrentLang": settings.SearchLanguage,
|
||||
"Theme": settings.Theme,
|
||||
"Safe": settings.SafeSearch,
|
||||
"IsThemeDark": settings.IsThemeDark,
|
||||
"HardCacheEnabled": config.HardCacheEnabled,
|
||||
}
|
||||
|
||||
// Render the template without measuring the time
|
||||
|
@ -98,7 +99,8 @@ func fetchImageResults(query, safe, lang string, page int) []ImageSearchResult {
|
|||
|
||||
for _, result := range searchResults {
|
||||
imageResult := result.(ImageSearchResult)
|
||||
if config.HardCacheDuration > 0 {
|
||||
if config.HardCacheEnabled == true {
|
||||
|
||||
// Generate hash from the original full-size image URL
|
||||
hasher := md5.New()
|
||||
hasher.Write([]byte(imageResult.Full))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue