tazpanel diff lib/libtazpanel @ 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 | f8e0ae0ac1d9 |
children | 4f619f973b88 |
line diff
1.1 --- a/lib/libtazpanel Tue Aug 18 19:09:02 2015 +0300 1.2 +++ b/lib/libtazpanel Thu Aug 20 17:00:19 2015 +0300 1.3 @@ -12,18 +12,15 @@ 1.4 1.5 _() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; echo; } 1.6 _n() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; } 1.7 -_p() { 1.8 - local S="$1" P="$2" N="$3"; shift 3; 1.9 - printf "$(ngettext "$S" "$P" "$N")" "$@"; } 1.10 1.11 1.12 GUI_USER=nobody 1.13 [ "$HTTP_HOST" == "127.0.0.1:82" ] && 1.14 for i in "$HTTP_COOKIE" "$QUERY_STRING" ; do 1.15 - v="$(echo "$i" | sed '/guiuser=/!d;s/.*guiuser=\([A-Za-z0-9_]*\).*/\1/')" 1.16 - [ "$v" ] || continue 1.17 - busybox ps | sed '/d;/d;/127\.0\.0\.1:82/!d' | grep -q " $v " || continue 1.18 - GUI_USER="$v" 1.19 + v="$(echo "$i" | sed '/guiuser=/!d;s/.*guiuser=\([A-Za-z0-9_]*\).*/\1/')" 1.20 + [ "$v" ] || continue 1.21 + busybox ps | sed '/d;/d;/127\.0\.0\.1:82/!d' | grep -q " $v " || continue 1.22 + GUI_USER="$v" 1.23 done 1.24 [ "$(id -un)" == "${REMOTE_USER:=$GUI_USER}" ] || exec su -s /bin/sh -c "$(realpath $0) $@" $REMOTE_USER 1.25 1.26 @@ -36,9 +33,7 @@ 1.27 # I18n 1.28 1.29 . /etc/locale.conf 1.30 -. /usr/bin/gettext.sh 1.31 -TEXTDOMAIN='tazpanel' 1.32 -export TEXTDOMAIN LANG LC_ALL 1.33 +export TEXTDOMAIN='tazpanel' LANG LC_ALL 1.34 1.35 1.36 # We need a config file first 1.37 @@ -155,7 +150,7 @@ 1.38 if ifconfig | grep -A1 $1 | grep -q inet; then 1.39 ip=$(ifconfig | grep -A1 $1 | grep inet | awk '{ print $2 }' | cut -d: -f2) 1.40 [ "$(cat /sys/class/net/$1/carrier)" == "1" ] && 1.41 - scan="<a data-icon=\"scan\" href='network.cgi?scan=$ip&back=network.cgi'>$(_ 'Scan')</a>" 1.42 + scan='<a data-icon="scan" href="network.cgi?scan='$ip'&back=network.cgi">'$(_ 'Scan')'</a>' 1.43 fi 1.44 [ "$(cat /sys/class/net/$1/carrier)" == "1" ] && 1.45 status="$(_ 'connected')" && 1.46 @@ -184,20 +179,20 @@ 1.47 for i in $(ls /sys/class/net); do 1.48 case $i in 1.49 eth*) 1.50 - echo " <tr><td><a data-icon='eth' href='network.cgi?eth'>$i</a></td> 1.51 - <td>Ethernet</td> $(interface_status $i)</tr>" ;; 1.52 + echo '<tr><td><a data-icon="eth" href="network.cgi?eth">'$i'</a></td> 1.53 + <td>Ethernet</td> '$(interface_status $i)'</tr>';; 1.54 wlan*|ath*|ra*) 1.55 - echo " <tr><td><a data-icon='wifi' href='network.cgi?wifi'>$i</a></td> 1.56 - <td>Wireless</td> $(interface_status $i)</tr>" ;; 1.57 + echo '<tr><td><a data-icon="wifi" href="network.cgi?wifi">'$i'</a></td> 1.58 + <td>Wireless</td> '$(interface_status $i)'</tr>';; 1.59 ppp*) 1.60 - echo " <tr><td><a data-icon='removable' href='ppp.cgi'>$i</a></td> 1.61 - <td>Point to point</td> $(interface_status $i)</tr>" ;; 1.62 + echo '<tr><td><a data-icon="removable" href="ppp.cgi">'$i'</a></td> 1.63 + <td>Point to point</td> '$(interface_status $i)'</tr>';; 1.64 tap[0-9]*|tun[0-9]*) 1.65 - echo " <tr><td><span data-icon='removable'>$i</span></td> 1.66 - <td>User space</td> $(interface_status $i)</tr>" ;; 1.67 + echo '<tr><td><span data-icon="removable">'$i'</span></td> 1.68 + <td>User space</td> '$(interface_status $i)'</tr>';; 1.69 lo) 1.70 - echo " <tr><td><span data-icon='loopback'>$i</span></td> 1.71 - <td>Loopback</td> $(interface_status $i)</tr>" ;; 1.72 + echo '<tr><td><span data-icon="loopback">'$i'</span></td> 1.73 + <td>Loopback</td> '$(interface_status $i)'</tr>';; 1.74 *) 1.75 continue ;; 1.76 esac 1.77 @@ -224,7 +219,7 @@ 1.78 list_locales() { 1.79 for locale in $(find /usr/share/i18n/locales -type f -name "[a-z][a-z]_[A-Z][A-Z]") 1.80 do 1.81 - echo "<option value='$locale'>$locale</option>" 1.82 + echo "<option value=\"$locale\">$locale</option>" 1.83 done 1.84 } 1.85 1.86 @@ -232,10 +227,12 @@ 1.87 # Get the list of console keymaps 1.88 1.89 list_keymaps() { 1.90 - if [ -d /usr/share/kbd ]; then # kbd-base 1.91 + if [ -d /usr/share/kbd ]; then 1.92 + # kbd-base 1.93 find /usr/share/kbd/keymaps/i386 -type f -name '*.map*' ! -path '*include*' | \ 1.94 awk -F/ '{gsub(/.map.gz/, ""); printf "<option value=\"%s\">%s (%s)\n", $8, $8, $7}' 1.95 - else # kbd-busybox 1.96 + else 1.97 + # kbd-busybox 1.98 ls /usr/share/kmap/*.kmap | \ 1.99 sed 's|.*kmap/\(.*\).kmap|<option value="\1">\1|' 1.100 fi | sort 1.101 @@ -247,6 +244,7 @@ 1.102 # 1.103 1.104 loading_msg() { 1.105 + [ -n "$(GET noheader)" ] && return 1.106 local MSG=${1:-$LOADING_MSG} 1.107 [ -z "$MSG" ] && MSG="$(_ 'Please wait')" 1.108 cat <<EOT 1.109 @@ -256,6 +254,7 @@ 1.110 1.111 1.112 xhtml_header() { 1.113 + [ -n "$(GET noheader)" ] && return 1.114 SUBTITLE="$1" 1.115 . ${PANEL}$HEADER 1.116 cat <<EOT 1.117 @@ -293,6 +292,7 @@ 1.118 1.119 1.120 xhtml_footer() { 1.121 + [ -n "$(GET noheader)" ] && return 1.122 export TEXTDOMAIN='tazpkg' 1.123 . ${PANEL}$FOOTER 1.124 } 1.125 @@ -323,15 +323,13 @@ 1.126 msg() { 1.127 msgtype="$1"; shift 1.128 case "$msgtype" in 1.129 - tip) MSG_ICON='msgtip';; 1.130 - warn|warning) MSG_ICON='msgwarn';; 1.131 - err|error) MSG_ICON='msgerr';; 1.132 - up) MSG_ICON='msgup';; 1.133 - *) MSG_ICON='msg';; 1.134 + tip) I='data-icon="msgtip"';; 1.135 + warn|warning) I='data-icon="msgwarn"';; 1.136 + err|error) I='data-icon="msgerr"';; 1.137 + up) I='data-icon="msgup"';; 1.138 + *) I='data-icon="msg"';; 1.139 esac 1.140 - cat <<EOT 1.141 - <section class="box"><span data-icon="$MSG_ICON"></span>$@</section> 1.142 -EOT 1.143 + echo "<section class=\"box\"><span $I></span>$@</section>" 1.144 } 1.145 1.146 1.147 @@ -361,6 +359,7 @@ 1.148 1.149 back_button() { 1.150 local URL="$1" default_caption="$(_ 'Back')" 1.151 + #FIXME: can't encode data-icon 1.152 local caption="${2:-$default_caption}" icon="${3:-back}" 1.153 1.154 if [ -n "$1" ]; then