fix typo #7

Merged
partisan merged 17 commits from work into main 2024-06-15 23:39:25 +00:00
2 changed files with 35 additions and 18 deletions
Showing only changes of commit d91c275aed - Show all commits

View file

@ -10,10 +10,10 @@
<form action="/search" id="prev-next-form" class="results-search-container" method="GET" autocomplete="off"> <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> <h1 class="logomobile"><a class="no-decoration" href="./">Ocásek</a></h1>
<div class="wrapper-results"> <div class="wrapper-results">
<input type="text" name="q" value="{{ .Query }}" id="search-input" placeholder="Type to search..." /> <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> <button id="search-wrapper-ico" class="material-icons-round" name="t" value="video">search</button>
<input type="submit" class="hide" name="t" value="video" /> <input type="submit" class="hide" name="t" value="video" />
</div> </div>
<div class="sub-search-button-wrapper"> <div class="sub-search-button-wrapper">
<div class="search-container-results-btn"> <div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="text">search</button> <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> <button name="t" value="forum" class="clickable">Forums</button>
</div> </div>
<div id="content" class="js-enabled"> <div id="content" class="js-enabled">
<div class="search-container-results-btn"> <div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="map">map</button> <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> <button name="t" value="map" class="clickable">Maps</button>
</div>
</div> </div>
</div>
<div class="search-container-results-btn"> <div class="search-container-results-btn">
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="file">share</button> <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> <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>
@ -51,11 +50,11 @@
<div> <div>
<div class="video__results"> <div class="video__results">
<div class="video__img__results"> <div class="video__img__results">
<a href="{{ .Href }}"> <img src="{{ .Image }}"> <a href="{{ .Href }}"> <img src="{{ .Image }}">
<div class="duration">{{ .Duration }}</div> <div class="duration">{{ .Duration }}</div>
</img></a> </img></a>
</div> </div>
<div class="results video-results-margin"> <div class="results video-results-margin">
<h3 class="video_title" href="{{ .Href }}">{{ .Title }}</h3></a> <h3 class="video_title" href="{{ .Href }}">{{ .Title }}</h3></a>
<p class="stats">{{ .Views }} <span class="pipe">|</span> {{ .Date }}</p> <p class="stats">{{ .Views }} <span class="pipe">|</span> {{ .Date }}</p>
<p class="publish__info">YouTube <span class="pipe">|</span> {{ .Creator }}</p> <p class="publish__info">YouTube <span class="pipe">|</span> {{ .Creator }}</p>
@ -64,12 +63,23 @@
</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');
</script> </script>
</body> </body>
</html> </html>

View file

@ -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)
}
} }