tazpanel diff lib/libtazpanel @ rev 303
3 weeks forging ;) Some bugs fixed, maybe all i18n improved (please, recheck 'po's!), couple of new features added... Enjoy!
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri May 04 13:00:43 2012 +0300 (2012-05-04) |
parents | 72e9955ebdff |
children | b3c93e4a8acc |
line diff
1.1 --- a/lib/libtazpanel Wed Apr 11 20:12:41 2012 +0300 1.2 +++ b/lib/libtazpanel Fri May 04 13:00:43 2012 +0300 1.3 @@ -22,27 +22,37 @@ 1.4 exit 1 1.5 } 1.6 1.7 +# Display < > & 1.8 +htmlize() { 1.9 + sed -e 's|\&|\&|g; s|<|\<|g; s|>|\>|g' 1.10 +} 1.11 + 1.12 # Syntax highlighting for config file and SHell scripts 1.13 -# HTML entities: -e 's|&|\&|g' -e 's|<|\<|g' -e 's|>|\>|g' 1.14 syntax_highlighter() { 1.15 case $1 in 1.16 conf) 1.17 - sed -e 's|&|\&|g' -e 's|<|\<|g' -e 's|>|\>|g' \ 1.18 + htmlize | sed \ 1.19 -e s"#^\#\([^']*\)#<span class='conf-comment'>\0</span>#"g \ 1.20 -e s"#^[A-Z]\([^']*\)=#<span class='conf-var'>\0</span>#"g \ 1.21 -e s"#^[a-z]\([^']*\)#<span class='conf-var'>\0</span>#"g \ 1.22 -e s"#\"\([^']*\)\"#<span class='conf-val'>\0</span>#"g ;; 1.23 sh) 1.24 - sed -e 's|&|\&|g' -e 's|<|\<|g' -e 's|>|\>|g' \ 1.25 + htmlize | sed \ 1.26 -e s"#^\#\([^']*\)#<span class='sh-comment'>\0</span>#"g \ 1.27 -e s"#\"\([^']*\)\"#<span class='sh-val'>\0</span>#"g ;; 1.28 diff) 1.29 - sed -e 's|&|\&|g' -e 's|<|\<|g' -e 's|>|\>|g' \ 1.30 + htmlize | sed \ 1.31 -e s"#^-\(.*\).#<span class='diff-rm'>\0</span>#"g \ 1.32 -e s"#^+\(.*\).#<span class='diff-add'>\0</span>#"g \ 1.33 -e s"#@@\(.*\)@@#<span class='diff-at'>@@\1@@</span>#"g ;; 1.34 activity) 1.35 - sed s"#^\([^']*:\)#<span class='activity-log''>\0</span>#"g ;; 1.36 + sed -e s"#^\([^']*:\)#<span class='activity-log'>\0</span>#"g ;; 1.37 + kernel) 1.38 + htmlize | sed \ 1.39 + -e "s|\([^0-9]\)\(0x[0-9a-f]\+\)|\1<span class='kernel-hex'>\2</span>|g" \ 1.40 + -e "s|^\([^(,\[]\+: \)|<span class='kernel-id'>\0</span>|g" \ 1.41 + -e "s|\(\[[^ ]\+\]\)|<span class='kernel-id2'>\0</span>|g" ;; 1.42 + 1.43 esac 1.44 } 1.45 1.46 @@ -70,7 +80,7 @@ 1.47 if ifconfig | grep -A 1 $i | grep -q inet; then 1.48 ip=`ifconfig | grep -A 1 $i | grep inet | \ 1.49 awk '{ print $2 }' | cut -d ":" -f 2` 1.50 - echo "<td>connected</td><td>$ip</td>" 1.51 + echo "<td>$(gettext 'connected')</td><td>$ip</td>" 1.52 echo "<td><a href='/network.cgi?scan=$ip'>" 1.53 echo "<img src='$IMAGES/recharge.png' /></a></td>" 1.54 else 1.55 @@ -80,35 +90,41 @@ 1.56 1.57 # Catch network interface (used in summary and network main page) 1.58 list_network_interfaces() { 1.59 - table_start 1.60 cat << EOT 1.61 -<tr id="thead"> 1.62 - <td>`gettext "Interface"`</td> 1.63 - <td>`gettext "Name"`</td> 1.64 - <td>`gettext "Status"`</td> 1.65 - <td>`gettext "IP Address"`</td> 1.66 - <td>`gettext "Scan ports"`</td> 1.67 -</tr> 1.68 +<table class="zebra"> 1.69 + <thead> 1.70 + <tr> 1.71 + <td>$(gettext 'Interface')</td> 1.72 + <td>$(gettext 'Name')</td> 1.73 + <td>$(gettext 'Status')</td> 1.74 + <td>$(gettext 'IP Address')</td> 1.75 + <td>$(gettext 'Scan ports')</td> 1.76 + </tr> 1.77 + </thead> 1.78 + <tbody> 1.79 EOT 1.80 for i in `ls /sys/class/net` 1.81 do 1.82 case $i in 1.83 eth*) 1.84 - echo "<tr><td><a href='/network.cgi?eth'> 1.85 + echo " <tr><td><a href='/network.cgi?eth'> 1.86 <img src='$IMAGES/ethernet.png' />$i</a></td> 1.87 <td>Ethernet</td> $(interface_status)</tr>" ;; 1.88 wlan*|ath*|ra*) 1.89 - echo "<tr><td><a href='/network.cgi?wifi'> 1.90 + echo " <tr><td><a href='/network.cgi?wifi'> 1.91 <img src='$IMAGES/wireless.png' />$i</a></td> 1.92 <td>Wireless</td> $(interface_status)</tr>" ;; 1.93 lo) 1.94 - echo "<tr><td><img src='$IMAGES/loopback.png' />$i</td> 1.95 + echo " <tr><td><img src='$IMAGES/loopback.png' />$i</td> 1.96 <td>Loopback</td> $(interface_status)</tr>" ;; 1.97 *) 1.98 continue ;; 1.99 esac 1.100 done 1.101 - table_end 1.102 + cat << EOT 1.103 + </tbody> 1.104 +</table> 1.105 +EOT 1.106 } 1.107 1.108 # Get the list of panel styles 1.109 @@ -184,29 +200,24 @@ 1.110 } 1.111 1.112 table_start() { 1.113 - cat << EOT 1.114 -<table> 1.115 - <tbody> 1.116 -EOT 1.117 + echo '<table>' 1.118 } 1.119 1.120 table_end() { 1.121 - cat << EOT 1.122 - </tbody> 1.123 -</table> 1.124 -EOT 1.125 - 1.126 + echo '</table>' 1.127 } 1.128 1.129 df_thead() { 1.130 cat << EOT 1.131 <thead> 1.132 <tr> 1.133 - <td>$(gettext "Disk")</td> 1.134 - <td>$(gettext "Size")</td> 1.135 - <td>$(gettext "Available")</td> 1.136 - <td>$(gettext "Used")</td> 1.137 - <td>$(gettext "Mount point")</td> 1.138 + <td>$(gettext 'Disk')</td> 1.139 + <td>$(gettext 'Label')</td> 1.140 + <td>$(gettext 'Type')</td> 1.141 + <td>$(gettext 'Size')</td> 1.142 + <td>$(gettext 'Available')</td> 1.143 + <td>$(gettext 'Used')</td> 1.144 + <td>$(gettext 'Mount point')</td> 1.145 </tr> 1.146 </thead> 1.147 EOT