tazpanel view stripall.sh @ rev 588
Un-fuzzy already translated messages; finish ru.po translations
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Wed Apr 20 11:36:15 2016 +0300 (2016-04-20) |
parents | 694b20d6963c |
children |
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 # Customize sed script
9 cp "$sed_script" "$sed_script.do"
10 sed -i "s|@@@|$1|" "$sed_script.do"
11 # Run sed script
12 sh "$sed_script.do"
13 rm "$sed_script.do"
14 }
17 # Make script for substitution
18 sed_script="$(mktemp)"
19 echo -n "sed -i '" > "$sed_script"
20 echo -e "\
21 add \n admin \n back \n battery
22 brightness \n cancel \n cd \n check
23 clock \n conf \n daemons \n delete
24 detect \n diff \n download \n edit
25 eth \n group \n grub \n hdd
26 help \n history \n info \n install
27 link \n list \n locale \n lock
28 logs \n loopback \n modules \n ok
29 proc \n refresh \n removable \n remove
30 repack \n report \n restart \n run
31 save \n scan \n settings \n start
32 stop \n sync \n tag \n tags
33 tazx \n temperature \n terminal \n text
34 unlink \n unlock \n upgrade \n user
35 view \n wifi \n man \n off
36 on \n opt \n web \n slitaz
37 lvl0 \n lvl1 \n lvl2 \n lvl3
38 lvl4 \n lvl5 \n online \n offline
39 sechi \n secmi \n seclo \n pkg
40 pkgi \n pkgib \n toggle \n chlock
41 calendar \n modem \n cpu \n display
42 msg \n msgerr \n msgwarn \n msgup
43 msgtip \n vpn \n floppy \n folder " | \
44 while read icon symbol; do
45 echo -n "s|@$icon@|$symbol|g; " >> "$sed_script"
46 done
47 echo "' @@@" >> "$sed_script"
50 cd build
52 echo -e "\nStrip shell scripts"
53 for CGI in *.cgi tazpanel libtazpanel bootloader *.html; do
54 echo "Processing $CGI"
56 case $CGI in
57 tazpanel.*.html)
58 # doc/tazpanel.*.html
59 substitute_icons $CGI
60 if [ -n "$(which tidy)" ]; then
61 tidy -m -q -w 0 -utf8 --show-body-only y --quote-nbsp n $CGI
62 else
63 sed -i 's|[ ][ ]*| |g; s|^ ||' $CGI
64 fi
65 ;;
66 *)
67 mv $CGI $CGI.old
68 # Copy initial comment (down to empty line)
69 sed '1,/^$/!d' $CGI.old > $CGI
70 # Remove initial tabs, other comments and empty lines
71 sed 's|^[\t ]*||;/^#/d;/^$/d' $CGI.old >> $CGI
72 rm $CGI.old
74 substitute_icons $CGI
76 sed -i 's|" *>|">|g' $CGI
77 sed -i "s|' *)|')|g" $CGI
78 sed -i 's| *;;|;;|g' $CGI
80 chmod a+x $CGI
81 ;;
82 esac
84 done
87 echo -e "\n\nStrip CSS stylesheets"
88 for CSS in *.css; do
89 echo "Processing $CSS"
91 mv $CSS $CSS.old
92 tr '\n' ' ' < $CSS.old > $CSS
93 rm $CSS.old
95 substitute_icons $CSS
97 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
98 done
100 mkdir gz
101 cat *.css > gz/tazpanel.css
102 gzip -9 gz/tazpanel.css
105 echo -e "\n\nStrip JS scripts"
106 for JS in *.js; do
107 echo -en "\nProcessing $JS"
109 substitute_icons $JS
110 sed -i 's|^[\t ]*||; /^$/d; /^\/\//d; /console\./d' $JS
112 # Try "jsmin"
113 if [ -n "$(which jsmin)" ]; then
114 jsmin < $JS > $JS.new
115 mv -f $JS.new $JS
116 fi
117 done
119 cat *.js > gz/tazpanel.js
120 gzip -9 gz/tazpanel.js
122 rm "$sed_script"
123 echo