Merge pull request #474 from MananJethwani/issue/473

injecting root link directly and renamed head_part to head_taskbar
This commit is contained in:
Kelson 2021-03-24 09:24:42 +01:00 committed by GitHub
commit d061697de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

View File

@ -202,7 +202,7 @@ void ContentResponse::introduce_taskbar()
data.set("hascontent", !m_bookName.empty());
data.set("title", m_bookTitle);
data.set("withlibrarybutton", m_withLibraryButton);
auto head_content = render_template(RESOURCE::templates::head_part_html, data);
auto head_content = render_template(RESOURCE::templates::head_taskbar_html, data);
m_content = prependToFirstOccurence(
m_content,
"</head[ \\t]*>",
@ -227,6 +227,13 @@ void ContentResponse::inject_externallinks_blocker()
script_tag);
}
void ContentResponse::inject_root_link(){
m_content = prependToFirstOccurence(
m_content,
"<head[ \\t]*>",
"<link type=\"root\" href=\"" + m_root + "\">");
}
bool
ContentResponse::can_compress(const RequestContext& request) const
{
@ -252,6 +259,8 @@ Response::create_mhd_response(const RequestContext& request)
MHD_Response*
ContentResponse::create_mhd_response(const RequestContext& request)
{
inject_root_link();
if (contentDecorationAllowed()) {
if (m_withTaskbar) {
introduce_taskbar();

View File

@ -89,6 +89,7 @@ class ContentResponse : public Response {
void introduce_taskbar();
void inject_externallinks_blocker();
void inject_root_link();
bool can_compress(const RequestContext& request) const;
bool contentDecorationAllowed() const;

View File

@ -27,7 +27,7 @@ templates/404.html
templates/500.html
templates/index.html
templates/suggestion.json
templates/head_part.html
templates/head_taskbar.html
templates/taskbar_part.html
templates/external_blocker_part.html
templates/captured_external.html

View File

@ -1,7 +1,6 @@
<link type="text/css" href="{{root}}/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
<link type="text/css" href="{{root}}/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
<link type="text/css" href="{{root}}/skin/taskbar.css" rel="Stylesheet" />
<link type="root" href="{{root}}">
<script type="text/javascript" src="{{root}}/skin/jquery-ui/external/jquery/jquery.js"></script>
<script type="text/javascript" src="{{root}}/skin/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="{{root}}/skin/taskbar.js" async></script>