Add --nolibrarybutton option

This commit is contained in:
Emmanuel Engelhart 2017-06-04 18:49:55 +02:00
parent e51539d161
commit 569b4d946e
2 changed files with 20 additions and 11 deletions

View File

@ -85,7 +85,8 @@ extern "C" {
using namespace std;
static bool nosearchbarFlag = false;
static bool noLibraryButtonFlag = false;
static bool noSearchBarFlag = false;
static string welcomeHTML;
static bool verboseFlag = false;
static std::map<std::string, std::string> extMimeTypes;
@ -120,12 +121,16 @@ static std::string getMimeTypeForFile(const std::string& filename) {
}
void introduceTaskbar(string &content, const string &humanReadableBookId) {
if (!nosearchbarFlag) {
if (!noSearchBarFlag) {
content = appendToFirstOccurence(content, "<head>",
replaceRegex(RESOURCE::include_html_part,
humanReadableBookId, "__CONTENT__"));
content = appendToFirstOccurence(content, "<head>", "<style>" +
RESOURCE::taskbar_css + "</style>");
content = appendToFirstOccurence(content,
"<head>",
"<style>" +
RESOURCE::taskbar_css +
(noLibraryButtonFlag ? " #kiwix_serve_taskbar_library_button { display: none }" : "") +
"</style>");
content = appendToFirstOccurence(content, "<body[^>]*>",
replaceRegex(RESOURCE::taskbar_html_part,
humanReadableBookId, "__CONTENT__"));
@ -713,6 +718,7 @@ int main(int argc, char **argv) {
{"daemon", no_argument, 0, 'd'},
{"verbose", no_argument, 0, 'v'},
{"library", no_argument, 0, 'l'},
{"nolibrarybutton", no_argument, 0, 'm'},
{"nosearchbar", no_argument, 0, 'n'},
{"index", required_argument, 0, 'i'},
{"attachToProcess", required_argument, 0, 'a'},
@ -724,7 +730,7 @@ int main(int argc, char **argv) {
/* Argument parsing */
while (true) {
int option_index = 0;
int c = getopt_long(argc, argv, "ndvli:a:p:f:", long_options, &option_index);
int c = getopt_long(argc, argv, "mndvli:a:p:f:", long_options, &option_index);
if (c != -1) {
@ -739,7 +745,10 @@ int main(int argc, char **argv) {
libraryFlag = true;
break;
case 'n':
nosearchbarFlag = true;
noSearchBarFlag = true;
break;
case 'm':
noLibraryButtonFlag = true;
break;
case 'i':
indexPath = optarg;
@ -771,8 +780,8 @@ int main(int argc, char **argv) {
/* Print usage)) if necessary */
if (zimPathes.empty() && libraryPath.empty()) {
cerr << "Usage: kiwix-serve [--index=INDEX_PATH] [--port=PORT] [--verbose] [--nosearchbar] [--daemon] [--attachToProcess=PID] [--interface=IF_NAME] ZIM_PATH+" << endl;
cerr << " kiwix-serve --library [--port=PORT] [--verbose] [--daemon] [--nosearchbar] [--attachToProcess=PID] [--interface=IF_NAME] LIBRARY_PATH" << endl;
cerr << "Usage: kiwix-serve [--index=INDEX_PATH] [--port=PORT] [--verbose] [--nosearchbar] [--nolibrarybutton] [--daemon] [--attachToProcess=PID] [--interface=IF_NAME] ZIM_PATH+" << endl;
cerr << " kiwix-serve --library [--port=PORT] [--verbose] [--daemon] [--nosearchbar] [--nolibrarybutton] [--attachToProcess=PID] [--interface=IF_NAME] LIBRARY_PATH" << endl;
cerr << "\n If you set more than one ZIM_PATH, you cannot set a INDEX_PATH." << endl;
exit(1);
}

View File

@ -4,9 +4,9 @@
<span id="kiwixtoolbar" class="ui-widget-header">
<div class="kiwix_centered">
<div class="kiwix_button_wrapper">
<a href="/"><button>Library</button></a>
<a href="/__CONTENT__/"><button>Home</button></a>
<a href="/random?content=__CONTENT__"><button>Random</button></a>
<a id="kiwix_serve_taskbar_library_button" href="/"><button>Library</button></a>
<a id="kiwix_serve_taskbar_home_button" href="/__CONTENT__/"><button>Home</button></a>
<a id="kiwix_serve_taskbar_random_button" href="/random?content=__CONTENT__"><button>Random</button></a>
</div>
<div class="kiwix_searchform">
<form class="kiwixsearch" method="GET" action="/search" id="kiwixsearchform">