mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #472 from MananJethwani/issue/407
added root functionality for block external link feature
This commit is contained in:
commit
1f45c42c32
|
@ -221,9 +221,9 @@ void ContentResponse::inject_externallinks_blocker()
|
||||||
kainjow::mustache::data data;
|
kainjow::mustache::data data;
|
||||||
data.set("root", m_root);
|
data.set("root", m_root);
|
||||||
auto script_tag = render_template(RESOURCE::templates::external_blocker_part_html, data);
|
auto script_tag = render_template(RESOURCE::templates::external_blocker_part_html, data);
|
||||||
m_content = appendToFirstOccurence(
|
m_content = prependToFirstOccurence(
|
||||||
m_content,
|
m_content,
|
||||||
"<head>",
|
"</head[ \\t]*>",
|
||||||
script_tag);
|
script_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
const root = document.querySelector( `link[type='root']` ).getAttribute("href");
|
||||||
// `block_path` variable used by openzim/warc2zim to detect whether URL blocking is enabled or not
|
// `block_path` variable used by openzim/warc2zim to detect whether URL blocking is enabled or not
|
||||||
var block_path = "/catch/external";
|
var block_path = `${root}/catch/external`;
|
||||||
// called only on external links
|
// called only on external links
|
||||||
function capture_event(e, target) { target.setAttribute("href", encodeURI(block_path + "?source=" + target.href)); }
|
function capture_event(e, target) { target.setAttribute("href", encodeURI(block_path + "?source=" + target.href)); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue