summaryrefslogtreecommitdiff
path: root/barsup
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2021-06-29 08:30:52 -0400
committerLuke Smith <luke@lukesmith.xyz>2021-06-29 08:30:52 -0400
commit825282fea9102326ad2538e4a98329fbd38c899b (patch)
tree678dd28280fd542242ed041778e353c2ac511ae1 /barsup
firststuffs
Diffstat (limited to 'barsup')
-rwxr-xr-xbarsup18
1 files changed, 18 insertions, 0 deletions
diff --git a/barsup b/barsup
new file mode 100755
index 0000000..71d21d4
--- /dev/null
+++ b/barsup
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Replace existing navs and footers with content of nav and footer files.
+
+navfile="/home/luke/.local/src/landchad/.nav.html"
+footerfile="/home/luke/.local/src/landchad/.footer.html"
+
+files="$(for x in $(find /home/luke/.local/src/landchad -type f -iname '*.html'); do
+ echo "$x"
+done)"
+
+escnav="$(sed "s|^\s\+||;s|/|\\\\/|g;s|\"|\\\\\"|g" "$navfile" 2>/dev/null | tr -d '\n')"
+escfooter="$(sed "s|^\s\+||;s|/|\\\\/|g;s|\"|\\\\\"|g" "$footerfile" 2>/dev/null | tr -d '\n')"
+
+sed -s -i "s/<nav>.*<\/nav>/<nav>$escnav<\/nav>/; s/<footer>.*<\/footer>/<footer>$escfooter<\/footer>/" $files
+
+# Multiline:
+# sed -n -s -i "1h; 1!H; \${ g; s/<nav>.*<\/nav>/<nav>\n$escnav\n\t<\/nav>/g; s/<footer>.*<\/footer>/<footer>\n$escfooter\n\t<\/footer>/p }" $files