|
|
|
@ -288,12 +288,42 @@ static int accessHandlerCallback(void *cls,
|
|
|
|
/* Try first to load directly the article if exactly matching the pattern */
|
|
|
|
/* Try first to load directly the article if exactly matching the pattern */
|
|
|
|
std::string patternCorrespondingUrl;
|
|
|
|
std::string patternCorrespondingUrl;
|
|
|
|
if (reader != NULL) {
|
|
|
|
if (reader != NULL) {
|
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(&readerLock);
|
|
|
|
pthread_mutex_lock(&readerLock);
|
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Try to see if there is an article with this title */
|
|
|
|
|
|
|
|
reader->getPageUrlFromTitle(patternString, patternCorrespondingUrl);
|
|
|
|
|
|
|
|
found = !patternCorrespondingUrl.empty();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Try with first letter uppercase */
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
|
|
|
|
patternString = kiwix::ucFirst(patternString);
|
|
|
|
|
|
|
|
reader->getPageUrlFromTitle(patternString, patternCorrespondingUrl);
|
|
|
|
|
|
|
|
found = !patternCorrespondingUrl.empty();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Try with first letter lowercase */
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
|
|
|
|
patternString = kiwix::lcFirst(patternString);
|
|
|
|
reader->getPageUrlFromTitle(patternString, patternCorrespondingUrl);
|
|
|
|
reader->getPageUrlFromTitle(patternString, patternCorrespondingUrl);
|
|
|
|
|
|
|
|
found = !patternCorrespondingUrl.empty();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Try with title words */
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
|
|
|
|
patternString = kiwix::toTitle(patternString);
|
|
|
|
|
|
|
|
reader->getPageUrlFromTitle(patternString, patternCorrespondingUrl);
|
|
|
|
|
|
|
|
found = !patternCorrespondingUrl.empty();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&readerLock);
|
|
|
|
pthread_mutex_unlock(&readerLock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* If article found then redirect directly to it */
|
|
|
|
if (!patternCorrespondingUrl.empty()) {
|
|
|
|
if (!patternCorrespondingUrl.empty()) {
|
|
|
|
httpRedirection="/" + humanReadableBookId + "/" + patternCorrespondingUrl;
|
|
|
|
httpRedirection="/" + humanReadableBookId + "/" + patternCorrespondingUrl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Make the search */
|
|
|
|
/* Make the search */
|
|
|
|
|