added "next" button for videos
This commit is contained in:
parent
b3eb7e39ea
commit
fe96287442
2 changed files with 35 additions and 18 deletions
|
@ -10,10 +10,10 @@
|
|||
<form action="/search" id="prev-next-form" class="results-search-container" method="GET" autocomplete="off">
|
||||
<h1 class="logomobile"><a class="no-decoration" href="./">Ocásek</a></h1>
|
||||
<div class="wrapper-results">
|
||||
<input type="text" name="q" value="{{ .Query }}" id="search-input" placeholder="Type to search..." />
|
||||
<button id="search-wrapper-ico" class="material-icons-round" name="t" value="video">search</button>
|
||||
<input type="submit" class="hide" name="t" value="video" />
|
||||
</div>
|
||||
<input type="text" name="q" value="{{ .Query }}" id="search-input" placeholder="Type to search..." />
|
||||
<button id="search-wrapper-ico" class="material-icons-round" name="t" value="video">search</button>
|
||||
<input type="submit" class="hide" name="t" value="video" />
|
||||
</div>
|
||||
<div class="sub-search-button-wrapper">
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="text">search</button>
|
||||
|
@ -32,17 +32,16 @@
|
|||
<button name="t" value="forum" class="clickable">Forums</button>
|
||||
</div>
|
||||
<div id="content" class="js-enabled">
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="map">map</button>
|
||||
<button name="t" value="map" class="clickable">Maps</button>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="map">map</button>
|
||||
<button name="t" value="map" class="clickable">Maps</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="file">share</button>
|
||||
<button name="t" value="file" class="clickable">Torrents</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!-- Results go here -->
|
||||
<p class="fetched fetched_dif fetched_vid"><!-- { fetched } --></p>
|
||||
|
@ -51,11 +50,11 @@
|
|||
<div>
|
||||
<div class="video__results">
|
||||
<div class="video__img__results">
|
||||
<a href="{{ .Href }}"> <img src="{{ .Image }}">
|
||||
<div class="duration">{{ .Duration }}</div>
|
||||
</img></a>
|
||||
<a href="{{ .Href }}"> <img src="{{ .Image }}">
|
||||
<div class="duration">{{ .Duration }}</div>
|
||||
</img></a>
|
||||
</div>
|
||||
<div class="results video-results-margin">
|
||||
<div class="results video-results-margin">
|
||||
<h3 class="video_title" href="{{ .Href }}">{{ .Title }}</h3></a>
|
||||
<p class="stats">{{ .Views }} <span class="pipe">|</span> {{ .Date }}</p>
|
||||
<p class="publish__info">YouTube <span class="pipe">|</span> {{ .Creator }}</p>
|
||||
|
@ -64,9 +63,20 @@
|
|||
</div>
|
||||
{{ end }}
|
||||
{{ 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 }}
|
||||
|
||||
<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>
|
||||
// Check if JavaScript is enabled and modify the DOM accordingly
|
||||
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)
|
||||
tmpl, err := template.ParseFiles("templates/videos.html")
|
||||
tmpl, err := template.New("videos.html").Funcs(funcs).ParseFiles("templates/videos.html")
|
||||
if err != nil {
|
||||
log.Printf("Error parsing template: %v", err)
|
||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
tmpl.Execute(w, map[string]interface{}{
|
||||
err = tmpl.Execute(w, map[string]interface{}{
|
||||
"Results": results,
|
||||
"Query": query,
|
||||
"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