wok rev 3780

tazpkg-web:search.cgi display description.txt
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jul 30 18:46:38 2009 +0200 (2009-07-30)
parents 750f6987718f
children 7fe791e8b986
files mirror-tools/stuff/var/www/pkgs/search.cgi tazpkg-web/stuff/search.cgi
line diff
     1.1 --- a/mirror-tools/stuff/var/www/pkgs/search.cgi	Thu Jul 30 11:32:00 2009 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,527 +0,0 @@
     1.4 -#!/bin/sh
     1.5 -# Tiny CGI search engine for SliTaz packages on http://pkgs.slitaz.org/
     1.6 -# Christophe Lincoln <pankso@slitaz.org>
     1.7 -#
     1.8 -
     1.9 -read QUERY_STRING
    1.10 -for i in $(echo $QUERY_STRING | sed 's/&/ /g'); do
    1.11 -	eval $i
    1.12 -done
    1.13 -LANG=$lang
    1.14 -SEARCH=$query
    1.15 -SLITAZ_VERSION=$version
    1.16 -OBJECT=$object
    1.17 -DATE=`date +%Y-%m-%d\ \%H:%M:%S`
    1.18 -VERSION=cooking
    1.19 -if [ "$REQUEST_METHOD" = "GET" ]; then
    1.20 -	SEARCH=""
    1.21 -	for i in $(echo $REQUEST_URI | sed 's/[?&]/ /g'); do
    1.22 -		SLITAZ_VERSION=cooking
    1.23 -		case "$i" in
    1.24 -		lang=*)
    1.25 -			LANG=${i#*=};;
    1.26 -		file=*)
    1.27 -			SEARCH=${i#*=}
    1.28 -			OBJECT=File;;
    1.29 -		desc=*)
    1.30 -			SEARCH=${i#*=}
    1.31 -			OBJECT=Desc;;
    1.32 -		tags=*)
    1.33 -			SEARCH=${i#*=}
    1.34 -			OBJECT=Tags;;
    1.35 -		receipt=*)
    1.36 -			SEARCH=${i#*=}
    1.37 -			OBJECT=Receipt;;
    1.38 -		filelist=*)
    1.39 -			SEARCH=${i#*=}
    1.40 -			OBJECT=File_list;;
    1.41 -		package=*)
    1.42 -			SEARCH=${i#*=}
    1.43 -			OBJECT=Package;;
    1.44 -		depends=*)
    1.45 -			SEARCH=${i#*=}
    1.46 -			OBJECT=Depends;;
    1.47 -		version=s*|version=2*)
    1.48 -			SLITAZ_VERSION=stable;;
    1.49 -		version=1*)
    1.50 -			SLITAZ_VERSION=1.0;;
    1.51 -		esac
    1.52 -	done
    1.53 -	[ -n "$SEARCH" ] && REQUEST_METHOD="POST"
    1.54 -fi
    1.55 -
    1.56 -case "$OBJECT" in
    1.57 -File)	 	selected_file="selected";;
    1.58 -Desc)	 	selected_desc="selected";;
    1.59 -Tags)	 	selected_tags="selected";;
    1.60 -Receipt) 	selected_receipt="selected";;
    1.61 -File_list) 	selected_file_list="selected";;
    1.62 -Depends)	selected_depends="selected";;
    1.63 -esac
    1.64 -
    1.65 -case "$SLITAZ_VERSION" in
    1.66 -1.0)	 	selected_1="selected";;
    1.67 -stable)		selected_stable="selected";;
    1.68 -esac
    1.69 -
    1.70 -# unescape query
    1.71 -SEARCH="$(echo $SEARCH | sed 's/%2B/+/g' | sed 's/%3A/:/g' | sed 's|%2F|/|g')"
    1.72 -
    1.73 -if [ -z "$LANG" ]; then
    1.74 -	for i in $(echo $HTTP_ACCEPT_LANGUAGE | sed 's/[,;]/ /g'); do
    1.75 -		case "$i" in
    1.76 -		fr|de|pt|cn)
    1.77 -			LANG=$i
    1.78 -			break;;
    1.79 -		esac
    1.80 -	done
    1.81 -fi
    1.82 -
    1.83 -package="Package"
    1.84 -file="File"
    1.85 -desc="Description"
    1.86 -tags="Tags"
    1.87 -receipt="Receipt"
    1.88 -file_list="File list"
    1.89 -depends="Depends"
    1.90 -search="Search"
    1.91 -cooking="cooking"
    1.92 -stable="stable"
    1.93 -result="Result for : $SEARCH"
    1.94 -noresult="No package $SEARCH"
    1.95 -deptree="Dependency tree for : $SEARCH"
    1.96 -rdeptree="Reverse dependency tree for : $SEARCH"
    1.97 -charset="ISO-8859-1"
    1.98 -
    1.99 -case "$LANG" in
   1.100 -
   1.101 -fr)	package="Paquet"
   1.102 -	receipt="Recette"
   1.103 -	depends="Dépendances"
   1.104 -	search="Recherche"
   1.105 -	result="Recherche de : $SEARCH"
   1.106 -	noresult="Paquet $SEARCH introuvable"
   1.107 -	deptree="Arbre des dépendances de $SEARCH"
   1.108 -	rdeptree="Arbre inversé des dépendances de $SEARCH"
   1.109 -	file_list="Liste des fichiers"
   1.110 -	file="Fichier";;
   1.111 -
   1.112 -de)	package="Paket"
   1.113 -	depends="Abhängigkeiten"
   1.114 -	desc="Beschreibung"
   1.115 -	search="Suche"
   1.116 -	cooking="Cooking"
   1.117 -	stable="Stable"
   1.118 -	result="Resultate für : $SEARCH"
   1.119 -	noresult="Kein Paket für $SEARCH"
   1.120 -	deptree="Abhängigkeiten von: $SEARCH"
   1.121 -	rdeptree="Abhängigkeit für: $SEARCH"
   1.122 -	file_list="Datei liste"
   1.123 -	file="Datei";;
   1.124 -
   1.125 -pt)	package="Pacote"
   1.126 -	search="Buscar"
   1.127 -	cooking="cooking"
   1.128 -	stable="stable"
   1.129 -	result="Resultado para : $SEARCH"
   1.130 -	noresult="Sem resultado: $SEARCH"
   1.131 -	deptree="Árvore de dependências para: $SEARCH"
   1.132 -	rdeptree="Árvore de dependências reversa para: $SEARCH"
   1.133 -	depends="Dependências"
   1.134 -	desc="Descrição"
   1.135 -	file_list="Arquivo lista"
   1.136 -	file="Arquivo";;
   1.137 -
   1.138 -cn)	package="软件包:"
   1.139 -	cooking="å¼€å‘版"
   1.140 -	stable="稳定版"
   1.141 -	desc="æè¿°"
   1.142 -	tags="标签"
   1.143 -	depends="ä¾èµ–"
   1.144 -	file="文件"
   1.145 -	file_list="文件列表"
   1.146 -	search="Search"
   1.147 -	result="Result for : $SEARCH"
   1.148 -	noresult="No package $SEARCH"
   1.149 -	deptree="Dependency tree for : $SEARCH"
   1.150 -	rdeptree="Reverse dependency tree for : $SEARCH"
   1.151 -	charset="UTF-8";;
   1.152 -
   1.153 -*)	LANG="en";;
   1.154 -
   1.155 -esac
   1.156 -
   1.157 -WOK=/home/slitaz/$SLITAZ_VERSION/wok
   1.158 -
   1.159 -echo Content-type: text/html
   1.160 -echo
   1.161 -
   1.162 -# Search form
   1.163 -search_form()
   1.164 -{
   1.165 -	cat << _EOT_
   1.166 -
   1.167 -<div style="text-align: center; padding: 20px;">
   1.168 -<form method="post" action="search.cgi">
   1.169 -	<input type="hidden" name="lang" value="$LANG" />
   1.170 -	<select name="object">
   1.171 -		<option value="Package">$package</option>
   1.172 -		<option $selected_desc value="Desc">$desc</option>
   1.173 -		<option $selected_tags value="Tags">$tags</option>
   1.174 -		<option $selected_receipt value="Receipt">$receipt</option>
   1.175 -		<option $selected_depends value="Depends">$depends</option>
   1.176 -		<option $selected_file value="File">$file</option>
   1.177 -		<option $selected_file_list value="File_list">$file_list</option>
   1.178 -	</select>
   1.179 -	<strong>:</strong>
   1.180 -	<input type="text" name="query" size="32" value="$SEARCH" />
   1.181 -	<select name="version">
   1.182 -		<option value="cooking">$cooking</option>
   1.183 -		<option $selected_stable value="stable">$stable</option>
   1.184 -		<option $selected_1 value="1.0">1.0</option>
   1.185 -	</select>
   1.186 -	<input type="submit" name="search" value="$search" />
   1.187 -</form>
   1.188 -</div>
   1.189 -_EOT_
   1.190 -}
   1.191 -
   1.192 -# xHTML Header.
   1.193 -xhtml_header()
   1.194 -{
   1.195 -	cat << _EOF_
   1.196 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   1.197 -	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   1.198 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$LANG" lang="$LANG">
   1.199 -<head>
   1.200 -	<title>SliTaz Packages - Search $SEARCH</title>
   1.201 -	<meta http-equiv="content-type" content="text/html; charset=$charset" />
   1.202 -	<meta name="description" content="Au sujet de SliTaz GNU/Linux mini système d'exploitation" />
   1.203 -	<meta name="keywords" lang="fr" content="Système, libre, gnu, linux, opensource, livecd" />
   1.204 -	<meta name="robots" content="index, follow, all" />
   1.205 -	<meta name="revisit-after" content="7 days" />
   1.206 -	<meta name="expires" content="never" />
   1.207 -	<meta name="modified" content="$DATE" />
   1.208 -	<meta name="author" content="ash, awk, grep, sed and cat"/>
   1.209 -	<meta name="publisher" content="www.slitaz.org" />
   1.210 -	<link rel="shortcut icon" href="http://pkgs.slitaz.org/favicon.ico" />
   1.211 -	<link rel="stylesheet"  type="text/css" href="http://pkgs.slitaz.org/slitaz.css" />
   1.212 -</head>
   1.213 -<body bgcolor="#ffffff">
   1.214 -
   1.215 -<!-- Header -->
   1.216 -<div id="header">
   1.217 -	<a name="top"></a>
   1.218 -<!-- Access -->
   1.219 -<div id="access">
   1.220 -	<a href="http://www.slitaz.org/" title="SliTaz Web site">Website</a> |
   1.221 -	<a href="http://wiki.slitaz.org/" title="SliTaz Community Wiki">Wiki</a> |
   1.222 -	<a href="http://labs.slitaz.org/" title="SliTaz laboratories">Labs</a>
   1.223 -</div>
   1.224 -	<a href="http://pkgs.slitaz.org/"><img id="logo"
   1.225 -	src="http://pkgs.slitaz.org/pics/website/logo.png" title="pkgs.slitaz.org" alt="pkgs.slitaz.org"
   1.226 -	style="border: 0px solid ; width: 200px; height: 74px;" /></a>
   1.227 -	<p id="titre">#!/tazpkg/packages</p>
   1.228 -</div>
   1.229 -_EOF_
   1.230 -}
   1.231 -
   1.232 -# xHTML Footer.
   1.233 -xhtml_footer()
   1.234 -{
   1.235 -	cat << _EOT_
   1.236 -<center>
   1.237 -<i>$(ls /home/slitaz/$SLITAZ_VERSION/wok | wc -l) packages and $(unlzma -c /home/slitaz/$SLITAZ_VERSION/packages/files.list.lzma | wc -l) files in $SLITAZ_VERSION database</i>
   1.238 -</center>
   1.239 -
   1.240 -<!-- End of content with round corner -->
   1.241 -</div>
   1.242 -<div id="content_bottom">
   1.243 -<div class="bottom_left"></div>
   1.244 -<div class="bottom_right"></div>
   1.245 -</div>
   1.246 -
   1.247 -<!-- Start of footer and copy notice -->
   1.248 -<div id="copy">
   1.249 -<p>
   1.250 -Dernière modification : $DATE -
   1.251 -<a href="#top">Top of the page</a>
   1.252 -</p>
   1.253 -<p>
   1.254 -Copyright &copy; 2009 <a href="http://www.slitaz.org/">SliTaz</a> -
   1.255 -<a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
   1.256 -</p>
   1.257 -<!-- End of copy -->
   1.258 -</div>
   1.259 -
   1.260 -<!-- Bottom and logo's -->
   1.261 -<div id="bottom">
   1.262 -<p>
   1.263 -<a href="http://validator.w3.org/check?uri=referer"><img
   1.264 -	src="http://pkgs.slitaz.org/pics/website/xhtml10.png" alt="Valid XHTML 1.0"
   1.265 -	title="Code validé XHTML 1.0"
   1.266 -	style="width: 80px; height: 15px;" /></a>
   1.267 -</p>
   1.268 -</div>
   1.269 -
   1.270 -</body>
   1.271 -</html>
   1.272 -_EOT_
   1.273 -}
   1.274 -
   1.275 -# recursive dependencies scan                                       
   1.276 -dep_scan()                                                       
   1.277 -{                                                                    
   1.278 -for i in $1; do
   1.279 -	case " $ALL_DEPS " in
   1.280 -	*\ $i\ *) continue;;
   1.281 -	esac
   1.282 -	ALL_DEPS="$ALL_DEPS $i"
   1.283 -	if [ -n "$2" ]; then
   1.284 -		echo -n "$2"
   1.285 -		(
   1.286 -		. $WOK/$i/receipt
   1.287 -		cat << _EOT_
   1.288 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.289 -_EOT_
   1.290 -		)
   1.291 -	fi
   1.292 -	[ -f $WOK/$i/receipt ] || continue
   1.293 -	DEPENDS=""
   1.294 -	. $WOK/$i/receipt
   1.295 -	[ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2    "
   1.296 -done
   1.297 -}
   1.298 -
   1.299 -# recursive reverse dependencies scan                       
   1.300 -rdep_scan()                                                           
   1.301 -{                                                                            
   1.302 -SEARCH=$1
   1.303 -case "$SEARCH" in
   1.304 -glibc-base|gcc-lib-base) cat <<EOT
   1.305 -	glibc-base and gcc-lib-base are implicit dependencies
   1.306 -	<b>every</b> packages are supposed to depend on them.
   1.307 -EOT
   1.308 -	return;;
   1.309 -esac
   1.310 -for i in $WOK/* ; do
   1.311 -	DEPENDS=""
   1.312 -	. $i/receipt
   1.313 -	echo "$(basename $i) $(echo $DEPENDS)"
   1.314 -done | awk -v search=$SEARCH '
   1.315 -function show_deps(deps, all_deps, pkg, space)
   1.316 -{
   1.317 -	if (all_deps[pkg] == 1) return
   1.318 -	all_deps[pkg] = 1
   1.319 -	if (space != "") printf "%s%s\n",space,pkg
   1.320 -	for (i = 1; i <= split(deps[pkg], mydeps, " "); i++) {
   1.321 -		show_deps(deps, all_deps, mydeps[i],"////" space)
   1.322 -	}
   1.323 -}
   1.324 -
   1.325 -{
   1.326 -	all_deps[$1] = 0
   1.327 -	for (i = 2; i <= NF; i++)
   1.328 -		deps[$i] = deps[$i] " " $1
   1.329 -}
   1.330 -
   1.331 -END {
   1.332 -	show_deps(deps, all_deps, search, "")
   1.333 -}
   1.334 -' | while read pkg; do
   1.335 -		. $WOK/${pkg##*/}/receipt
   1.336 -		cat << _EOT_
   1.337 -$(echo ${pkg%/*} | sed 's|/| |g') <a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.338 -_EOT_
   1.339 -done
   1.340 -}
   1.341 -
   1.342 -# Check package exists
   1.343 -package_exist()
   1.344 -{
   1.345 -	[ -f $WOK/$1/receipt ] && return 0
   1.346 -	cat << _EOT_
   1.347 -
   1.348 -<h3>$noresult</h3>
   1.349 -<pre class="package">
   1.350 -_EOT_
   1.351 -	return 1
   1.352 -}
   1.353 -
   1.354 -# Display search form and result if requested.
   1.355 -if [ "$REQUEST_METHOD" != "POST" ]; then
   1.356 -	xhtml_header
   1.357 -	cat << _EOT_
   1.358 -
   1.359 -<!-- Content top. -->
   1.360 -<div id="content_top">
   1.361 -<div class="top_left"></div>
   1.362 -<div class="top_right"></div>
   1.363 -</div>
   1.364 -
   1.365 -<!-- Content -->
   1.366 -<div id="content">
   1.367 -<a name="content"></a>
   1.368 -
   1.369 -<h1><font color="#3E1220">$package</font></h1>
   1.370 -<h2><font color="#DF8F06">$search</font></h2>
   1.371 -_EOT_
   1.372 -	search_form
   1.373 -	xhtml_footer
   1.374 -else
   1.375 -	xhtml_header
   1.376 -	cat << _EOT_
   1.377 -
   1.378 -<!-- Content top. -->
   1.379 -<div id="content_top">
   1.380 -<div class="top_left"></div>
   1.381 -<div class="top_right"></div>
   1.382 -</div>
   1.383 -
   1.384 -<!-- Content -->
   1.385 -<div id="content">
   1.386 -<a name="content"></a>
   1.387 -
   1.388 -<h1><font color="#3E1220">$package</font></h1>
   1.389 -<h2><font color="#DF8F06">$search</font></h2>
   1.390 -_EOT_
   1.391 -	search_form
   1.392 -	if [ "$OBJECT" = "Depends" ]; then
   1.393 -		if package_exist $SEARCH ; then
   1.394 -			cat << _EOT_
   1.395 -
   1.396 -<h3>$deptree</h3>
   1.397 -<pre class="package">
   1.398 -_EOT_
   1.399 -			ALL_DEPS=""
   1.400 -			dep_scan $SEARCH ""
   1.401 -			SUGGESTED=""
   1.402 -			. $WOK/$SEARCH/receipt
   1.403 -			if [ -n "$SUGGESTED" ]; then
   1.404 -				cat << _EOT_
   1.405 -</pre>
   1.406 -
   1.407 -<h3>$deptree (SUGGESTED)</h3>
   1.408 -<pre class="package">
   1.409 -_EOT_
   1.410 -				ALL_DEPS=""
   1.411 -				dep_scan "$SUGGESTED" "    "
   1.412 -			fi
   1.413 -			cat << _EOT_
   1.414 -</pre>
   1.415 -
   1.416 -<h3>$rdeptree</h3>
   1.417 -<pre class="package">
   1.418 -_EOT_
   1.419 -			ALL_DEPS=""
   1.420 -			rdep_scan $SEARCH
   1.421 -		fi
   1.422 -	elif [ "$OBJECT" = "File" ]; then
   1.423 -		cat << _EOT_
   1.424 -
   1.425 -<h3>$result</h3>
   1.426 -<pre class="package">
   1.427 -_EOT_
   1.428 -		last=""
   1.429 -		unlzma -c /home/slitaz/$SLITAZ_VERSION/packages/files.list.lzma \
   1.430 -		| grep $SEARCH | while read pkg file; do
   1.431 -			echo "$file" | grep -q $SEARCH || continue
   1.432 -			if [ "$last" != "${pkg%:}" ]; then
   1.433 -				last=${pkg%:}
   1.434 -				(
   1.435 -				. $WOK/$last/receipt
   1.436 -				cat << _EOT_
   1.437 -
   1.438 -<i><b><a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a></b> $SHORT_DESC</i>
   1.439 -_EOT_
   1.440 -				)
   1.441 -			fi
   1.442 -			echo "    $file"
   1.443 -		done
   1.444 -	elif [ "$OBJECT" = "File_list" ]; then
   1.445 -		package_exist $SEARCH && cat << _EOT_
   1.446 -
   1.447 -<h3>$result</h3>
   1.448 -<pre class="package">
   1.449 -_EOT_
   1.450 -		last=""
   1.451 -		unlzma -c /home/slitaz/$SLITAZ_VERSION/packages/files.list.lzma \
   1.452 -		| grep ^$SEARCH: |  sed 's/.*: /    /' | sort
   1.453 -	elif [ "$OBJECT" = "Desc" ]; then
   1.454 -		cat << _EOT_
   1.455 -
   1.456 -<h3>$result</h3>
   1.457 -<pre class="package">
   1.458 -_EOT_
   1.459 -		last=""
   1.460 -		grep -i $SEARCH /home/slitaz/$SLITAZ_VERSION/packages/packages.desc | \
   1.461 -		sort | while read pkg extras ; do
   1.462 -				. $WOK/$pkg/receipt
   1.463 -				cat << _EOT_
   1.464 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.465 -_EOT_
   1.466 -			done
   1.467 -	elif [ "$OBJECT" = "Tags" ]; then
   1.468 -		cat << _EOT_
   1.469 -
   1.470 -<h3>$result</h3>
   1.471 -<pre class="package">
   1.472 -_EOT_
   1.473 -		last=""
   1.474 -		grep ^TAGS= $WOK/*/receipt |  grep -i $SEARCH | \
   1.475 -		sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
   1.476 -				. $WOK/$pkg/receipt
   1.477 -				cat << _EOT_
   1.478 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.479 -_EOT_
   1.480 -			done
   1.481 -	elif [ "$OBJECT" = "Receipt" ]; then
   1.482 -		package_exist $SEARCH && cat << _EOT_
   1.483 -
   1.484 -<h3>$result</h3>
   1.485 -<pre class="package">
   1.486 -<pre>
   1.487 -$(if [ -f  $WOK/$SEARCH/taz/*/receipt ]; then
   1.488 -	cat $WOK/$SEARCH/taz/*/receipt
   1.489 -  else
   1.490 -    cat $WOK/$SEARCH//receipt
   1.491 -  fi | sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g')
   1.492 -</pre>
   1.493 -_EOT_
   1.494 -	else
   1.495 -		cat << _EOT_
   1.496 -
   1.497 -<h3>$result</h3>
   1.498 -<pre class="package">
   1.499 -_EOT_
   1.500 -		for pkg in `ls $WOK | grep $SEARCH`
   1.501 -		do
   1.502 -			. $WOK/$pkg/receipt
   1.503 -			cat << _EOT_
   1.504 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.505 -_EOT_
   1.506 -		done
   1.507 -		equiv=/home/slitaz/$SLITAZ_VERSION/packages/packages.equiv
   1.508 -		vpkgs="$(cat $equiv | cut -d= -f1 | grep $SEARCH)"
   1.509 -		for vpkg in $vpkgs ; do
   1.510 -	cat << _EOT_
   1.511 -</pre>
   1.512 -
   1.513 -<h3>$result (package providing $vpkg)</h3>
   1.514 -<pre class="package">
   1.515 -_EOT_
   1.516 -			for pkg in $(grep $vpkg= $equiv | sed "s/$vpkg=//"); do
   1.517 -				. $WOK/${pkg#*:}/receipt
   1.518 -				cat << _EOT_
   1.519 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.520 -_EOT_
   1.521 -			done
   1.522 -		done
   1.523 -	fi
   1.524 -	cat << _EOT_
   1.525 -</pre>
   1.526 -_EOT_
   1.527 -	xhtml_footer
   1.528 -fi
   1.529 -
   1.530 -exit 0
     2.1 --- a/tazpkg-web/stuff/search.cgi	Thu Jul 30 11:32:00 2009 +0000
     2.2 +++ b/tazpkg-web/stuff/search.cgi	Thu Jul 30 18:46:38 2009 +0200
     2.3 @@ -270,9 +270,9 @@
     2.4  _EOT_
     2.5  }
     2.6  
     2.7 -# recursive dependencies scan                                       
     2.8 -dep_scan()                                                       
     2.9 -{                                                                    
    2.10 +# recursive dependencies scan
    2.11 +dep_scan()
    2.12 +{
    2.13  for i in $1; do
    2.14  	case " $ALL_DEPS " in
    2.15  	*\ $i\ *) continue;;
    2.16 @@ -294,9 +294,9 @@
    2.17  done
    2.18  }
    2.19  
    2.20 -# recursive reverse dependencies scan                       
    2.21 -rdep_scan()                                                           
    2.22 -{                                                                            
    2.23 +# recursive reverse dependencies scan
    2.24 +rdep_scan()
    2.25 +{
    2.26  SEARCH=$1
    2.27  case "$SEARCH" in
    2.28  glibc-base|gcc-lib-base) cat <<EOT
    2.29 @@ -349,6 +349,12 @@
    2.30  	return 1
    2.31  }
    2.32  
    2.33 +# Display < > &
    2.34 +htmlize()
    2.35 +{
    2.36 +	sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'
    2.37 +}
    2.38 +
    2.39  # Display search form and result if requested.
    2.40  if [ "$REQUEST_METHOD" != "POST" ]; then
    2.41  	xhtml_header
    2.42 @@ -449,19 +455,30 @@
    2.43  		unlzma -c $PACKAGES_REPOSITORY/files.list.lzma \
    2.44  		| grep ^$SEARCH: |  sed 's/.*: /    /' | sort
    2.45  	elif [ "$OBJECT" = "Desc" ]; then
    2.46 -		cat << _EOT_
    2.47 +		if [ -f $WOK/$SEARCH/description.txt ]; then
    2.48 +			cat << _EOT_
    2.49 +
    2.50 +<h3>$result</h3>
    2.51 +<pre class="package">
    2.52 +<pre>
    2.53 +$(htmlize < $WOK/$SEARCH/description.txt)
    2.54 +</pre>
    2.55 +_EOT_
    2.56 +		else
    2.57 +			cat << _EOT_
    2.58  
    2.59  <h3>$result</h3>
    2.60  <pre class="package">
    2.61  _EOT_
    2.62 -		last=""
    2.63 -		grep -i $SEARCH $PACKAGES_REPOSITORY/packages.desc | \
    2.64 -		sort | while read pkg extras ; do
    2.65 +			last=""
    2.66 +			grep -i $SEARCH $PACKAGES_REPOSITORY/packages.desc | \
    2.67 +			sort | while read pkg extras ; do
    2.68  				. $WOK/$pkg/receipt
    2.69  				cat << _EOT_
    2.70  <a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
    2.71  _EOT_
    2.72  			done
    2.73 +		fi
    2.74  	elif [ "$OBJECT" = "Tags" ]; then
    2.75  		cat << _EOT_
    2.76  
    2.77 @@ -485,8 +502,8 @@
    2.78  $(if [ -f  $WOK/$SEARCH/taz/*/receipt ]; then
    2.79  	cat $WOK/$SEARCH/taz/*/receipt
    2.80    else
    2.81 -    cat $WOK/$SEARCH//receipt
    2.82 -  fi | sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g')
    2.83 +    cat $WOK/$SEARCH/receipt
    2.84 +  fi | htmlize)
    2.85  </pre>
    2.86  _EOT_
    2.87  	else
    2.88 @@ -498,8 +515,10 @@
    2.89  		for pkg in `ls $WOK | grep $SEARCH`
    2.90  		do
    2.91  			. $WOK/$pkg/receipt
    2.92 +			DESC=" <a href=\"?desc=$pkg\">description</a>"
    2.93 +			[ -f $WOK/$pkg/description.txt ] || DESC=""
    2.94  			cat << _EOT_
    2.95 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
    2.96 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC$DESC
    2.97  _EOT_
    2.98  		done
    2.99  		equiv=$PACKAGES_REPOSITORY/packages.equiv