Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.3
htdig
htdig-google-style.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File htdig-google-style.patch of Package htdig
Index: htsearch/Display.cc =================================================================== --- htsearch/Display.cc.orig +++ htsearch/Display.cc @@ -694,6 +694,38 @@ // if (nPages > 1) { + // Assume number of page links is equal to maximum_page_buttons + // For example, if pageNumber=9, maximum_page_buttons=10, + // and nPages>=13, we get: + // + // [prev] 4 5 6 7 8 9 10 11 12 13 [next] + + int nPageButtons = config->Value("maximum_page_buttons", 10); + + // Initialize indexes of pages links + int first_page_index = 1; + int last_page_index = nPages; + + if (nPages > nPageButtons) + { + // Try to center the current page + int links_on_the_left = nPageButtons/2; + first_page_index = pageNumber - links_on_the_left; + last_page_index = first_page_index + nPageButtons - 1; + + // Adjust if required + if (first_page_index < 1) + { + first_page_index = 1; + last_page_index = nPageButtons; + } + else if (last_page_index > nPages ) + { + last_page_index = nPages; + first_page_index = nPages - nPageButtons + 1; + } + } + if (pageNumber > 1) { str = new String("<a href=\""); @@ -725,9 +757,7 @@ QuotedStringList pnt(config->Find("page_number_text"), " \t\r\n"); QuotedStringList npnt(config->Find("no_page_number_text"), " \t\r\n"); QuotedStringList sep(config->Find("page_number_separator"), " \t\r\n"); - if (nPages > config->Value("maximum_page_buttons", 10)) - nPages = config->Value("maximum_page_buttons", 10); - for (i = 1; i <= nPages; i++) + for (i = first_page_index; i <= last_page_index; i++) { if (i == pageNumber) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor