Files
QBPOS-Help/scripts/add_mobile_nav_html.sh

40 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2026-01-27 18:07:54 -06:00
#!/bin/bash
# Add mobile navigation HTML to all body tags
HELP_DIR="/home/pts/Documents/QBPOS_Help_Web/QB_Help_Web/POS_Help"
echo "Adding mobile navigation HTML to body tags..."
# Find all .htm and .html files
find "$HELP_DIR" -type f \( -name "*.htm" -o -name "*.html" \) | while read -r file; do
# Skip if already has mobile-nav div
if grep -q '<div class="mobile-nav">' "$file"; then
continue
fi
# Calculate relative path to home based on file location
rel_path=$(realpath --relative-to="$(dirname "$file")" "$HELP_DIR")
if [ "$rel_path" = "." ]; then
home_link="___left.htm"
else
home_link="${rel_path}/___left.htm"
fi
# Add mobile navigation after <body> or <body ...> tag
sed -i "/<body[^>]*>/I {
a\\
<div class=\"mobile-nav\">\\
<div class=\"mobile-nav-content\">\\
<a href=\"${home_link}\" class=\"home-btn\">🏠 Home</a>\\
<span class=\"site-title\">QB POS Help</span>\\
<a href=\"javascript:history.back()\" class=\"back-btn\">← Back</a>\\
</div>\\
</div>
}" "$file"
echo "Updated: $(basename $file)"
done
echo ""
echo "✅ Mobile navigation added!"