tazpanel rev 9

improve tazpkg.cgi and fix some CSS issues
author Christophe Lincoln <pankso@slitaz.org>
date Sat Apr 02 17:35:09 2011 +0200 (2011-04-02)
parents ab6120f11be4
children 0ca11f2550ef
files styles/default/style.css tazpkg.cgi
line diff
     1.1 --- a/styles/default/style.css	Sat Apr 02 13:55:29 2011 +0200
     1.2 +++ b/styles/default/style.css	Sat Apr 02 17:35:09 2011 +0200
     1.3 @@ -3,9 +3,9 @@
     1.4  */
     1.5  
     1.6  html { min-height:  102%; }
     1.7 -body { padding: 40px 80px; font: 13px sans; }
     1.8 -h1 { color: #4d4d4d; border-bottom: 1px dotted #ddd; }
     1.9 -h2 { color: #444; }
    1.10 +body { padding: 20px 80px; font: 13px sans; }
    1.11 +h1 { color: #d66018; border-bottom: 1px dotted #ddd; }
    1.12 +h2 { color: #444; margin: 0 0 60px; }
    1.13  h3 { color: #666; font-size: 140%; }
    1.14  h4 { color: #888; font-size: 120%; }
    1.15  img { border: 0pt none; vertical-align: middle; padding: 0 6px 0 0;}
    1.16 @@ -19,9 +19,11 @@
    1.17  	background-color: #f8f8f8; 
    1.18  	border: 1px solid #ddd; 
    1.19  	padding: 10px;
    1.20 +	margin: 10px 0;
    1.21  	overflow: auto;
    1.22  }
    1.23  
    1.24 +
    1.25  input[type=submit] {
    1.26  	padding: 2px 4px;
    1.27  	background-color: #f1f1f1;
    1.28 @@ -36,33 +38,31 @@
    1.29  
    1.30  input[type=text] { height: 16px; }
    1.31  
    1.32 -table {
    1.33 -	background-color: #f8f8f8;
    1.34 -	border: 1px solid #ddd;
    1.35 -	margin: 10px 0 0;
    1.36 -	padding: 10px 10px 10px 0;
    1.37 -	width: 100%;
    1.38 -}
    1.39 -
    1.40 -.search { float: right; }
    1.41 -.search p { margin: -1px; }
    1.42 +/* Blocks */
    1.43  
    1.44  #list { margin: 20px 0 0; }
    1.45  
    1.46 -td.pkg { max-width: 160px; }
    1.47 -td.desc { max-width: 300px; }
    1.48 +#block { float: left; }
    1.49  
    1.50 -#thead, thead {
    1.51 -	height: 10px;
    1.52 -	font-weight: bold;
    1.53 -}
    1.54 -
    1.55 -#block { float: left; }
    1.56 +#sub_block { margin: 50px 0 20px; }
    1.57  
    1.58  /* Content */
    1.59  
    1.60 -#content { margin: 60px 0 0 }
    1.61 +#content { margin: 0; }
    1.62  
    1.63 +.search {
    1.64 +	position: absolute;
    1.65 +	right: 87px;
    1.66 +	top: 214px;
    1.67 +}
    1.68 +
    1.69 +#actions {
    1.70 +	position: absolute;
    1.71 +	left: 86px;
    1.72 +	top: 212px;
    1.73 +}
    1.74 +
    1.75 +#actions p { padding: 0; }
    1.76  .box {
    1.77  	margin: 10px 0;
    1.78  	padding: 12px;
    1.79 @@ -76,6 +76,22 @@
    1.80  	border: 1px solid #ddd;
    1.81  }
    1.82  
    1.83 +table {
    1.84 +	background-color: #f8f8f8;
    1.85 +	border: 1px solid #ddd;
    1.86 +	margin: 0;
    1.87 +	padding: 10px 10px 10px 0;
    1.88 +	width: 100%;
    1.89 +}
    1.90 +
    1.91 +td.pkg { max-width: 160px; }
    1.92 +td.desc { max-width: 300px; }
    1.93 +
    1.94 +#thead, thead {
    1.95 +	height: 10px;
    1.96 +	font-weight: bold;
    1.97 +}
    1.98 +
    1.99  /* Round corner */
   1.100  table, pre, input[type=submit], .debug, .box {
   1.101  	-moz-border-radius: 4px;
     2.1 --- a/tazpkg.cgi	Sat Apr 02 13:55:29 2011 +0200
     2.2 +++ b/tazpkg.cgi	Sat Apr 02 17:35:09 2011 +0200
     2.3 @@ -22,14 +22,6 @@
     2.4  
     2.5  # xHTML 5 header
     2.6  cat $HEADER | sed s'/%TITLE%/Tazpkg/'
     2.7 -cat << EOT
     2.8 -<form class="search" method="get" action="$SCRIPT_NAME">
     2.9 -	<p>
    2.10 -		`gettext "Search":`
    2.11 -		<input type="text" name="search" size="20">
    2.12 -	</p>
    2.13 -</form>
    2.14 -EOT
    2.15  
    2.16  # DEBUG mode
    2.17  [ $DEBUG == "1" ] && echo "<p class='debug'>$REQUEST_METHOD ${QUERY_STRING}</p>"
    2.18 @@ -43,8 +35,7 @@
    2.19  		vers=$(echo $line | cut -d "|" -f 2)
    2.20  		desc=$(echo $line | cut -d "|" -f 3)
    2.21  		web=$(echo $line | cut -d "|" -f 5)
    2.22 -		imgs=styles/$STYLE/images
    2.23 -		if [ -d installed/$pkg ]; then
    2.24 +		if [ -d $INSTALLED/$pkg ]; then
    2.25  			echo -e "<td><input type='checkbox' name='pkg' value=\"$pkg\">\n
    2.26  				<img src='$IMAGES/tazpkg-installed.png'/>$pkg</td>"
    2.27  		else
    2.28 @@ -83,6 +74,19 @@
    2.29  # xHTML functions
    2.30  #
    2.31  
    2.32 +search_form() {
    2.33 +	cat << EOT
    2.34 +<div class="search">
    2.35 +<form method="get" action="$SCRIPT_NAME">
    2.36 +	<p>
    2.37 +		`gettext "Search":`
    2.38 +		<input type="text" name="search" size="20">
    2.39 +	</p>
    2.40 +</form>
    2.41 +</div>
    2.42 +EOT
    2.43 +}
    2.44 +
    2.45  table_start() {
    2.46  	cat << EOT
    2.47  <table>
    2.48 @@ -103,35 +107,48 @@
    2.49  EOT
    2.50  }
    2.51  
    2.52 -
    2.53 -list_actions() {
    2.54 +sub_block() {
    2.55  	cat << EOT
    2.56 -	<p>
    2.57 -		`gettext "Selection:"`
    2.58 -		<input type="submit" name="do" value="remove" />
    2.59 -		`gettext "List:"`
    2.60 -		<a href='$SCRIPT_NAME?list-all'>`gettext "All packages"`</a> |
    2.61 -		<a href='$SCRIPT_NAME?recharge'>`gettext "Recharge"`</a>
    2.62 -	</p>
    2.63 +<div id="sub_block">
    2.64 +	`gettext "List:"`
    2.65 +	<a href='$SCRIPT_NAME?list'>`gettext "My packages"`</a> |
    2.66 +	<a href='$SCRIPT_NAME?list-all'>`gettext "All packages"`</a> |
    2.67 +	<a href='$SCRIPT_NAME?recharge'>`gettext "Recharge"`</a> |
    2.68 +	<a href='$SCRIPT_NAME?upgradeable'>`gettext "Upgradeable"`</a>
    2.69 +</div>
    2.70  EOT
    2.71  }
    2.72  
    2.73 -list_all_actions() {
    2.74 +# For my packages list
    2.75 +list_actions() {
    2.76  	cat << EOT
    2.77 -	<p>
    2.78 -		`gettext "Selection:"`
    2.79 -		<input type="submit" name="do" value="install" />
    2.80 -		<input type="submit" name="do" value="remove" />
    2.81 -		`gettext "List:"`
    2.82 -		<a href='$SCRIPT_NAME?list'>`gettext "My packages"`</a> |
    2.83 -		<a href='$SCRIPT_NAME?recharge'>`gettext "Recharge"`</a> |
    2.84 -	</p>
    2.85 +<p>
    2.86 +	`gettext "Selection:"`
    2.87 +	<input type="submit" name="do" value="remove" />
    2.88 +</p>
    2.89  EOT
    2.90  }
    2.91  
    2.92 -js_checkbox_all() {
    2.93 -cat << EOT
    2.94 +# For list-all
    2.95 +list_all_actions() {
    2.96 +	cat << EOT
    2.97 +<p>
    2.98 +	`gettext "Selection:"`
    2.99 +	<input type="submit" name="do" value="install" />
   2.100 +	<input type="submit" name="do" value="remove" />
   2.101 +</p>
   2.102 +EOT
   2.103 +}
   2.104  
   2.105 +# For search and upgrade with JS function to toogle all pkgs
   2.106 +list_full_actions() {
   2.107 +	cat << EOT
   2.108 +<p>
   2.109 +	`gettext "Selection:"`
   2.110 +	<input type="submit" name="do" value="install" />
   2.111 +	<input type="submit" name="do" value="remove" />
   2.112 +	<a href="`cat $PANEL/checkbox.js`">`gettext "Toogle all"`</a>
   2.113 +</p>
   2.114  EOT
   2.115  }
   2.116  
   2.117 @@ -143,9 +160,16 @@
   2.118  	list)
   2.119  		# List installed packages. This is the default because parsing
   2.120  		# the full packages.desc can be long and take some resources
   2.121 -		cd /var/lib/tazpkg/installed
   2.122 -		echo "<form method='get' action='$SCRIPT_NAME'>"
   2.123 +		cd $INSTALLED
   2.124 +		search_form
   2.125 +		sub_block
   2.126 +		cat << EOT
   2.127 +<h2>`gettext "My packages"`</h2>
   2.128 +<form method='get' action='$SCRIPT_NAME'>
   2.129 +<div id="actions">
   2.130 +EOT
   2.131  		list_actions
   2.132 +		echo '</div>'
   2.133  		table_start
   2.134  		for pkg in *
   2.135  		do
   2.136 @@ -156,7 +180,7 @@
   2.137  			echo "<td class='pkg'>
   2.138  				<input type='checkbox' name='pkg' value=\"$pkg\" />
   2.139  				<a href='$SCRIPT_NAME?info=$pkg'><img
   2.140 -					src='$IMAGES/tazpkg.png'/></a>$pkg</td>"
   2.141 +					src='$IMAGES/tazpkg-installed.png'/></a>$pkg</td>"
   2.142  			echo "<td>$VERSION</td>"
   2.143  			echo "<td class='desc'>$SHORT_DESC</td>"
   2.144  			echo "<td><a href='$WEB_SITE'>web</a></td>"
   2.145 @@ -167,9 +191,16 @@
   2.146  		echo '</form>' ;;
   2.147  	list-all)
   2.148  		# List all available packages on mirror
   2.149 -		cd /var/lib/tazpkg
   2.150 -		echo "<form method='get' action='$SCRIPT_NAME'>"
   2.151 +		cd  $LOCALSTATE
   2.152 +		search_form
   2.153 +		sub_block
   2.154 +		cat << EOT
   2.155 +<h2>`gettext "All packages"`</h2>
   2.156 +<form method='get' action='$SCRIPT_NAME'>
   2.157 +<div id="actions">
   2.158 +EOT
   2.159  		list_all_actions
   2.160 +		echo '</div>'
   2.161  		table_start
   2.162  		cat packages.desc | parse_packages_desc
   2.163  		table_end
   2.164 @@ -178,31 +209,30 @@
   2.165  	search=*)
   2.166  		# Search for packages
   2.167  		pkg=${QUERY_STRING#*=}
   2.168 -		cd /var/lib/tazpkg
   2.169 +		cd  $LOCALSTATE
   2.170 +		search_form
   2.171 +		sub_block
   2.172  		cat << EOT
   2.173 +<h2>`gettext "All packages"`</h2>
   2.174  <form method="get" action="$SCRIPT_NAME">
   2.175 -	<p>
   2.176 -		`gettext "Selection:"`
   2.177 -		<input type="submit" name="do" value="install" />
   2.178 -		<input type="submit" name="do" value="remove" />
   2.179 -		`gettext "List:"`
   2.180 -		<a href='$SCRIPT_NAME?list'>`gettext "My packages"`</a> |
   2.181 -		<a href='$SCRIPT_NAME?list-all'>`gettext "All packages"`</a> |
   2.182 -		<a href='$SCRIPT_NAME?recharge'>`gettext "Recharge"`</a> |
   2.183 -		<a href="`cat checkbox.js`">`gettext "Toogle all"`</a>
   2.184 -	</p>
   2.185 +<div id="actions">
   2.186  EOT
   2.187 +		list_full_actions
   2.188 +		echo '</div>'
   2.189  		table_start
   2.190  		grep $pkg packages.desc | parse_packages_desc
   2.191  		table_end
   2.192  		echo '</form>' ;;
   2.193  	recharge)
   2.194  		# Let recharge the packages list
   2.195 +		search_form
   2.196 +		sub_block
   2.197  		cat << EOT
   2.198 -	<p>
   2.199 -		`gettext "List:"`
   2.200 -		<a href='$SCRIPT_NAME?list'>`gettext "My packages"`</a>
   2.201 -	</p>
   2.202 +<h2>`gettext "Recharge"`</h2>
   2.203 +<form method='get' action='$SCRIPT_NAME'>
   2.204 +<div id="actions">
   2.205 +	<p>`gettext "Recharge lists will check for new or updated packages"`</p>
   2.206 +</div>	
   2.207  <pre>
   2.208  EOT
   2.209  		gettext "Recharging the packages list... please wait"; echo
   2.210 @@ -212,20 +242,19 @@
   2.211  		gettext "Packages lists are up-to-date"
   2.212  		echo '</p>' ;;
   2.213  	upgradeable)
   2.214 +		cd $LOCALSTATE
   2.215 +		search_form
   2.216 +		sub_block
   2.217  		cat << EOT
   2.218 +<h2>`gettext "Upgradeable packages"`</h2>
   2.219  <form method="get" action="$SCRIPT_NAME">
   2.220 -<p>
   2.221 -	`gettext "Selection:"`
   2.222 -		<input type="submit" name="do" value="install" />
   2.223 -	`gettext "List:"`
   2.224 -	<a href='$SCRIPT_NAME?list'>`gettext "My packages"`</a> |
   2.225 -	`gettext "Upgradeable packages list"`
   2.226 -	<a href="`cat checkbox.js`">`gettext "Toogle all"`</a>
   2.227 -</p>
   2.228 +<div id="actions">
   2.229  EOT
   2.230 +		list_full_actions
   2.231 +		tazpkg upgradeable
   2.232 +		echo '</div>'
   2.233  		table_start
   2.234 -		tazpkg upgradeable
   2.235 -		for pkg in `cat $LOCALSTATE/upgradeable-packages.list`
   2.236 +		for pkg in `cat upgradeable-packages.list`
   2.237  		do
   2.238  			grep "^$pkg |" $LOCALSTATE/packages.desc | parse_packages_desc
   2.239  		done
   2.240 @@ -236,24 +265,34 @@
   2.241  		cmdline=`echo ${QUERY_STRING#do=} | sed s'/&/ /g'`		
   2.242  		cmd=`echo ${cmdline} | awk '{print $1}'`		
   2.243  		pkgs=`echo $cmdline | sed -e s'/+/ /g' -e s'/pkg=//g' -e s/$cmd//`
   2.244 -		[ $cmd == install ] && cmd=get-install
   2.245 +		[ $cmd == install ] && cmd=get-install opt=--forced
   2.246 +		search_form
   2.247 +		sub_block
   2.248 +		cat << EOT
   2.249 +<h2>Tazpkg: $cmd</h2>
   2.250 +<form method="get" action="$SCRIPT_NAME">
   2.251 +<div id="actions">
   2.252 +<p>
   2.253 +EOT
   2.254 +		gettext "Performing task on packages"
   2.255  		[ $DEBUG == "1" ] && echo "<p class='debug'>cmd: $cmd</p><p>pkgs: $pkgs </p>"
   2.256 +		echo '</p></div>'
   2.257  		for pkg in $pkgs
   2.258  		do
   2.259 -			echo '<p>'
   2.260 -			gettext "Executing: tazpkg $cmd $pkg"
   2.261 -			echo '</p><pre>'
   2.262 -			echo 'y' | tazpkg $cmd $pkg --forced 2>/dev/null | filter_tazpkg_msgs
   2.263 +			echo '<pre class="nomargin">'
   2.264 +			echo 'y' | tazpkg $cmd $pkg $opt 2>/dev/null | filter_tazpkg_msgs
   2.265  			echo '</pre>'
   2.266  		done ;;
   2.267  	info=*)
   2.268  		pkg=${QUERY_STRING#*=}
   2.269 +		search_form
   2.270 +		sub_block
   2.271  		. $INSTALLED/$pkg/receipt
   2.272  		cat << EOT
   2.273 -<p>
   2.274 -	`gettext "List:"`
   2.275 -	<a href='$SCRIPT_NAME?list'>`gettext "My packages"`</a>
   2.276 -</p>
   2.277 +<h2>`gettext "Upgradeable packages"`</h2>
   2.278 +<div id="actions">
   2.279 +	<p>`gettext "Detailled information on:" $PACKAGE`</p>
   2.280 +</div>
   2.281  <pre>
   2.282  Name        : $PACKAGE
   2.283  Version     : $VERSION
   2.284 @@ -273,11 +312,14 @@
   2.285  		;;
   2.286  	*)
   2.287  		# Default to summary
   2.288 +		
   2.289 +		sub_block
   2.290 +		search_form
   2.291  		cat << EOT
   2.292 -`gettext "List:"`
   2.293 -<a href='$SCRIPT_NAME?list'>`gettext "My packages"`</a> |
   2.294 -<a href='$SCRIPT_NAME?recharge'>`gettext "Recharge"`</a> |
   2.295 -<a href='$SCRIPT_NAME?upgradeable'>`gettext "Upgradeable"`</a>
   2.296 +<h2>`gettext "Summary"`</h2>
   2.297 +<div id="actions">
   2.298 +	<p>`gettext "Overview of all installed and mirrored packages"`</p>
   2.299 +</div>
   2.300  <pre>
   2.301  `packages_summary`
   2.302  </pre>