tazpanel view stripall.sh @ rev 530
index.cgi: add renice support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Aug 28 13:08:26 2015 +0200 (2015-08-28) |
parents | 5323427d34b9 |
children | 694b20d6963c |
line source
1 #!/bin/sh
2 # TazPanel - SliTaz Control Panel, hg.slitaz.org/tazpanel
3 # stripall.sh - strip and compact resources in build process
4 # Copyright (C) 2015 SliTaz GNU/Linux - BSD License
7 substitute_icons() {
8 grep -q 'data-icon="\|data-img"' $1 || return
10 # Customize sed script
11 cp "$sed_script" "$sed_script.do"
12 sed -i "s|@@@|$1|" "$sed_script.do"
13 # Run sed script
14 sh "$sed_script.do"
15 rm "$sed_script.do"
16 }
19 # Make script for substitution
20 sed_script="$(mktemp)"
21 echo -n "sed -i '" > "$sed_script"
22 echo -e "\
23 add \n admin \n back \n battery
24 brightness \n cancel \n cd \n check
25 clock \n conf \n daemons \n delete
26 detect \n diff \n download \n edit
27 eth \n group \n grub \n hdd
28 help \n history \n info \n install
29 link \n list \n locale \n lock
30 logs \n loopback \n modules \n ok
31 proc \n refresh \n removable \n remove
32 repack \n report \n restart \n run
33 save \n scan \n settings \n start
34 stop \n sync \n tag \n tags
35 tazx \n temperature \n terminal \n text
36 unlink \n unlock \n upgrade \n user
37 view \n wifi \n man \n off
38 on \n opt \n web \n slitaz
39 lvl0 \n lvl1 \n lvl2 \n lvl3
40 lvl4 \n lvl5 \n online \n offline
41 sechi \n secmi \n seclo \n pkg
42 pkgi \n pkgib \n toggle \n chlock
43 calendar \n modem \n cpu \n display
44 msg \n msgerr \n msgwarn \n msgup
45 msgtip \n vpn " | \
46 while read icon symbol; do
47 echo -n "s|data-icon=\"$icon\"|data-icon=\"$symbol\"|g; " >> "$sed_script"
48 echo -n "s|data-img=\"$icon\"|data-img=\"$symbol\"|g; " >> "$sed_script"
49 done
50 echo "' @@@" >> "$sed_script"
53 cd build
55 echo -e "\nStrip shell scripts"
56 for CGI in *.cgi tazpanel libtazpanel bootloader *.html; do
57 echo "Processing $CGI"
59 mv $CGI $CGI.old
60 # Copy initial comment (down to empty line)
61 sed '1,/^$/!d' $CGI.old > $CGI
62 # Remove initial tabs, other comments and empty lines
63 sed 's|^[\t ]*||;/^#/d;/^$/d' $CGI.old >> $CGI
64 rm $CGI.old
66 substitute_icons $CGI
68 sed -i 's|" *>|">|g' $CGI
69 sed -i "s|' *)|')|g" $CGI
70 sed -i 's| *;;|;;|g' $CGI
72 chmod a+x $CGI
74 done
77 echo -e "\n\nStrip CSS stylesheets"
78 for CSS in *.css; do
79 echo "Processing $CSS"
81 mv $CSS $CSS.old
82 tr '\n' ' ' < $CSS.old > $CSS
83 rm $CSS.old
85 substitute_icons $CSS
87 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
88 done
90 mkdir gz
91 cat *.css > gz/tazpanel.css
92 gzip -9 gz/tazpanel.css
95 echo -e "\n\nStrip JS scripts"
96 for JS in *.js; do
97 echo -en "\nProcessing $JS"
99 sed -i 's|^[\t ]*||; /^$/d; /^\/\//d; /console\./d' $JS
101 # Try "jsmin"
102 if [ -n "$(which jsmin)" ]; then
103 jsmin < $JS > $JS.new
104 mv -f $JS.new $JS
105 fi
106 done
108 cat *.js > gz/tazpanel.js
109 gzip -9 gz/tazpanel.js
111 rm "$sed_script"
112 echo