|
|
|
@ -452,8 +452,8 @@ int main(int argc, char **argv) {
|
|
|
|
vector<string>::iterator itr;
|
|
|
|
vector<string>::iterator itr;
|
|
|
|
kiwix::Book currentBook;
|
|
|
|
kiwix::Book currentBook;
|
|
|
|
for ( itr = booksIds.begin(); itr != booksIds.end(); ++itr ) {
|
|
|
|
for ( itr = booksIds.begin(); itr != booksIds.end(); ++itr ) {
|
|
|
|
|
|
|
|
bool zimFileOk = false;
|
|
|
|
libraryManager.getBookById(*itr, currentBook);
|
|
|
|
libraryManager.getBookById(*itr, currentBook);
|
|
|
|
string humanReadableId = currentBook.getHumanReadableIdFromPath();
|
|
|
|
|
|
|
|
zimPath = currentBook.pathAbsolute;
|
|
|
|
zimPath = currentBook.pathAbsolute;
|
|
|
|
|
|
|
|
|
|
|
|
if (!zimPath.empty()) {
|
|
|
|
if (!zimPath.empty()) {
|
|
|
|
@ -463,38 +463,42 @@ int main(int argc, char **argv) {
|
|
|
|
kiwix::Reader *reader = NULL;
|
|
|
|
kiwix::Reader *reader = NULL;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
reader = new kiwix::Reader(zimPath);
|
|
|
|
reader = new kiwix::Reader(zimPath);
|
|
|
|
|
|
|
|
zimFileOk = true;
|
|
|
|
} catch (...) {
|
|
|
|
} catch (...) {
|
|
|
|
cerr << "Unable to open the ZIM file '" << zimPath << "'." << endl;
|
|
|
|
cerr << "Unable to open the ZIM file '" << zimPath << "'." << endl;
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
readers[humanReadableId] = reader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Instanciate the ZIM index (if necessary) */
|
|
|
|
if (zimFileOk) {
|
|
|
|
kiwix::Searcher *searcher = NULL;
|
|
|
|
string humanReadableId = currentBook.getHumanReadableIdFromPath();
|
|
|
|
if (indexPath != "") {
|
|
|
|
readers[humanReadableId] = reader;
|
|
|
|
bool hasSearchIndex = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Try to load the search */
|
|
|
|
/* Instanciate the ZIM index (if necessary) */
|
|
|
|
try {
|
|
|
|
kiwix::Searcher *searcher = NULL;
|
|
|
|
if (currentBook.indexType == kiwix::XAPIAN) {
|
|
|
|
if (indexPath != "") {
|
|
|
|
searcher = new kiwix::XapianSearcher(indexPath);
|
|
|
|
bool hasSearchIndex = false;
|
|
|
|
} else if (currentBook.indexType == kiwix::CLUCENE) {
|
|
|
|
|
|
|
|
|
|
|
|
/* Try to load the search */
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (currentBook.indexType == kiwix::XAPIAN) {
|
|
|
|
|
|
|
|
searcher = new kiwix::XapianSearcher(indexPath);
|
|
|
|
|
|
|
|
} else if (currentBook.indexType == kiwix::CLUCENE) {
|
|
|
|
#ifndef _WIN32
|
|
|
|
#ifndef _WIN32
|
|
|
|
searcher = new kiwix::CluceneSearcher(indexPath);
|
|
|
|
searcher = new kiwix::CluceneSearcher(indexPath);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw("Unknown index type");
|
|
|
|
throw("Unknown index type");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hasSearchIndex = true;
|
|
|
|
|
|
|
|
} catch (...) {
|
|
|
|
|
|
|
|
cerr << "Unable to open the search index '" << zimPath << "'." << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
hasSearchIndex = true;
|
|
|
|
|
|
|
|
} catch (...) {
|
|
|
|
|
|
|
|
cerr << "Unable to open the search index '" << zimPath << "'." << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hasSearchIndex) {
|
|
|
|
if (hasSearchIndex) {
|
|
|
|
searcher->setProtocolPrefix("/");
|
|
|
|
searcher->setProtocolPrefix("/");
|
|
|
|
searcher->setSearchProtocolPrefix("/search?");
|
|
|
|
searcher->setSearchProtocolPrefix("/search?");
|
|
|
|
searcher->setContentHumanReadableId(humanReadableId);
|
|
|
|
searcher->setContentHumanReadableId(humanReadableId);
|
|
|
|
searchers[humanReadableId] = searcher;
|
|
|
|
searchers[humanReadableId] = searcher;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -504,7 +508,7 @@ int main(int argc, char **argv) {
|
|
|
|
string welcomeBooksHtml;
|
|
|
|
string welcomeBooksHtml;
|
|
|
|
for ( itr = booksIds.begin(); itr != booksIds.end(); ++itr ) {
|
|
|
|
for ( itr = booksIds.begin(); itr != booksIds.end(); ++itr ) {
|
|
|
|
libraryManager.getBookById(*itr, currentBook);
|
|
|
|
libraryManager.getBookById(*itr, currentBook);
|
|
|
|
if (!currentBook.path.empty()) {
|
|
|
|
if (!currentBook.path.empty() && readers.find(currentBook.getHumanReadableIdFromPath()) != readers.end()) {
|
|
|
|
welcomeBooksHtml += "<h3><a href=\"#\">" + currentBook.title + "</a></h3> \
|
|
|
|
welcomeBooksHtml += "<h3><a href=\"#\">" + currentBook.title + "</a></h3> \
|
|
|
|
<table style=\"overflow-x: hidden; overflow-y: hidden; margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; width: 100%; \"><tr> \
|
|
|
|
<table style=\"overflow-x: hidden; overflow-y: hidden; margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; width: 100%; \"><tr> \
|
|
|
|
<td style=\"background-repeat: no-repeat; background-image: url(data:" + currentBook.faviconMimeType+ ";base64," + currentBook.favicon + ")\"><div style=\"width: 50px\"/></td> \
|
|
|
|
<td style=\"background-repeat: no-repeat; background-image: url(data:" + currentBook.faviconMimeType+ ";base64," + currentBook.favicon + ")\"><div style=\"width: 50px\"/></td> \
|
|
|
|
|