added "next" button for videos
This commit is contained in:
parent
b3eb7e39ea
commit
fe96287442
2 changed files with 35 additions and 18 deletions
|
@ -42,7 +42,6 @@
|
||||||
<button name="t" value="file" class="clickable">Torrents</button>
|
<button name="t" value="file" class="clickable">Torrents</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
<!-- Results go here -->
|
<!-- Results go here -->
|
||||||
<p class="fetched fetched_dif fetched_vid"><!-- { fetched } --></p>
|
<p class="fetched fetched_dif fetched_vid"><!-- { fetched } --></p>
|
||||||
|
@ -64,9 +63,20 @@
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<div class="no-results">No results found for '{{ .Query }}'. Try different keywords.</div>>
|
<div class="no-results">No results found for '{{ .Query }}'. Try different keywords.</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
<div class="prev-next prev-img" id="prev-next">
|
||||||
|
<form action="/search" method="get">
|
||||||
|
<input type="hidden" name="q" value="{{ .Query }}">
|
||||||
|
<input type="hidden" name="t" value="video">
|
||||||
|
{{ if .HasPrevPage }}
|
||||||
|
<button type="submit" name="p" value="{{ sub .Page 1 }}">Previous</button>
|
||||||
|
{{ end }}
|
||||||
|
{{ if .HasNextPage }}
|
||||||
|
<button type="submit" name="p" value="{{ add .Page 1 }}">Next</button>
|
||||||
|
{{ end }}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
// Check if JavaScript is enabled and modify the DOM accordingly
|
// Check if JavaScript is enabled and modify the DOM accordingly
|
||||||
document.getElementById('content').classList.remove('js-enabled');
|
document.getElementById('content').classList.remove('js-enabled');
|
||||||
|
|
11
video.go
11
video.go
|
@ -180,16 +180,23 @@ func handleVideoSearch(w http.ResponseWriter, query, safe, lang string, page int
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsed := time.Since(start)
|
elapsed := time.Since(start)
|
||||||
tmpl, err := template.ParseFiles("templates/videos.html")
|
tmpl, err := template.New("videos.html").Funcs(funcs).ParseFiles("templates/videos.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error parsing template: %v", err)
|
log.Printf("Error parsing template: %v", err)
|
||||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl.Execute(w, map[string]interface{}{
|
err = tmpl.Execute(w, map[string]interface{}{
|
||||||
"Results": results,
|
"Results": results,
|
||||||
"Query": query,
|
"Query": query,
|
||||||
"Fetched": fmt.Sprintf("%.2f seconds", elapsed.Seconds()),
|
"Fetched": fmt.Sprintf("%.2f seconds", elapsed.Seconds()),
|
||||||
|
"Page": page,
|
||||||
|
"HasPrevPage": page > 1,
|
||||||
|
"HasNextPage": len(results) > 0, // assuming you have a way to determine if there are more pages
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error executing template: %v", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue