tazpkg rev 732

pkgs.cgi: full featured "tag".
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Dec 29 05:05:36 2014 +0200 (2014-12-29)
parents 853142b48010
children 061ee30eaf2d
files tazpanel/pkgs.cgi
line diff
     1.1 --- a/tazpanel/pkgs.cgi	Sun Dec 28 06:11:25 2014 +0200
     1.2 +++ b/tazpanel/pkgs.cgi	Mon Dec 29 05:05:36 2014 +0200
     1.3 @@ -85,38 +85,6 @@
     1.4  }
     1.5  
     1.6  
     1.7 -# Display a full summary of packages stats
     1.8 -
     1.9 -packages_summary() {
    1.10 -	cat << EOT
    1.11 -<table class="zebra outbox">
    1.12 -<tbody>
    1.13 -<tr><td>$(_ 'Last recharge:')</td><td>
    1.14 -EOT
    1.15 -	ls -l $PKGS_DB/packages.list | awk '{print $6, $7, $8}'
    1.16 -	if [ -n "$(find $PKGS_DB/packages.list -mtime +10)" ]; then
    1.17 -		_ '(Older than 10 days)'
    1.18 -	else
    1.19 -		_ '(Not older than 10 days)'
    1.20 -	fi
    1.21 -	cat << EOT
    1.22 -</td></tr>
    1.23 -<tr><td>$(_ 'Installed packages:')</td>
    1.24 -	<td>$(cat $PKGS_DB/installed.info | wc -l)</td></tr>
    1.25 -<tr><td>$(_ 'Mirrored packages:')</td>
    1.26 -	<td>$(cat $PKGS_DB/packages.list | wc -l)</td></tr>
    1.27 -<tr><td>$(_ 'Upgradeable packages:')</td>
    1.28 -	<td>$(cat $PKGS_DB/packages.up | wc -l)</td></tr>
    1.29 -<tr><td>$(_ 'Installed files:')</td>
    1.30 -	<td>$(cat $INSTALLED/*/files.list | wc -l)</td></tr>
    1.31 -<tr><td>$(_ 'Blocked packages:')</td>
    1.32 -	<td>$(cat $PKGS_DB/blocked-packages.list | wc -l)</td></tr>
    1.33 -</tbody>
    1.34 -</table>
    1.35 -EOT
    1.36 -}
    1.37 -
    1.38 -
    1.39  # Parse mirrors list to be able to have an icon and remove link
    1.40  
    1.41  list_mirrors() {
    1.42 @@ -155,6 +123,7 @@
    1.43  		recharge)     img='recharge'; label="$(_ 'Recharge list')" ;;
    1.44  		up)           img='update';   label="$(_ 'Check upgrades')" ;;
    1.45  		list)         img='tazpkg';   label="$(_ 'My packages')" ;;
    1.46 +		tag=)         img='';         label="$(_ 'Tags')" ;;
    1.47  		linkable)     img='tazpkg';   label="$(_ 'Linkable packages')" ;;
    1.48  		admin)        img='edit';     label="$(_ 'Administration')" ;;
    1.49  		*Install*nf*) img='';         label="$(_ 'Install (Non Free)')" ;;
    1.50 @@ -506,12 +475,7 @@
    1.51  </div>
    1.52  EOT
    1.53  			for i in $(repo_list ""); do
    1.54 -				if [ "$repo" != "Public" ]; then
    1.55 -					Repo_Name="$(repo_name $i)"
    1.56 -					cat << EOT
    1.57 -<h3>$(_ 'Repository: %s' $Repo_Name)</h3>
    1.58 -EOT
    1.59 -				fi
    1.60 +				[ "$repo" != "Public" ] && echo "<h3>$(_ 'Repository: %s' $(repo_name $i))</h3>"
    1.61  
    1.62  				case $category in
    1.63  					extra)
    1.64 @@ -1162,16 +1126,54 @@
    1.65  		#
    1.66  		search_form
    1.67  		sidebar
    1.68 -		tag=$(GET tag)
    1.69 +		tag=$(GET tag); repo=$(GET repo)
    1.70  		if [ -n "$tag" ]; then
    1.71 -			echo "<h2>$(_ 'Tag "%s"' $tag)</h2>"
    1.72 -			echo '<table class="zebra outbox pkglist">'
    1.73 -			table_head
    1.74 -			echo '<tbody>'
    1.75 -			awk -F$'\t' '$6 ~ /(^| )'$tag'( |$)/{
    1.76 -				printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\"><a class=\"pkg%s%s\" href=\"?info=%s\">%s</a></td><td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", $1, INS, BLK, gensub(/\+/, "%2B", "g", $1), $1, $2, $4, $5
    1.77 -			}' $PKGS_DB/packages.info
    1.78 -			echo "</tbody></table>"
    1.79 +			cat << EOT
    1.80 +<h2>$(_ 'Tag "%s"' $tag)</h2>
    1.81 +
    1.82 +<form method='get' action='$SCRIPT_NAME'>
    1.83 +<div id="actions">
    1.84 +	<div class="float-left">
    1.85 +		$(_ 'Selection:')
    1.86 +		<input type="submit" name="do" value="Install" />
    1.87 +		<input type="submit" name="do" value="Remove" />
    1.88 +		<input type="hidden" name="repo" value="$repo" />
    1.89 +	</div>
    1.90 +	<div class="float-right">
    1.91 +		$(show_button tag=)
    1.92 +		$(show_button list)
    1.93 +	</div>
    1.94 +</div>
    1.95 +EOT
    1.96 +			for i in $(repo_list ""); do
    1.97 +				[ "$repo" != "Public" ] && echo "<h3>$(_ 'Repository: %s' $(repo_name $i))</h3>"
    1.98 +
    1.99 +				echo '<table class="zebra outbox pkglist">'
   1.100 +				table_head
   1.101 +				echo '<tbody>'
   1.102 +				make_mixed_list | sort -t$'\t' -k1,1 | awk -F$'\t' -vt="$tag" '
   1.103 +{
   1.104 +	if (PKG && PKG != $1) {
   1.105 +		if (TAG) {
   1.106 +			if (DSCL) DSC = DSCL
   1.107 +			printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\"><a class=\"pkg%s%s\" href=\"?info=%s\">%s</a></td><td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", PKG, INS, BLK, gensub(/\+/, "%2B", "g", PKG), PKG, VER, DSC, WEB
   1.108 +		}
   1.109 +		VER = DSC = WEB = DSCL = INS = BLK = TAG = ""
   1.110 +	}
   1.111 +
   1.112 +	PKG = $1
   1.113 +	if (NF == 1) { BLK = "b"; next }
   1.114 +	if (NF == 2) { DSCL = $2; next }
   1.115 +	if (index(" "$6" ", " "t" ")) {
   1.116 +		TAG = t
   1.117 +		if ($9 == "i") { VER = $2; DSC = $4; WEB = $5; INS = "i"; next}
   1.118 +		if (! INS)     { VER = $2; DSC = $4; WEB = $5 }
   1.119 +	}
   1.120 +}'
   1.121 +				echo "</tbody></table>"
   1.122 +			done
   1.123 +			echo '</form>'
   1.124 +
   1.125  		else
   1.126  			echo "<h2>$(_ 'Tags list')</h2>"
   1.127  			echo "<p>"
   1.128 @@ -1197,8 +1199,8 @@
   1.129  <h2>$(_ 'Summary')</h2>
   1.130  
   1.131  <div id="actions">
   1.132 -	$(show_button list)
   1.133  EOT
   1.134 +		show_button list
   1.135  		fslink=$(readlink $PKGS_DB/fslink)
   1.136  		[ -n "$fslink" -a -d "$fslink/$INSTALLED" ] && show_button linkable
   1.137  		show_button recharge
   1.138 @@ -1207,8 +1209,30 @@
   1.139  		cat << EOT
   1.140  </div>
   1.141  
   1.142 -$(packages_summary)
   1.143 -
   1.144 +<table class="zebra outbox">
   1.145 +<tbody>
   1.146 +<tr><td>$(_ 'Last recharge:')</td><td>
   1.147 +EOT
   1.148 +		ls -l $PKGS_DB/packages.list | awk '{print $6, $7, $8}'
   1.149 +		if [ -n "$(find $PKGS_DB/packages.list -mtime +10)" ]; then
   1.150 +			_ '(Older than 10 days)'
   1.151 +		else
   1.152 +			_ '(Not older than 10 days)'
   1.153 +		fi
   1.154 +		cat << EOT
   1.155 +</td></tr>
   1.156 +<tr><td>$(_ 'Installed packages:')</td>
   1.157 +	<td>$(cat $PKGS_DB/installed.info | wc -l)</td></tr>
   1.158 +<tr><td>$(_ 'Mirrored packages:')</td>
   1.159 +	<td>$(cat $PKGS_DB/packages.list | wc -l)</td></tr>
   1.160 +<tr><td>$(_ 'Upgradeable packages:')</td>
   1.161 +	<td>$(cat $PKGS_DB/packages.up | wc -l)</td></tr>
   1.162 +<tr><td>$(_ 'Installed files:')</td>
   1.163 +	<td>$(cat $INSTALLED/*/files.list | wc -l)</td></tr>
   1.164 +<tr><td>$(_ 'Blocked packages:')</td>
   1.165 +	<td>$(cat $PKGS_DB/blocked-packages.list | wc -l)</td></tr>
   1.166 +</tbody>
   1.167 +</table>
   1.168  
   1.169  <h3>$(_ 'Latest log entries')</h3>
   1.170