mirror of https://github.com/kiwix/libkiwix.git
+ Introduction of base url in kiwix-serve (to handle relative urls in ZIM files)
This commit is contained in:
parent
4e05d0dea6
commit
005b75f7ab
|
@ -380,6 +380,11 @@ namespace kiwix {
|
|||
}
|
||||
|
||||
bool Reader::getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType) {
|
||||
std::string stubRedirectUrl;
|
||||
return this->getContentByDecodedUrl(kiwix::urlDecode(url), content, contentLength, contentType, stubRedirectUrl);
|
||||
}
|
||||
|
||||
bool Reader::getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType, string &baseUrl) {
|
||||
bool retVal = false;
|
||||
content="";
|
||||
contentType="";
|
||||
|
@ -411,6 +416,9 @@ namespace kiwix {
|
|||
article = article.getRedirectArticle();
|
||||
}
|
||||
|
||||
/* Compute base url (might be different from the url if redirects */
|
||||
baseUrl = "/" + std::string(1, article.getNamespace()) + "/" + article.getUrl();
|
||||
|
||||
/* Get the content mime-type */
|
||||
contentType = string(article.getMimeType().data(), article.getMimeType().size());
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace kiwix {
|
|||
bool getPageUrlFromTitle(const string &title, string &url);
|
||||
bool getContentByUrl(const string &url, string &content, unsigned int &contentLength, string &contentType);
|
||||
bool getContentByEncodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType);
|
||||
bool getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType, string &baseUrl);
|
||||
bool getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType);
|
||||
bool searchSuggestions(const string &prefix, unsigned int suggestionsCount, const bool reset = true);
|
||||
bool searchSuggestionsSmart(const string &prefix, unsigned int suggestionsCount);
|
||||
|
|
Loading…
Reference in New Issue