misc/theme-flexcolor: inject css into files that are cache safe

This is a bit weird, but lets us inline the branding CSS and the
cache invalidation for CSS works fine.
This commit is contained in:
Franco Fichtner 2025-11-22 14:13:11 +01:00
parent a696ef090f
commit 9ebf053b8e
10 changed files with 12 additions and 5 deletions

View file

@ -22,13 +22,20 @@ CACHEMARKER="/usr/local/opnsense/www/index.php"
flexcolor_start()
{
SELECTEDCSS="${SCHEMESDIR}/${flexcolor_theme}/${DEFAULTCSS}"
if [ ! -f "${SELECTEDCSS}" ]; then
warn "The theme '${flexcolor_theme}' was not found."
return
fi
if [ -f "${SELECTEDCSS}" ]; then
cp "${SELECTEDCSS}" "${TARGETDIR}/${DEFAULTCSS}"
for FILE in $(find ${TARGETDIR} -name "*.sample"); do
FILE=${FILE%.sample}
cp ${FILE}.sample ${FILE}
sed -i '' -e "/@import url('default_scheme.css');/r ${SELECTEDCSS}" ${FILE}
sed -i '' -e "/@import url('default_scheme.css');/d" ${FILE}
done
if [ -f "${CACHEMARKER}" ]; then
touch "${CACHEMARKER}"
fi
if [ -f "${CACHEMARKER}" ]; then
touch "${CACHEMARKER}"
fi
}