|
|
@ -114,6 +114,18 @@ inline std::string _tostring(const T& value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<kiwix::Reader*, kiwix::Searcher*>
|
|
|
|
|
|
|
|
get_from_humanReadableBookId(const std::string& humanReadableBookId) {
|
|
|
|
|
|
|
|
kiwix::Searcher* searcher
|
|
|
|
|
|
|
|
= searchers.find(humanReadableBookId) != searchers.end()
|
|
|
|
|
|
|
|
? searchers.find(humanReadableBookId)->second
|
|
|
|
|
|
|
|
: globalSearcher;
|
|
|
|
|
|
|
|
kiwix::Reader* reader = readers.find(humanReadableBookId) != readers.end()
|
|
|
|
|
|
|
|
? readers.find(humanReadableBookId)->second
|
|
|
|
|
|
|
|
: NULL;
|
|
|
|
|
|
|
|
return std::pair<kiwix::Reader*, kiwix::Searcher*>(reader, searcher);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Try to get the mimeType from the file extension */
|
|
|
|
/* Try to get the mimeType from the file extension */
|
|
|
|
static std::string getMimeTypeForFile(const std::string& filename)
|
|
|
|
static std::string getMimeTypeForFile(const std::string& filename)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -147,7 +159,10 @@ static bool startswith(const std::string& base, const std::string& start)
|
|
|
|
|
|
|
|
|
|
|
|
void introduceTaskbar(string& content, const string& humanReadableBookId)
|
|
|
|
void introduceTaskbar(string& content, const string& humanReadableBookId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
string zimTitle;
|
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(®exLock);
|
|
|
|
pthread_mutex_lock(®exLock);
|
|
|
|
|
|
|
|
|
|
|
|
if (!noSearchBarFlag) {
|
|
|
|
if (!noSearchBarFlag) {
|
|
|
|
content = appendToFirstOccurence(
|
|
|
|
content = appendToFirstOccurence(
|
|
|
|
content,
|
|
|
|
content,
|
|
|
@ -169,10 +184,18 @@ void introduceTaskbar(string& content, const string& humanReadableBookId)
|
|
|
|
RESOURCE::taskbar_html_part,
|
|
|
|
RESOURCE::taskbar_html_part,
|
|
|
|
humanReadableBookId,
|
|
|
|
humanReadableBookId,
|
|
|
|
"__CONTENT__"));
|
|
|
|
"__CONTENT__"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto reader = get_from_humanReadableBookId(humanReadableBookId).first;
|
|
|
|
|
|
|
|
if (reader != nullptr) {
|
|
|
|
|
|
|
|
zimTitle = reader->getTitle();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
content = replaceRegex(content, rootLocation, "__ROOT_LOCATION__");
|
|
|
|
content = replaceRegex(content, rootLocation, "__ROOT_LOCATION__");
|
|
|
|
|
|
|
|
content = replaceRegex(content, replaceRegex(zimTitle, "%26", "&"), "__ZIM_TITLE__");
|
|
|
|
content = replaceRegex(content, replaceRegex(humanReadableBookId, "%26", "&"), "__CONTENT_ESCAPED__");
|
|
|
|
content = replaceRegex(content, replaceRegex(humanReadableBookId, "%26", "&"), "__CONTENT_ESCAPED__");
|
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_unlock(®exLock);
|
|
|
|
pthread_mutex_unlock(®exLock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -378,18 +401,6 @@ static struct MHD_Response* build_callback_response_from_entry(
|
|
|
|
return response;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<kiwix::Reader*, kiwix::Searcher*>
|
|
|
|
|
|
|
|
get_from_humanReadableBookId(const std::string& humanReadableBookId) {
|
|
|
|
|
|
|
|
kiwix::Searcher* searcher
|
|
|
|
|
|
|
|
= searchers.find(humanReadableBookId) != searchers.end()
|
|
|
|
|
|
|
|
? searchers.find(humanReadableBookId)->second
|
|
|
|
|
|
|
|
: globalSearcher;
|
|
|
|
|
|
|
|
kiwix::Reader* reader = readers.find(humanReadableBookId) != readers.end()
|
|
|
|
|
|
|
|
? readers.find(humanReadableBookId)->second
|
|
|
|
|
|
|
|
: NULL;
|
|
|
|
|
|
|
|
return std::pair<kiwix::Reader*, kiwix::Searcher*>(reader, searcher);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct MHD_Response* handle_meta(RequestContext* request)
|
|
|
|
static struct MHD_Response* handle_meta(RequestContext* request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string humanReadableBookId;
|
|
|
|
std::string humanReadableBookId;
|
|
|
|