mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-22 11:22:38 -04:00
Merge pull request #200 from kiwix/improved_kiwix_serve_taskbar
Improved taskbar #160 #59
This commit is contained in:
commit
5c040d3ee6
@ -1,6 +1,11 @@
|
|||||||
kiwix-tools 0.6.0
|
kiwix-tools 0.6.0
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
kiwix-serve
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Improved taskbar #160 #59
|
||||||
|
|
||||||
kiwix-manage
|
kiwix-manage
|
||||||
------------
|
------------
|
||||||
|
|
||||||
@ -13,7 +18,7 @@ kiwix-tools 0.5.0
|
|||||||
* Compile without warning.
|
* Compile without warning.
|
||||||
|
|
||||||
|
|
||||||
kiwix-server
|
kiwix-serve
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Serve metadata information using the "/meta" url.
|
* Serve metadata information using the "/meta" url.
|
||||||
|
@ -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;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="kiwix_searchform">
|
<div class="kiwix_searchform">
|
||||||
<form class="kiwixsearch" method="GET" action="__ROOT_LOCATION__/search" id="kiwixsearchform">
|
<form class="kiwixsearch" method="GET" action="__ROOT_LOCATION__/search" id="kiwixsearchform">
|
||||||
<input autocomplete="off" class="ui-autocomplete-input" id="kiwixsearchbox" name="pattern" type="text">
|
<input autocomplete="off" class="ui-autocomplete-input" id="kiwixsearchbox" name="pattern" type="text">
|
||||||
<input type="submit" value="Search">
|
<input type="submit" value="🔍">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
<span id="kiwixtoolbar" class="ui-widget-header">
|
<span id="kiwixtoolbar" class="ui-widget-header">
|
||||||
<div class="kiwix_centered">
|
<div class="kiwix_centered">
|
||||||
<div class="kiwix_button_wrapper">
|
<div class="kiwix_button_wrapper">
|
||||||
<a id="kiwix_serve_taskbar_library_button" href="__ROOT_LOCATION__/"><button>Library</button></a>
|
<a id="kiwix_serve_taskbar_library_button" href="__ROOT_LOCATION__/"><button>🏠</button></a>
|
||||||
<a id="kiwix_serve_taskbar_home_button" href="__ROOT_LOCATION__/__CONTENT__/"><button>Home</button></a>
|
<a id="kiwix_serve_taskbar_home_button" href="__ROOT_LOCATION__/__CONTENT__/"><button>__ZIM_TITLE__</button></a>
|
||||||
<a id="kiwix_serve_taskbar_random_button" href="__ROOT_LOCATION__/random?content=__CONTENT_ESCAPED__"><button>Random</button></a>
|
<a id="kiwix_serve_taskbar_random_button" href="__ROOT_LOCATION__/random?content=__CONTENT_ESCAPED__"><button>🎲</button></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="kiwix_searchform">
|
<div class="kiwix_searchform">
|
||||||
<form class="kiwixsearch" method="GET" action="__ROOT_LOCATION__/search" id="kiwixsearchform">
|
<form class="kiwixsearch" method="GET" action="__ROOT_LOCATION__/search" id="kiwixsearchform">
|
||||||
<input type="hidden" name="content" value="__CONTENT__" />
|
<input type="hidden" name="content" value="__CONTENT__" />
|
||||||
<input autocomplete="off" class="ui-autocomplete-input" id="kiwixsearchbox" name="pattern" type="text">
|
<input autocomplete="off" class="ui-autocomplete-input" id="kiwixsearchbox" name="pattern" type="text">
|
||||||
<input type="submit" value="Search">
|
<input type="submit" value="🔍">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user