Add a minifying script fot html files

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@48976 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2017-09-15 13:01:52 +00:00
parent 21ac2eba32
commit 6bcb70dbc4
1 changed files with 36 additions and 0 deletions

36
portal-2/minifyScript Executable file
View File

@ -0,0 +1,36 @@
if [ "$1" != "" ]; then
echo "Find html files in $1";
find $1 -name "*.html" -type f
echo " ";
echo " ";
echo " ";
files=( $(find $1 -name "*.html" -type f) )
echo " Minifying...";
echo " ";
total = 0;
for entry in $(find $1 -name "*.html" -type f)
do
echo
s=$(stat -c%s "$entry");
echo "Size of $entry = $s bytes.";
cat $entry | sed -e :a -re 's/<!--.*?-->//g;/<!--/N;//ba'| awk '{printf "%s",$0} END {print ""}' | tr -s " "> $entry".mini";
n=$entry".mini";
ns=$(stat -c%s "$n");
dif=$((s-ns));
total=$((total+dif));
echo Size of $n = $ns bytes.
done
for entry in $(find $1 -name "*.html" -type f)
do
echo
cat $entry".mini" > $entry;
rm $entry".mini";
done
echo Total size $total
else
echo "Give a path";
fi