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:
parent
21ac2eba32
commit
6bcb70dbc4
|
@ -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
|
Loading…
Reference in New Issue