slitaz-forge rev 266

pkgs: introduce httphelper.sh and $(GET var)
author Christophe Lincoln <pankso@slitaz.org>
date Fri Apr 13 00:44:00 2012 +0200 (2012-04-13)
parents dea449c5be89
children 23e29516f2f5
files pkgs/lib/header.sh pkgs/search.sh
line diff
     1.1 --- a/pkgs/lib/header.sh	Thu Apr 12 13:38:03 2012 +0200
     1.2 +++ b/pkgs/lib/header.sh	Fri Apr 13 00:44:00 2012 +0200
     1.3 @@ -29,4 +29,7 @@
     1.4  	<h1><a href="./">$(gettext "SliTaz Packages")</a></h1>
     1.5  </div>
     1.6  
     1.7 +<!-- Content -->
     1.8 +<div id="content">
     1.9 +
    1.10  _EOF_
     2.1 --- a/pkgs/search.sh	Thu Apr 12 13:38:03 2012 +0200
     2.2 +++ b/pkgs/search.sh	Fri Apr 13 00:44:00 2012 +0200
     2.3 @@ -3,8 +3,10 @@
     2.4  # Christophe Lincoln <pankso@slitaz.org>
     2.5  # Aleksej Bobylev <al.bobylev@gmail.com> - i18n
     2.6  #
     2.7 +. /usr/lib/slitaz/httphelper.sh
     2.8  
     2.9 -#renice 20
    2.10 +# This can be removed when we use $(GET var) PHP a like syntaxe from
    2.11 +# httphelper.sh
    2.12  read QUERY_STRING
    2.13  for i in $(echo $QUERY_STRING | sed 's/&/ /g'); do
    2.14  	i=$(httpd -d $i)
    2.15 @@ -18,7 +20,6 @@
    2.16  VERSION=cooking
    2.17  SCRIPT_NAME="search.sh"
    2.18  
    2.19 -
    2.20  # Internationalization
    2.21  . /usr/bin/gettext.sh
    2.22  TEXTDOMAIN='tazpkg-web'
    2.23 @@ -102,7 +103,6 @@
    2.24  
    2.25  export LANG
    2.26  
    2.27 -
    2.28  case "$OBJECT" in
    2.29  	File)	 	selected_file="selected";;
    2.30  	Desc)	 	selected_desc="selected";;
    2.31 @@ -126,11 +126,10 @@
    2.32  # unescape query
    2.33  SEARCH="$(echo $SEARCH | sed 's/%2B/+/g; s/%3A/:/g; s|%2F|/|g')"
    2.34  
    2.35 -
    2.36 -
    2.37  WOK=/home/slitaz/$SLITAZ_VERSION/wok
    2.38  PACKAGES_REPOSITORY=/home/slitaz/$SLITAZ_VERSION/packages
    2.39  
    2.40 +# --> header function from httphelper
    2.41  echo "Content-type: text/html"
    2.42  echo
    2.43  
    2.44 @@ -380,29 +379,27 @@
    2.45  done
    2.46  }
    2.47  
    2.48 +#
    2.49 +# Handle GET requests
    2.50 +#
    2.51 +case " $(GET) " in
    2.52 +	*\ debug\ *)
    2.53 +		xhtml_header
    2.54 +		echo "<h2>Debug info</h2>"
    2.55 +		echo "<p>LANG: $LANK</p>"
    2.56 +		httpinfo
    2.57 +		xhtml_footer 
    2.58 +		exit 0 ;;
    2.59 +esac
    2.60 +
    2.61  # Display search form and result if requested.
    2.62  if [ "$REQUEST_METHOD" != "POST" ]; then
    2.63 -	xhtml_header
    2.64 -	cat << _EOT_
    2.65 -
    2.66 -<!-- Content -->
    2.67 -<div id="content">
    2.68 -<a name="content"></a>
    2.69 -
    2.70 -<h2>$(gettext "Search for packages")</h2>
    2.71 -_EOT_
    2.72 +	echo "<h2>$(gettext "Search for packages")</h2>"
    2.73  	search_form
    2.74  	xhtml_footer
    2.75  else
    2.76  	xhtml_header
    2.77 -	cat << _EOT_
    2.78 -
    2.79 -<!-- Content -->
    2.80 -<div id="content">
    2.81 -<a name="content"></a>
    2.82 -
    2.83 -<h2>$(gettext "Search for packages")</h2>
    2.84 -_EOT_
    2.85 +	echo "$(gettext "Search for packages")</h2>"
    2.86  	search_form
    2.87  	if [ "$OBJECT" = "Depends" ]; then
    2.88  		if [ -z "$SEARCH" ]; then