Fix kiwix-serve pagination

This commit is contained in:
Emmanuel Engelhart
2025-06-07 14:34:04 +02:00
committed by Kelson
parent 759d430232
commit d857b0f8f6
2 changed files with 4 additions and 4 deletions

View File

@@ -224,8 +224,8 @@ std::string SearchRenderer::renderTemplate(const std::string& tmpl_str, const Na
kainjow::mustache::data results;
results.set("items", items);
results.set("count", kiwix::beautifyInteger(estimatedResultCount));
results.set("start", kiwix::beautifyInteger(resultStart));
results.set("end", kiwix::beautifyInteger(std::min(resultStart+pageLength-1, estimatedResultCount)));
results.set("start", kiwix::beautifyInteger(resultStart+1));
results.set("end", kiwix::beautifyInteger(std::min(resultStart+pageLength, estimatedResultCount)));
// pagination
auto pagination = buildPagination(

View File

@@ -1021,11 +1021,11 @@ std::unique_ptr<Response> InternalServer::handle_search_request(const RequestCon
return response;
}
const auto start = max(1u, request.get_optional_param("start", 1u));
const auto start = max(0u, request.get_optional_param("start", 0u));
const auto pageLength = getSearchPageSize(request);
/* Get the results */
SearchRenderer renderer(search->getResults(start-1, pageLength), start,
SearchRenderer renderer(search->getResults(start, pageLength), start,
search->getEstimatedMatches());
renderer.setSearchPattern(searchInfo.pattern);
renderer.setSearchBookQuery(searchInfo.bookFilterQuery);