#!/bin/bash # This example script can be used to compact a skin (pastel by default) # It uses CSS sprite and remove spaces in HTML # Note: it must be launched in the skin dir NAME=img SRC=pastel DST=pastel-compact rm -rf $NAME $DST mkdir $NAME $DST find $SRC/ -type f -iname '*.css' -exec cat {} \; | \ perl -ne 'if(m#\@import url\(\s*"[\./]+(.*?.css)"#){print `cat $1`}else{print}' \ | perl -pe 'if(!s#url\s*\(\s*"?(?:\.\./)?(\.\./common/[^\)"]*)"?\s*\)#url\("$1")#){ if(s#url\s*\(\s*"?(?:.*?/)?([\w\-]+\.(?:png|gif|jpe?g))"?\s*\)#url\("$1")#){ $name=$1; $img=`find '$SRC'/ -type f -name $name`; chomp $img; if($img){ `cp $img '$DST'`; } else{ $img=`find common/ -type f -name $name`; chomp $img; if($img){ s#url\("#url\("../common/#; } else { print STDERR "$name not found\n"; } } } }'>styles2.css LIST=$(find $SRC -type f -iname '*.tpl') for L in $LIST; do perl -ne 's/^\s+//; s/\s*$/\n/s; next if(/^$/); $j=1 if(m#]* (?:]*>)?[^>]*? ((?:\w+|))(\.(?:png|gif|jpe?g))[^>]*> /
<\/div>/xg){ my $img=$1.$2; chomp $img; unless($img=~/^$/) { $ind=1; } elsif((/^$/) { $ind=0; } elsif(!/^<\?xml/i and !m#^//# and !$j) { chomp; } print "\n" if(m#^${L/$SRC/$DST} done LIST=$(find $SRC -type l -iname '*.tpl') for L in $LIST; do echo "####### $L" cp -d $L $DST done AUTHLIST=$(ls /usr/share/perl5/Lemonldap/NG/Portal/Auth*|sed -e 's/.*\/Auth/common\//' -e 's/\.pm/\.png/') for FILE in $AUTHLIST; do [ -e $FILE ] && cp $FILE $NAME done glue-sprite $NAME $DST find $DST/ -type f -iname '*.css' -exec cat {} \; -delete >styles.css cat styles.css styles2.css > $DST/styles.css rm -f styles.css styles2.css rm -rf $NAME