branded header, nav, footer for OTB
https://outsidethebox.top
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
#!/bin/bash |
|
set -e |
|
SITE_DIR="/var/www/outsidethebox.top" |
|
cd "$SITE_DIR" || exit 1 |
|
|
|
STAMP="$(date +%Y%m%d-%H%M%S)" |
|
BKDIR="backups/shared-brand-$STAMP" |
|
mkdir -p "$BKDIR" |
|
cp -av index.html pricing.html terms.html contact.html assets/style.css "$BKDIR"/ |
|
|
|
HEADER="$(cat /home/def/otb-shared-brand/header.html)" |
|
FOOTER="$(cat /home/def/otb-shared-brand/footer.html | sed 's|__OTB_BRAND_JS__|/assets/brand.js|g')" |
|
BRANDCSS="$(cat /home/def/otb-shared-brand/brand.css)" |
|
|
|
cp -av /home/def/otb-shared-brand/brand.js assets/brand.js |
|
|
|
python3 - <<PY2 |
|
from pathlib import Path |
|
import re |
|
|
|
header = '''$HEADER''' |
|
footer = '''$FOOTER''' |
|
brandcss = '''$BRANDCSS''' |
|
|
|
for name in ["index.html", "pricing.html", "terms.html", "contact.html"]: |
|
p = Path(name) |
|
text = p.read_text(encoding="utf-8") |
|
|
|
if '<header class="site-header">' in text: |
|
text = re.sub(r'<header class="site-header">.*?</header>', header, text, count=1, flags=re.S) |
|
elif '<header class="header">' in text: |
|
text = re.sub(r'<header class="header">.*?</header>', header, text, count=1, flags=re.S) |
|
else: |
|
text = text.replace('<body>', '<body>\n' + header, 1) |
|
|
|
if '<div class="otb-statusbar">' in text: |
|
text = re.sub(r'<div class="otb-statusbar">.*?</script>', footer, text, count=1, flags=re.S) |
|
else: |
|
text = text.replace('</body>', footer + '\n</body>', 1) |
|
|
|
p.write_text(text, encoding="utf-8") |
|
|
|
cssp = Path("assets/style.css") |
|
css = cssp.read_text(encoding="utf-8") |
|
if "/* ===== OTB shared branding ===== */" in css: |
|
css = re.sub(r'/\* ===== OTB shared branding ===== \*/.*', brandcss, css, flags=re.S) |
|
else: |
|
css += "\n\n" + brandcss |
|
cssp.write_text(css, encoding="utf-8") |
|
print("mintme deploy complete") |
|
PY2
|
|
|