sup rev 26
sup.cgi: some fixes, better page look
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon Feb 27 14:48:07 2017 +0100 (2017-02-27) |
parents | 996be4ac95de |
children | 22ba9f7c9f8d |
files | server/sup/sup.cgi |
line diff
1.1 --- a/server/sup/sup.cgi Mon Feb 27 13:24:42 2017 +0100 1.2 +++ b/server/sup/sup.cgi Mon Feb 27 14:48:07 2017 +0100 1.3 @@ -18,10 +18,10 @@ 1.4 . /usr/lib/slitaz/httphelper.sh 1.5 fi 1.6 1.7 -host="http://scn.slitaz.org/" 1.8 -scn="/home/slitaz/www/scn" 1.9 -#host="http://localhost/~pankso/cgi-bin/scn/" 1.10 -#scn="/home/pankso/Public/cgi-bin/scn" 1.11 +#host="http://scn.slitaz.org/" 1.12 +#scn="/home/slitaz/www/scn" 1.13 +host="http://localhost/~pankso/cgi-bin/scn/" 1.14 +scn="/home/pankso/Public/cgi-bin/scn" 1.15 1.16 supdb="$content/sup" 1.17 wok="$supdb/wok" 1.18 @@ -46,22 +46,51 @@ 1.19 if ! . ${wok}/${pkg}/receip; then 1.20 echo "Missing or corrupted receip" && exit 1 1.21 fi 1.22 + 1.23 cat << EOT 1.24 <h2>$(gettext "Package:") $PACKAGE $VERSION</h2> 1.25 <div id="tools"> 1.26 <a title="Right click to download link: $PACKAGE-$VERSION.sup" 1.27 href='$packages/$PACKAGE-$VERSION.sup'>Download</a> 1.28 - <a href='?sup'>SUP Hub</a> 1.29 EOT 1.30 # Tools for logged users 1.31 if check_auth; then 1.32 - cat << EOT 1.33 + # Only package owner can update a package MAIL is set by check_auth 1.34 + if [ "$MAINTAINER" == "$MAIL" ]; then 1.35 + cat << EOT 1.36 <a href="?sup=upload">$(gettext "Update package")</a> 1.37 EOT 1.38 + fi 1.39 fi 1.40 cat << EOT 1.41 + <a href='?sup'>SUP Hub</a> 1.42 </div> 1.43 +<pre> 1.44 +${SHORT_DESC} 1.45 +</pre> 1.46 1.47 +EOT 1.48 + # Get package maintainer/user info from SCN/SliTaz user DB 1.49 + if ! . $(fgrep -l "MAIL=\"${MAINTAINER}\"" ${PEOPLE}/*/account.conf); then 1.50 + USER="unknow" 1.51 + fi 1.52 + cat << EOT 1.53 +<div> 1.54 + <a href="?user=$USER">$(get_gravatar $MAINTAINER 24)</a> 1.55 + $(gettext "Maintainer:") <a href="?user=$USER">$NAME</a> - 1.56 + $(gettext "Build date:") ${build_date} - 1.57 + $(gettext "License:") $LICENSE 1.58 +</div> 1.59 +EOT 1.60 + # README 1.61 + if [ -f "${wok}/${pkg}/README" ]; then 1.62 + echo "<h3>README</h3>" 1.63 + echo "<pre>" 1.64 + cat ${wok}/${pkg}/README 1.65 + echo "</pre>" 1.66 + fi 1.67 + # Receip 1.68 + cat << EOT 1.69 <h3>$(gettext "Receip")</h3> 1.70 <pre> 1.71 $(cat ${wok}/${pkg}/receip | receip_highlighter) 1.72 @@ -125,15 +154,16 @@ 1.73 # Use COOKIE to make sure user is logged in SCN/SUP Hub 1.74 user="$(echo $(COOKIE auth) | cut -d ':' -f 1)" 1.75 if [ "$(COOKIE auth)" ] && [ "$user" != "$(GET user)" ]; then 1.76 - clean_error "user auth cookie" && exit 1 1.77 + clean_error "user auth cookie"; exit 1 1.78 fi 1.79 1.80 #if [ ! -f "$pkgsdb" ]; then 1.81 #echo "<pre>ERROR: missing $pkgsdb</pre>" && exit 1 1.82 #fi 1.83 1.84 - if [ "$supfile" != "${supfile%.sup}.sip" ]; then 1.85 - clean_error "not a .sup package" && exit 1 1.86 + # Is it a .sup file ? 1.87 + if [ "$supfile" != "${supfile%.sup}.sup" ]; then 1.88 + clean_error "not a .sup package: $supfile"; exit 1 1.89 fi 1.90 1.91 cat << EOT 1.92 @@ -152,10 +182,6 @@ 1.93 Package file : ${supfile} 1.94 EOT 1.95 1.96 - # Is it a .sup file 1.97 - 1.98 - 1.99 - 1.100 mkdir -p ${cache} 1.101 if ! mv -f ${tmpfile} ${cache}/${supfile}; then 1.102 clean_error "moving: ${tmpfile} to ${supfile}" 1.103 @@ -191,7 +217,7 @@ 1.104 echo " <span class='value'>$(gettext 'no')</span>" 1.105 fi 1.106 1.107 - # Logged user is maintainaer ? 1.108 + # Logged user is maintainer ? 1.109 if [ "$MAINTAINER" != "$(GET mail)" ]; then 1.110 error=1 1.111 echo -e "\n<span class='error'>WARNING: user mail not matching</span>" 1.112 @@ -204,8 +230,8 @@ 1.113 gettext "Moving package to mirror..." 1.114 mv -f ${supfile} ${packages}; status 1.115 gettext "Moving receip to public wok..." 1.116 - mkdir -p ${wok}/${PACKAGE} && mv -f receip ${wok}/${PACKAGE} 1.117 - status 1.118 + mkdir -p ${wok}/${PACKAGE} && mv -f receip ${wok}/${PACKAGE}; status 1.119 + [ -f "README" ] && mv -f README ${wok}/${PACKAGE} 1.120 1.121 # Handle packages.md5 1.122