cookutils diff lighttpd/index.cgi @ rev 1007

lighttpd/index.cgi: remake toolchain info (was broken for linux-api-headers); add feature: show tags
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Nov 13 02:55:58 2017 +0200 (2017-11-13)
parents 553a90d99a5b
children 7dc9964e94a8
line diff
     1.1 --- a/lighttpd/index.cgi	Sat Nov 11 11:53:55 2017 +0000
     1.2 +++ b/lighttpd/index.cgi	Mon Nov 13 02:55:58 2017 +0200
     1.3 @@ -772,15 +772,14 @@
     1.4  
     1.5  
     1.6  toolchain_version() {
     1.7 -	echo "<tr><td><a href='$base/$1'>$1</a></td><td>"
     1.8 -	if [ -e "$WOK/$1/receipt" ]; then
     1.9 -		grep ^VERSION $WOK/$1/receipt | cut -d '"' -f2
    1.10 -		echo '</td><td>'
    1.11 -		grep ^SHORT_DESC $WOK/$1/receipt | cut -d '"' -f2
    1.12 -	else
    1.13 -		echo -n '---</td><td>---'
    1.14 -	fi
    1.15 -	echo "</td></tr>"
    1.16 +	echo "<tr><td><a href='$base/$1'>$1</a></td>"
    1.17 +	awk -F$'\t' -vpkg="$1" '
    1.18 +	BEGIN { version = description = "---"; }
    1.19 +	      {
    1.20 +	        if ($1 == pkg) { version = $2; description = $4; }
    1.21 +	      }
    1.22 +	END   { printf("<td>%s</td><td>%s</td></tr>", version, description); }
    1.23 +	' $PKGS/packages.info
    1.24  }
    1.25  
    1.26  
    1.27 @@ -1039,6 +1038,35 @@
    1.28  fi
    1.29  
    1.30  
    1.31 +# show tag
    1.32 +
    1.33 +if [ "$pkg" == '~' -a -n "$cmd" ]; then
    1.34 +	tag="$cmd"
    1.35 +	page_header
    1.36 +	cat <<EOT
    1.37 +<div id="content2">
    1.38 +<section>
    1.39 +<h2>Tag “$tag”</h2>
    1.40 +
    1.41 +<table>
    1.42 +	<thead>
    1.43 +		<tr><th>Name</th><th>Description</th><th>Category</th></tr>
    1.44 +	</thead>
    1.45 +	<tbody>
    1.46 +EOT
    1.47 +	awk -F$'\t' -vtag=" $tag " -vbase="$base" '{
    1.48 +		if (index(" " $6 " ", tag)) {
    1.49 +			url = base "/" $1 "/";
    1.50 +			gsub("+", "%2B", url);
    1.51 +			printf("<tr><td><a href=\"%s\">%s</a></td><td>%s</td><td>%s</td></tr>\n", url, $1, $4, $3);
    1.52 +		}
    1.53 +	}' $PKGS/packages.info
    1.54 +	echo '</tbody></table>'
    1.55 +	page_footer
    1.56 +	exit 0
    1.57 +fi
    1.58 +
    1.59 +
    1.60  case "$cmd" in
    1.61  	'')
    1.62  		page_header
    1.63 @@ -1094,9 +1122,29 @@
    1.64  		summary "$log"
    1.65  
    1.66  
    1.67 +		# Show tag list
    1.68 +		taglist=$(
    1.69 +			for i in $pkg $(awk -F$'\t' -vp="$pkg" '{if ($1 == p) print $2}' $splitdb); do
    1.70 +				[ -s "$PKGS/packages.info" ] &&
    1.71 +				awk -F$'\t' -vpkg="$i" '{
    1.72 +					if ($1 == pkg) { print $6; exit; }
    1.73 +				}' "$PKGS/packages.info"
    1.74 +			done \
    1.75 +			| tr ' ' '\n' \
    1.76 +			| sort -u
    1.77 +		)
    1.78 +		if [ -n "$taglist" ]; then
    1.79 +			echo -n '<section><h3>Tags</h3><p>'
    1.80 +			lasttag=$(echo "$taglist" | tail -n1)
    1.81 +			for tag in $taglist; do
    1.82 +				echo -n "<a href=\"$base/~/${tag//+/%2B}\">$tag</a>"
    1.83 +				[ "$tag" != "$lasttag" ] && echo -n " · "
    1.84 +			done
    1.85 +			echo '</p></section>'
    1.86 +		fi
    1.87  
    1.88  
    1.89 -		# Informal table with dependencies
    1.90 +		# Informational table with dependencies
    1.91  		pkg="$requested_pkg"
    1.92  		inf="$(mktemp -d)"
    1.93