Files
QBPOS-Help/scripts/add_mobile_nav.sh

59 lines
1.9 KiB
Bash

#!/bin/bash
# Add mobile navigation bar to all HTML files
HELP_DIR="/home/pts/Documents/QBPOS_Help_Web/QB_Help_Web/POS_Help"
echo "Adding mobile navigation to HTML files..."
# 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
if grep -q "mobile-nav.css" "$file"; then
continue
fi
# Add mobile-nav.css link after other CSS files
if grep -q "qbpos.css" "$file" || grep -q "prompttech-header.css" "$file"; then
# Calculate relative path for CSS
rel_path=$(realpath --relative-to="$(dirname "$file")" "$HELP_DIR")
if [ "$rel_path" = "." ]; then
css_path="mobile-nav.css"
else
css_path="${rel_path}/mobile-nav.css"
fi
# Add after the last stylesheet
sed -i "/qbpos\.css/a <link rel=\"StyleSheet\" href=\"${css_path}\" type=\"text/css\">" "$file"
fi
# Add mobile navigation HTML after <body> tag
if ! grep -q "mobile-nav" "$file"; then
# 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
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"
fi
echo "Updated: $file"
done
echo ""
echo "Mobile navigation added to all pages!"
echo ""
echo "Features:"
echo " - Home button (returns to main page)"
echo " - Back button (goes to previous page)"
echo " - Only visible on mobile/tablet devices"