tazpanel diff stripall.sh @ rev 525
Add "noheader" flag to get page without header/footer/panel "wrappers" (for pop-ups); strip, minify and gzip scripts and styles.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Aug 20 17:00:19 2015 +0300 (2015-08-20) |
parents | |
children | 4f619f973b88 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/stripall.sh Thu Aug 20 17:00:19 2015 +0300 1.3 @@ -0,0 +1,100 @@ 1.4 +#!/bin/sh 1.5 +# TazPanel - SliTaz Control Panel, hg.slitaz.org/tazpanel 1.6 +# stripall.sh - strip and compact resources in build process 1.7 +# Copyright (C) 2015 SliTaz GNU/Linux - BSD License 1.8 + 1.9 + 1.10 +substitute_icons() { 1.11 + grep -q 'data-icon="\|data-img"' $1 || return 1.12 + 1.13 + echo -e "\ 1.14 + add \n admin \n back \n battery 1.15 + brightness \n cancel \n cd \n check 1.16 + clock \n conf \n daemons \n delete 1.17 + detect \n diff \n download \n edit 1.18 + eth \n group \n grub \n hdd 1.19 + help \n history \n info \n install 1.20 + link \n list \n locale \n lock 1.21 + logs \n loopback \n modules \n ok 1.22 + proc \n refresh \n removable \n remove 1.23 + repack \n report \n restart \n run 1.24 + save \n scan \n settings \n start 1.25 + stop \n sync \n tag \n tags 1.26 + tazx \n temperature \n terminal \n text 1.27 + unlink \n unlock \n upgrade \n user 1.28 + view \n wifi \n man \n off 1.29 + on \n opt \n web \n slitaz 1.30 + lvl0 \n lvl1 \n lvl2 \n lvl3 1.31 + lvl4 \n lvl5 \n online \n offline 1.32 + sechi \n secmi \n seclo \n pkg 1.33 + pkgi \n pkgib \n toggle \n chlock 1.34 + calendar \n modem \n cpu \n display 1.35 + msg \n msgerr \n msgwarn \n msgup 1.36 + msgtip \n vpn " | \ 1.37 + while read icon symbol; do 1.38 + echo -n "." 1.39 + sed -i "s|data-icon=\"$icon\"|data-icon=\"$symbol\"|g" $1 1.40 + sed -i "s|data-img=\"$icon\"|data-img=\"$symbol\"|g" $1 1.41 + done 1.42 +} 1.43 + 1.44 + 1.45 +cd build 1.46 + 1.47 +echo -e "\nStrip shell scripts" 1.48 +for CGI in *.cgi tazpanel libtazpanel bootloader *.html; do 1.49 + echo -en "\nProcessing $CGI" 1.50 + 1.51 + mv $CGI $CGI.old 1.52 + # Copy initial comment (down to empty line) 1.53 + sed '1,/^$/!d' $CGI.old > $CGI 1.54 + # Remove initial tabs, other comments and empty lines 1.55 + sed 's|^[\t ]*||;/^#/d;/^$/d' $CGI.old >> $CGI 1.56 + rm $CGI.old 1.57 + 1.58 + substitute_icons $CGI 1.59 + 1.60 + sed -i 's|" *>|">|g' $CGI 1.61 + sed -i "s|' *)|')|g" $CGI 1.62 + sed -i 's| *;;|;;|g' $CGI 1.63 + 1.64 + chmod a+x $CGI 1.65 + 1.66 +done 1.67 + 1.68 + 1.69 +echo -e "\n\nStrip CSS stylesheets" 1.70 +for CSS in *.css; do 1.71 + echo -en "\nProcessing $CSS" 1.72 + 1.73 + mv $CSS $CSS.old 1.74 + tr '\n' ' ' < $CSS.old > $CSS 1.75 + rm $CSS.old 1.76 + 1.77 + substitute_icons $CSS 1.78 + 1.79 + sed -i 's|\t| |g; s| *| |g; s|/\*|‹|g; s|\*/|›|g; s|‹[^›][^›]*›||g; s| *| |g; s|^ ||; s| {|{|g; s|{ |{|g; s| *: *|:|g; s| *; *|;|g; s|;}|}|g; s|} |}|g; s| *> *|>|g; s| *, *|,|g; s|000000|000|g; s|CC0000|C00|g; s|00FFFF|0FF|g' $CSS 1.80 +done 1.81 + 1.82 +mkdir gz 1.83 +cat *.css > gz/tazpanel.css 1.84 +gzip -9 gz/tazpanel.css 1.85 + 1.86 + 1.87 +echo -e "\n\nStrip JS scripts" 1.88 +for JS in *.js; do 1.89 + echo -en "\nProcessing $JS" 1.90 + 1.91 + sed -i 's|^[\t ]*||; /^$/d; /^\/\//d; /console\./d' $JS 1.92 + 1.93 + # Try "jsmin" 1.94 + if [ -n "$(which jsmin)" ]; then 1.95 + jsmin < $JS > $JS.new 1.96 + mv -f $JS.new $JS 1.97 + fi 1.98 +done 1.99 + 1.100 +cat *.js > gz/tazpanel.js 1.101 +gzip -9 gz/tazpanel.js 1.102 + 1.103 +echo