tazpanel diff index.cgi @ rev 501

*.cgi: Implement TazPanel title and sub-title; hardware.cgi: fix and improve modules search; index.cgi: complex code using awk was prevented 'make pot' to collect all messages, fix terminal history removing; tazpanel.js: disable buttons when no packages selected (pkgs.cgi: up / search / category lists); network.cgi: complex comment was prevented 'make pot' to collect all messages; powersaving.cgi: starting development; *.po: rebuild; tazpanel.ttf: add messages icons, so remove all the style/png images and change libtazpanel; *.css: title and sub-title, messages icons; test.cgi: add new icons.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Jun 08 04:32:19 2015 +0300 (2015-06-08)
parents de34ca9d1417
children a8ff72f76e0d
line diff
     1.1 --- a/index.cgi	Fri May 01 23:56:00 2015 +0200
     1.2 +++ b/index.cgi	Mon Jun 08 04:32:19 2015 +0300
     1.3 @@ -13,7 +13,7 @@
     1.4  . lib/libtazpanel
     1.5  get_config
     1.6  
     1.7 -TITLE="TazPanel"
     1.8 +TITLE='TazPanel'
     1.9  
    1.10  
    1.11  
    1.12 @@ -41,7 +41,6 @@
    1.13  }
    1.14  
    1.15  
    1.16 -
    1.17  # OK status in table
    1.18  
    1.19  ok_status_t() {
    1.20 @@ -74,7 +73,7 @@
    1.21  	*\ exec\ *)
    1.22  		# Execute command and display its result in a terminal-like window
    1.23  
    1.24 -		header; TITLE=$(_ 'TazPanel - exec'); xhtml_header
    1.25 +		header; xhtml_header "$(_ 'exec')"
    1.26  
    1.27  		exec="$(GET exec)"
    1.28  		font="${TERM_FONT:-monospace}"
    1.29 @@ -107,7 +106,7 @@
    1.30  			*.html)
    1.31  				cat $file; exit 0 ;;
    1.32  			*)
    1.33 -				TITLE=$(_ 'TazPanel - File'); xhtml_header ;;
    1.34 +				xhtml_header "$(_ 'File')";;
    1.35  		esac
    1.36  
    1.37  		case "$action" in
    1.38 @@ -223,7 +222,7 @@
    1.39  	*\ terminal\ *|*\ cmd\ *)
    1.40  		# Cmdline terminal
    1.41  
    1.42 -		header; TITLE=$(_ 'TazPanel - Terminal'); xhtml_header
    1.43 +		header; xhtml_header "$(_ 'Terminal')"
    1.44  
    1.45  		user="$REMOTE_USER"
    1.46  		HOME="$(awk -F: -vu=$user '$1==u{print $6}' /etc/passwd)"
    1.47 @@ -251,18 +250,20 @@
    1.48  		<input type="hidden" name="path" value="$path"/>
    1.49  		<pre class="term $palette" style="font-family: '$font'">
    1.50  EOT
    1.51 -			htmlize < $historyfile | awk -vrun="$(_ 'run')" -vpath="$path" '
    1.52 -			BEGIN { num=1 }
    1.53 -			{
    1.54 -			printf("%3d ", num);
    1.55 -			cmd = $0
    1.56 -			gsub("%",  "%25", cmd); gsub("+",  "%2B", cmd); gsub(" ",    "+",   cmd);
    1.57 -			gsub("\"", "%22", cmd); gsub("!",  "%21", cmd); gsub("'\''", "%27", cmd);
    1.58 -			printf("<a data-icon=\"run\" href=\"?cmd=%s&path=%s\">%s</a> ", cmd, path, run);
    1.59 -			printf("<input type=\"checkbox\" name=\"rm\" value=\"%d\" id=\"hist%d\">", num, num);
    1.60 -			printf("<label for=\"hist%d\">%s</label>\n", num, $0);
    1.61 -			num++
    1.62 -			}'
    1.63 +
    1.64 +			htmlize < $historyfile | awk -vrun="$(_ 'run')" -vpath="$path" -vq="'" '
    1.65 +BEGIN { num = 1; }
    1.66 +{
    1.67 +	printf("%3d ", num);
    1.68 +	cmd = $0;
    1.69 +	gsub("%",  "%25", cmd); gsub("+",  "%2B", cmd); gsub(" ",    "+",   cmd);
    1.70 +	gsub("\"", "%22", cmd); gsub("!",  "%21", cmd); gsub(q, "%27", cmd);
    1.71 +	printf("<a data-icon=\"run\" href=\"?cmd=%s&path=%s\">%s</a> ", cmd, path, run);
    1.72 +	printf("<input type=\"checkbox\" name=\"rm\" value=\"%d\" id=\"hist%d\">", num, num);
    1.73 +	printf("<label for=\"hist%d\">%s</label>\n", num, $0);
    1.74 +	num++;
    1.75 +}'
    1.76 +
    1.77  			cat <<EOT
    1.78  		</pre>
    1.79  		<footer>
    1.80 @@ -294,7 +295,7 @@
    1.81  			_ 'Run any command at your own risk, avoid interactive commands (%s)' 'nano, mc, ...'; echo
    1.82  			;;
    1.83  		wget*)
    1.84 -			dl=/var/cache/downloads
    1.85 +			dl='/var/cache/downloads'
    1.86  			[ ! -d "$dl" ] && mkdir -p $dl
    1.87  			_ 'Downloading to: %s' $dl; echo
    1.88  			cd $dl; $cmd 2>&1 ;;
    1.89 @@ -357,7 +358,7 @@
    1.90  	*\ rmhistory\ *)
    1.91  		# Manage shell commandline history
    1.92  		user="$REMOTE_USER"
    1.93 -		[ -z "$HOME" ] && HOME="$(awk -F: -vu=$user '$1==u{print $6}' /etc/passwd)"
    1.94 +		HOME="$(awk -F: -vu="$user" '$1==u{print $6}' /etc/passwd)"
    1.95  		historyfile="$HOME/.ash_history"
    1.96  
    1.97  		# Return sed command for removing history lines ('8d12d' to remove 8 and 12 lines)
    1.98 @@ -375,7 +376,7 @@
    1.99  
   1.100  	*\ termsettings\ *)
   1.101  		# Terminal settings
   1.102 -		TITLE=$(_ 'TazPanel - Terminal'); header; xhtml_header;
   1.103 +		header; xhtml_header "$(_ 'Terminal')"
   1.104  		user="$REMOTE_USER"
   1.105  		font="$(GET font)"; font="${font:-$TERM_FONT}"
   1.106  		palette="$(GET palette)"; palette="${palette:-$TERM_PALETTE}"
   1.107 @@ -441,7 +442,7 @@
   1.108  
   1.109  
   1.110  	*\ top\ *)
   1.111 -		header; TITLE=$(_ 'TazPanel - Process activity'); xhtml_header
   1.112 +		header; xhtml_header "$(_ 'Process activity')"
   1.113  
   1.114  		r=$(GET refresh)
   1.115  		cat <<EOT
   1.116 @@ -469,7 +470,7 @@
   1.117  
   1.118  
   1.119  	*\ debug\ *)
   1.120 -		header; TITLE=$(_ 'TazPanel - Debug'); xhtml_header
   1.121 +		header; xhtml_header "$(_ 'Debug')"
   1.122  
   1.123  		cat <<EOT
   1.124  <h2>$(_ 'HTTP Environment')</h2>
   1.125 @@ -484,13 +485,12 @@
   1.126  
   1.127  
   1.128  	*\ report\ *)
   1.129 -		header; TITLE=$(_ 'TazPanel - System report'); xhtml_header
   1.130 +		header; xhtml_header "$(_ 'System report')"
   1.131  
   1.132 -		[ -d /var/cache/slitaz ] || mkdir -p /var/cache/slitaz
   1.133 -		output=/var/cache/slitaz/sys-report.html
   1.134 +		[ -d '/var/cache/slitaz' ] || mkdir -p /var/cache/slitaz
   1.135 +		output='/var/cache/slitaz/sys-report.html'
   1.136  
   1.137  		cat <<EOT
   1.138 -
   1.139  <section>
   1.140  	<header>$(_ 'Reporting to: %s' "$output")</header>
   1.141  	<table class="wide zebra">
   1.142 @@ -620,15 +620,12 @@
   1.143  		#
   1.144  		# Default xHTML content
   1.145  		#
   1.146 -		header; xhtml_header
   1.147 +		header; xhtml_header "$(_ 'SliTaz administration and configuration Panel')"
   1.148  		[ -n "$(GET gen_locale)" ] && new_locale=$(GET gen_locale)
   1.149  		[ -n "$(GET rdate)" ] && echo ""
   1.150  		hostname=$(hostname)
   1.151  
   1.152  		cat <<EOT
   1.153 -<h2>$(_ 'Host: %s' $hostname)</h2>
   1.154 -<p>$(_ 'SliTaz administration and configuration Panel')<p>
   1.155 -
   1.156  <form class="nogap"><!--
   1.157  	--><button name="terminal" data-icon="terminal">$(_ 'Terminal')</button><!--
   1.158  	--><button name="top"      data-icon="proc"    >$(_ 'Process activity')</button><!--
   1.159 @@ -638,6 +635,7 @@
   1.160  <section>
   1.161  	<header>$(_ 'Summary')</header>
   1.162  	<table>
   1.163 +		<tr><td>$(_ 'Host:')</td><td>$hostname</td></tr>
   1.164  		<tr><td>$(_ 'Uptime:')</td>
   1.165  			<td id="uptime">$(uptime | sed 's|\([0-9.:][0-9.:]*\)|<b>\1</b>|g')</td>
   1.166  		</tr>