HTML: Use the new pagination component for search results

This commit is contained in:
Samantaz Fox
2023-04-18 00:12:56 +02:00
parent c4ef3bed95
commit efaf7cb09c
3 changed files with 16 additions and 76 deletions

View File

@@ -59,17 +59,21 @@ module Invidious::Routes::Search
return error_template(500, ex)
end
params = query.to_http_params
url_prev_page = "/search?#{params}&page=#{query.page - 1}"
url_next_page = "/search?#{params}&page=#{query.page + 1}"
redirect_url = Invidious::Frontend::Misc.redirect_url(env)
# Pagination
page_nav_html = Frontend::Pagination.nav_numeric(locale,
base_url: "/search?#{query.to_http_params}",
current_page: query.page,
show_next: (videos.size >= 20)
)
if query.type == Invidious::Search::Query::Type::Channel
env.set "search", "channel:#{query.channel} #{query.text}"
else
env.set "search", query.text
end
templated "search"
end
end
@@ -96,11 +100,13 @@ module Invidious::Routes::Search
return error_template(500, ex)
end
params = env.params.query.empty? ? "" : "&#{env.params.query}"
# Pagination
hashtag_encoded = URI.encode_www_form(hashtag, space_to_plus: false)
url_prev_page = "/hashtag/#{hashtag_encoded}?page=#{page - 1}#{params}"
url_next_page = "/hashtag/#{hashtag_encoded}?page=#{page + 1}#{params}"
page_nav_html = Frontend::Pagination.nav_numeric(locale,
base_url: "/hashtag/#{hashtag_encoded}",
current_page: page,
show_next: (videos.size >= 60)
)
templated "hashtag"
end