Modernize frontend assets and security baseline
All checks were successful
Publish static bundles / publish (push) Successful in 3m19s
All checks were successful
Publish static bundles / publish (push) Successful in 3m19s
This commit is contained in:
parent
33d9509678
commit
1d55bdb691
995 changed files with 10228 additions and 16769 deletions
|
|
@ -15,13 +15,39 @@ function walkHtml(dir) {
|
|||
}
|
||||
|
||||
function removeWordPressResidue(html) {
|
||||
return html
|
||||
const securityMeta = `<meta http-equiv="Content-Security-Policy" content="default-src 'self'; base-uri 'self'; object-src 'none'; img-src 'self' data: https:; font-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://static.cloudflareinsights.com; connect-src 'self' https:; frame-src https://www.youtube.com https://www.youtube-nocookie.com https://player.vimeo.com; form-action 'self' mailto: https:; upgrade-insecure-requests" />
|
||||
<meta name="referrer" content="strict-origin-when-cross-origin" />`;
|
||||
const bannerPicture = `<picture class="site-banner">
|
||||
<source type="image/avif" srcset="/assets/uploads/2013/10/BannerFamilyFed_23_10c1-480.avif 480w, /assets/uploads/2013/10/BannerFamilyFed_23_10c1-768.avif 768w, /assets/uploads/2013/10/BannerFamilyFed_23_10c1-1050.avif 1050w" sizes="(max-width: 1050px) 100vw, 1050px" />
|
||||
<source type="image/webp" srcset="/assets/uploads/2013/10/BannerFamilyFed_23_10c1-480.webp 480w, /assets/uploads/2013/10/BannerFamilyFed_23_10c1-768.webp 768w, /assets/uploads/2013/10/BannerFamilyFed_23_10c1-1050.webp 1050w" sizes="(max-width: 1050px) 100vw, 1050px" />
|
||||
<img id="bg_image" alt="Family Federation for World Peace and Unification Ireland" src="/assets/uploads/2013/10/BannerFamilyFed_23_10c1.jpg" width="1050" height="120" fetchpriority="high" />
|
||||
</picture>`;
|
||||
|
||||
let cleaned = html
|
||||
.replace(/\n?<!--\[if lt IE 9\]>\s*<script>[\s\S]*?<\/script>\s*<!\[endif\]-->\s*/g, "\n")
|
||||
.replace(
|
||||
/\n?\s*<script>\s*\/\* <!\[CDATA\[ \*\/var tribe_l10n_datatables = [\s\S]*?<\/script>/g,
|
||||
""
|
||||
)
|
||||
.replace(/\n?<!-- Shortcodes Ultimate custom CSS - start -->\s*<!-- Shortcodes Ultimate custom CSS - end -->\s*/g, "\n");
|
||||
.replace(/\n?<!-- Shortcodes Ultimate custom CSS - start -->\s*<!-- Shortcodes Ultimate custom CSS - end -->\s*/g, "\n")
|
||||
.replace(/\s*<script\b[^>]*\bsrc=["'][^"']*(?:\/js\/jquery\.min\.js[^"']*|\/assets\/theme\/parabola\/js\/[^"']+|\/assets\/vendor\/[^"']+\.js[^"']*)["'][^>]*>\s*<\/script>/gi, "")
|
||||
.replace(/\s*<script\b[^>]*id=["']parabola-frontend-js-extra["'][^>]*>[\s\S]*?<\/script>/gi, "")
|
||||
.replace(/\s*<script\b[^>]*>[\s\S]*?jQuery\(document\)\.ready[\s\S]*?<\/script>/gi, "")
|
||||
.replace(/\s*<script>\s*\( function \( body \)[\s\S]*?<\/script>/gi, "")
|
||||
.replace(/\s*<script[^>]*>\s*var cryout_global_content_width = 800;\s*<\/script>/gi, "")
|
||||
.replace(/href=(["'])\/css\/site\.css(?:\?ver=[^"']*)?\1/gi, 'href=$1/css/site.css?ver=20260715-1$1')
|
||||
.replace(/<div id="toTop">\s*<\/div>/g, '<button id="toTop" type="button" aria-label="Back to top"></button>')
|
||||
.replace(/(?:<picture class="site-banner">\s*<source\b[^>]*>\s*<source\b[^>]*>\s*)*<img id="bg_image"[^>]*BannerFamilyFed_23_10c1\.jpg[^>]*>(?:\s*<\/picture>)*/g, bannerPicture);
|
||||
|
||||
if (!cleaned.includes("/js/site.js") && cleaned.includes("</body>")) {
|
||||
cleaned = cleaned.replace(/\s*<\/body>/i, '\n<script defer src="/js/site.js?ver=20260715-1"></script>\n</body>');
|
||||
}
|
||||
|
||||
if (!cleaned.includes('http-equiv="Content-Security-Policy"') && cleaned.includes("</head>")) {
|
||||
cleaned = cleaned.replace(/\s*<\/head>/i, `\n${securityMeta}\n</head>`);
|
||||
}
|
||||
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
let updated = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue