Externalize license footer script to satisfy CSP
This commit is contained in:
parent
05082b6f01
commit
acecd619e9
3 changed files with 87 additions and 2 deletions
12
nginx.conf
12
nginx.conf
|
|
@ -52,6 +52,14 @@ http {
|
|||
access_log off;
|
||||
}
|
||||
|
||||
# Same-origin static assets we inject (license footer script, etc.).
|
||||
# Same-origin URLs satisfy Outline's CSP without needing a nonce.
|
||||
location /theme/ {
|
||||
root /usr/share/nginx/html;
|
||||
expires 1h;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# Homepage: inject OG meta tags + license footer script
|
||||
location = / {
|
||||
proxy_pass http://outline;
|
||||
|
|
@ -70,7 +78,7 @@ http {
|
|||
sub_filter '<head>' '<head><meta property="og:title" content="Ghost Guild Wiki" /><meta property="og:description" content="A living knowledge base for Baby Ghosts & Ghost Guild." /><meta property="og:type" content="website" /><meta property="og:url" content="https://wiki.ghostguild.org" /><meta name="twitter:card" content="summary" /><meta name="twitter:title" content="Ghost Guild Wiki" /><meta name="twitter:description" content="A living knowledge base for Baby Ghosts & Ghost Guild." />';
|
||||
|
||||
# CC BY-SA 4.0 license footer (script self-gates to /doc/ pages).
|
||||
sub_filter '</head>' '<style>.cc-license-footer{margin:4rem 0 2rem;padding:1.5rem 0 0;border-top:1px solid rgba(128,128,128,0.25);font-size:0.85em;line-height:1.5;opacity:0.75}.cc-license-footer p{margin:0}.cc-license-footer a{color:inherit;text-decoration:underline}</style><script>(function(){var URL_HREF="https://creativecommons.org/licenses/by-sa/4.0/";var PREFIX="Content on this site by Baby Ghosts Studio Development Fund is licensed under CC BY-SA 4.0. To view a copy of this license, visit ";function isDoc(){return location.pathname.indexOf("/doc/")===0}function findTarget(){var pm=document.querySelector(".ProseMirror");if(pm&&pm.parentElement)return pm.parentElement;return document.querySelector("article")||document.querySelector("[role=main]")||document.querySelector("main")}function render(){var ex=document.querySelector(".cc-license-footer");if(!isDoc()){if(ex)ex.remove();return}if(ex)return;var t=findTarget();if(!t)return;var f=document.createElement("footer");f.className="cc-license-footer";var p=document.createElement("p");p.appendChild(document.createTextNode(PREFIX));var a=document.createElement("a");a.href=URL_HREF;a.target="_blank";a.rel="noopener noreferrer";a.textContent=URL_HREF;p.appendChild(a);f.appendChild(p);t.appendChild(f)}var pending=false;function s(){if(pending)return;pending=true;requestAnimationFrame(function(){pending=false;render()})}["pushState","replaceState"].forEach(function(m){var o=history[m];history[m]=function(){o.apply(this,arguments);s()}});window.addEventListener("popstate",s);function go(){new MutationObserver(s).observe(document.body,{childList:true,subtree:true});s()}if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",go)}else{go()}})();</script></head>';
|
||||
sub_filter '</head>' '<style>.cc-license-footer{margin:4rem 0 2rem;padding:1.5rem 0 0;border-top:1px solid rgba(128,128,128,0.25);font-size:0.85em;line-height:1.5;opacity:0.75}.cc-license-footer p{margin:0}.cc-license-footer a{color:inherit;text-decoration:underline}</style><script src="/theme/license-footer.js" defer></script></head>';
|
||||
|
||||
sub_filter_once on;
|
||||
sub_filter_types text/html;
|
||||
|
|
@ -95,7 +103,7 @@ http {
|
|||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# CC BY-SA 4.0 license footer (script self-gates to /doc/ pages).
|
||||
sub_filter '</head>' '<style>.cc-license-footer{margin:4rem 0 2rem;padding:1.5rem 0 0;border-top:1px solid rgba(128,128,128,0.25);font-size:0.85em;line-height:1.5;opacity:0.75}.cc-license-footer p{margin:0}.cc-license-footer a{color:inherit;text-decoration:underline}</style><script>(function(){var URL_HREF="https://creativecommons.org/licenses/by-sa/4.0/";var PREFIX="Content on this site by Baby Ghosts Studio Development Fund is licensed under CC BY-SA 4.0. To view a copy of this license, visit ";function isDoc(){return location.pathname.indexOf("/doc/")===0}function findTarget(){var pm=document.querySelector(".ProseMirror");if(pm&&pm.parentElement)return pm.parentElement;return document.querySelector("article")||document.querySelector("[role=main]")||document.querySelector("main")}function render(){var ex=document.querySelector(".cc-license-footer");if(!isDoc()){if(ex)ex.remove();return}if(ex)return;var t=findTarget();if(!t)return;var f=document.createElement("footer");f.className="cc-license-footer";var p=document.createElement("p");p.appendChild(document.createTextNode(PREFIX));var a=document.createElement("a");a.href=URL_HREF;a.target="_blank";a.rel="noopener noreferrer";a.textContent=URL_HREF;p.appendChild(a);f.appendChild(p);t.appendChild(f)}var pending=false;function s(){if(pending)return;pending=true;requestAnimationFrame(function(){pending=false;render()})}["pushState","replaceState"].forEach(function(m){var o=history[m];history[m]=function(){o.apply(this,arguments);s()}});window.addEventListener("popstate",s);function go(){new MutationObserver(s).observe(document.body,{childList:true,subtree:true});s()}if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",go)}else{go()}})();</script></head>';
|
||||
sub_filter '</head>' '<style>.cc-license-footer{margin:4rem 0 2rem;padding:1.5rem 0 0;border-top:1px solid rgba(128,128,128,0.25);font-size:0.85em;line-height:1.5;opacity:0.75}.cc-license-footer p{margin:0}.cc-license-footer a{color:inherit;text-decoration:underline}</style><script src="/theme/license-footer.js" defer></script></head>';
|
||||
|
||||
sub_filter_once on;
|
||||
sub_filter_types text/html;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue