slitaz-dev-tools rev 120

tazwikiss/wkp_Admin: shrink to 4K, add section separators
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jun 19 14:03:36 2011 +0200 (2011-06-19)
parents a5349e79042b
children 229bf48d394c
files tazwikiss/rootfs/var/www/wiki/plugins/wkp_Admin.sh
line diff
     1.1 --- a/tazwikiss/rootfs/var/www/wiki/plugins/wkp_Admin.sh	Sat Jun 18 22:46:27 2011 +0200
     1.2 +++ b/tazwikiss/rootfs/var/www/wiki/plugins/wkp_Admin.sh	Sun Jun 19 14:03:36 2011 +0200
     1.3 @@ -11,28 +11,33 @@
     1.4  	done
     1.5  }
     1.6  
     1.7 +admin_download()
     1.8 +{
     1.9 +	cat - $1 <<EOT
    1.10 +Content-Type: application/octet-stream
    1.11 +Content-Length: $(stat -c %s $1)
    1.12 +Content-Disposition: attachment; filename=${2:-$1}
    1.13 +
    1.14 +EOT
    1.15 +}
    1.16 +
    1.17  action()
    1.18  {
    1.19  	case "$1" in
    1.20  	list|config|admin);;
    1.21 -	backup)	if [ -z "$(FILE file tmpname)" ]; then
    1.22 +	backup)	file=$(FILE file tmpname)
    1.23 +		if [ -z "$file" ]; then
    1.24  			file=$(mktemp -p /tmp)
    1.25  			find */ | cpio -o -H newc | gzip -9 > $file
    1.26 -			cat - $file <<EOT
    1.27 -Content-Type: application/octet-stream
    1.28 -Content-Length: $(stat -c %s $file)
    1.29 -Content-Disposition: attachment; filename=wiki-$(date '+%Y%m%d%H%M').cpio.gz
    1.30 -
    1.31 -EOT
    1.32 +			admin_download $file wiki-$(date '+%Y%m%d%H%M').cpio.gz
    1.33  			rm -f $file
    1.34  			exit 0
    1.35  		else
    1.36 -			file=$(FILE file tmpname)
    1.37  			zcat $file | cpio -idmu $(echo */ | sed 's|/||g')
    1.38  			rm -rf $(dirname $file)
    1.39  			return 1
    1.40  		fi ;;
    1.41 -	*) return 1 ;;
    1.42 +	*)	return 1 ;;
    1.43  	esac
    1.44  	PAGE_TITLE_link=false
    1.45  	editable=false
    1.46 @@ -50,31 +55,26 @@
    1.47  		[ -n "$curpassword" ] && echo $curpassword | md5sum > $secret
    1.48  	fi
    1.49  	if [ -n "$(POST save)" ]; then
    1.50 -		cat <<EOT
    1.51 -Content-Type: application/octet-stream
    1.52 -Content-Length: $(stat -c %s $(POST file))
    1.53 -Content-Disposition: attachment; filename=$(POST file)
    1.54 -
    1.55 -EOT
    1.56 -		cat $(POST file)
    1.57 +		admin_download $(POST file)
    1.58  		exit 0
    1.59  	fi
    1.60  	[ -n "$(POST restore)" ] && mv -f $(FILE data tmpname) $(POST file)
    1.61  	admin_enable locales config- config_ ./
    1.62  	admin_enable plugins wkp_ wkp_ plugins/
    1.63 +	disabled="disabled=disabled"
    1.64 +	[ -n "$curpassword" ] && disabled="" && 
    1.65 +	curpassword="<input type=\"hidden\" name=\"curpassword\" value=\"$curpassword\" />
    1.66 +"
    1.67 +	hr="$curpassword<tr><td colspan=2><hr /></td><tr />"
    1.68  	CONTENT="
    1.69  <table width=\"100%\">
    1.70  <form method=\"post\" action=\"?action=admin\">
    1.71  <tr><td><h2>$MDP</h2></td>
    1.72 -<td><input type=\"text\" name=\"password\" />
    1.73 -<input type=\"hidden\" name=\"curpassword\" value=\"$curpassword\" />
    1.74 +<td><input type=\"text\" name=\"password\" />$curpassword
    1.75  <input type=\"submit\" value=\"$DONE_BUTTON\" name=\"setpassword\" /></td></tr>
    1.76 -</form>"
    1.77 -	disabled=
    1.78 -	[ -z "$curpassword" ] && disabled="disabled=disabled"
    1.79 -	CONTENT="$CONTENT
    1.80 +</form>
    1.81  <form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=admin\">
    1.82 -<input type=\"hidden\" name=\"curpassword\" value=\"$curpassword\" />
    1.83 +$hr
    1.84  <tr><td><h2>Plugins</h2></td>
    1.85  <td><input type=\"submit\" $disabled value=\"$DONE_BUTTON\" name=\"plugins\" /></td></tr>
    1.86  "
    1.87 @@ -93,16 +93,14 @@
    1.88  	CONTENT="$CONTENT
    1.89  </form>
    1.90  <form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=admin\">
    1.91 -<input type=\"hidden\" name=\"curpassword\" value=\"$curpassword\" />
    1.92 -<p></p>
    1.93 +$hr
    1.94  <tr><td><h2>Locales</h2></td>
    1.95  <td><input type=\"submit\" $disabled value=\"$DONE_BUTTON\" name=\"locales\" /></td></tr>
    1.96  "
    1.97  	for i in config-*.sh ; do
    1.98  		j=${i#config-}
    1.99  		j=${j%.sh}
   1.100 -		[ -n "$j" ] || continue
   1.101 -	CONTENT="$CONTENT
   1.102 +		[ -n "$j" ] && CONTENT="$CONTENT
   1.103  <tr><td><b>
   1.104  <input type=checkbox $disabled $([ -x $i ] && echo 'checked=checked ') name=\"config_$j\" />
   1.105  $j</b></td><td><i>$(. ./$i ; echo $WIKI_TITLE)</i></td></tr>
   1.106 @@ -111,10 +109,9 @@
   1.107  	CONTENT="$CONTENT
   1.108  </form>
   1.109  <form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=admin\">
   1.110 -<input type=\"hidden\" name=\"curpassword\" value=\"$curpassword\" />
   1.111 -<tr></tr>
   1.112 -<tr><td><h2>Configuration</h2></td><td>
   1.113 -<select name="file" $disabled>
   1.114 +$hr
   1.115 +<tr><td><h2>Configuration</h2></td>
   1.116 +<td><select name="file" $disabled>
   1.117  $(for i in template.html style.css config*.sh; do
   1.118    [ -x $i ] && echo "<option>$i</option>"; done)
   1.119  </select>
   1.120 @@ -122,16 +119,14 @@
   1.121  <input type=\"file\" $disabled name=\"data\" />
   1.122  <input type=\"submit\" $disabled value=\"$RESTORE\" name=\"restore\" /></td></tr>
   1.123  </form>
   1.124 -<tr></tr>
   1.125  <form method=\"post\" enctype=\"multipart/form-data\" action=\"?action=backup\">
   1.126 -<input type=\"hidden\" name=\"curpassword\" value=\"$curpassword\" />
   1.127 +$hr
   1.128  <tr><td><h2>Data</h2></td>
   1.129  <td><input type=\"submit\" $disabled name=\"save\" value=\"$DONE_BUTTON\" />
   1.130  <input type=\"file\" $disabled name=\"file\" value=\"file\" />
   1.131 -<input type=\"submit\" $disabled name=\"restore\" value=\"$RESTORE\" />"
   1.132 -	CONTENT="$CONTENT
   1.133 +<input type=\"submit\" $disabled name=\"restore\" value=\"$RESTORE\" />
   1.134  </td></tr>
   1.135 -$(du -hs */ | awk '{ printf "<tr><td><b>%s</b></td><td><i>%s</i></td></tr>\n",$1,$2 }')
   1.136 +$(du -hs */ | sed 's|\(.*\)\t\(.*\)|<tr><td><b>\1</b></td><td><i>\2</i></td></tr>|')
   1.137  </form>
   1.138  </table>
   1.139  "