mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-24 04:20:56 -04:00
+ implement --nosearchbar option for kiwix-serve
This commit is contained in:
parent
77dfd3e03f
commit
27a6e645ed
@ -74,6 +74,7 @@ extern "C" {
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
static bool nosearchbarFlag = false;
|
||||||
static string welcomeHTML;
|
static string welcomeHTML;
|
||||||
static bool verboseFlag = false;
|
static bool verboseFlag = false;
|
||||||
static std::map<std::string, kiwix::Reader*> readers;
|
static std::map<std::string, kiwix::Reader*> readers;
|
||||||
@ -88,12 +89,14 @@ static pthread_mutex_t verboseFlagLock = PTHREAD_MUTEX_INITIALIZER;
|
|||||||
|
|
||||||
void introduceTaskbar(string &content, const string &humanReadableBookId) {
|
void introduceTaskbar(string &content, const string &humanReadableBookId) {
|
||||||
pthread_mutex_lock(&resourceLock);
|
pthread_mutex_lock(&resourceLock);
|
||||||
|
if (!nosearchbarFlag) {
|
||||||
content = appendToFirstOccurence(content, "<head>", getResourceAsString("jqueryui/include.html.part"));
|
content = appendToFirstOccurence(content, "<head>", getResourceAsString("jqueryui/include.html.part"));
|
||||||
content = appendToFirstOccurence(content, "<head>", "<style>" +
|
content = appendToFirstOccurence(content, "<head>", "<style>" +
|
||||||
getResourceAsString("server/taskbar.css") + "</style>");
|
getResourceAsString("server/taskbar.css") + "</style>");
|
||||||
std::string HTMLDivRewrited = replaceRegex(getResourceAsString("server/taskbar.html.part"),
|
std::string HTMLDivRewrited = replaceRegex(getResourceAsString("server/taskbar.html.part"),
|
||||||
humanReadableBookId, "__CONTENT__");
|
humanReadableBookId, "__CONTENT__");
|
||||||
content = appendToFirstOccurence(content, "<body[^>]*>", HTMLDivRewrited);
|
content = appendToFirstOccurence(content, "<body[^>]*>", HTMLDivRewrited);
|
||||||
|
}
|
||||||
pthread_mutex_unlock(&resourceLock);
|
pthread_mutex_unlock(&resourceLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,6 +403,7 @@ int main(int argc, char **argv) {
|
|||||||
{"daemon", no_argument, 0, 'd'},
|
{"daemon", no_argument, 0, 'd'},
|
||||||
{"verbose", no_argument, 0, 'v'},
|
{"verbose", no_argument, 0, 'v'},
|
||||||
{"library", no_argument, 0, 'l'},
|
{"library", no_argument, 0, 'l'},
|
||||||
|
{"nosearchbar", no_argument, 0, 'n'},
|
||||||
{"index", required_argument, 0, 'i'},
|
{"index", required_argument, 0, 'i'},
|
||||||
{"attachToProcess", required_argument, 0, 'a'},
|
{"attachToProcess", required_argument, 0, 'a'},
|
||||||
{"port", required_argument, 0, 'p'},
|
{"port", required_argument, 0, 'p'},
|
||||||
@ -407,7 +411,7 @@ int main(int argc, char **argv) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
int c = getopt_long(argc, argv, "dvli:a:p:", long_options, &option_index);
|
int c = getopt_long(argc, argv, "ndvli:a:p:", long_options, &option_index);
|
||||||
|
|
||||||
if (c != -1) {
|
if (c != -1) {
|
||||||
|
|
||||||
@ -424,6 +428,10 @@ int main(int argc, char **argv) {
|
|||||||
libraryFlag = true;
|
libraryFlag = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
nosearchbarFlag = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
indexPath = optarg;
|
indexPath = optarg;
|
||||||
break;
|
break;
|
||||||
@ -451,8 +459,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* Print usage)) if necessary */
|
/* Print usage)) if necessary */
|
||||||
if (zimPath.empty() && libraryPath.empty()) {
|
if (zimPath.empty() && libraryPath.empty()) {
|
||||||
cerr << "Usage: kiwix-serve [--index=INDEX_PATH] [--port=PORT] [--verbose] [--daemon] [--attachToProcess=PID] ZIM_PATH" << endl;
|
cerr << "Usage: kiwix-serve [--index=INDEX_PATH] [--port=PORT] [--verbose] [--nosearchbar] [--daemon] [--attachToProcess=PID] ZIM_PATH" << endl;
|
||||||
cerr << " kiwix-serve --library [--port=PORT] [--verbose] [--daemon] [--attachToProcess=PID] LIBRARY_PATH" << endl;
|
cerr << " kiwix-serve --library [--port=PORT] [--verbose] [--daemon] [--nosearchbar] [--attachToProcess=PID] LIBRARY_PATH" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user