wok-tiny rev 100

Update wiki, add module-serial
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Oct 31 16:32:19 2015 +0100 (2015-10-31)
parents a10bae21f602
children c9e797b1bf36
files custom-console/receipt lpd-config/receipt lpd-spooling-config/receipt module-serial/receipt module-usbserial/receipt p910nd/receipt wiki/stuff/var/www/wiki/config-de.sh wiki/stuff/var/www/wiki/config-fr.sh wiki/stuff/var/www/wiki/config.sh wiki/stuff/var/www/wiki/index.sh wiki/stuff/var/www/wiki/pages/Aide.txt wiki/stuff/var/www/wiki/pages/Help.txt wiki/stuff/var/www/wiki/pages/HelpTables.txt wiki/stuff/var/www/wiki/plugins/wkp_Admin.sh wiki/stuff/var/www/wiki/plugins/wkp_Calc.css wiki/stuff/var/www/wiki/plugins/wkp_Calc.sh wiki/stuff/var/www/wiki/plugins/wkp_ListPlugins.sh wiki/stuff/var/www/wiki/plugins/wkp_Password.sh wiki/stuff/var/www/wiki/plugins/wkp_Rss.sh wiki/stuff/var/www/wiki/plugins/wkp_Tables.sh wiki/stuff/var/www/wiki/plugins/wkp_Upload.sh wiki/stuff/var/www/wiki/style.css
line diff
     1.1 --- a/custom-console/receipt	Sat Oct 31 12:53:44 2015 +0100
     1.2 +++ b/custom-console/receipt	Sat Oct 31 16:32:19 2015 +0100
     1.3 @@ -8,6 +8,7 @@
     1.4  LICENSE="BSD"
     1.5  WEB_SITE="http://tiny.slitaz.org/"
     1.6  DEPENDS="base-tiny"
     1.7 +SUGGESTED="module-usbserial module-serial"
     1.8  CONFIG_FILES="/etc/inittab"
     1.9  
    1.10  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.11 @@ -28,7 +29,7 @@
    1.12  	[ -n "$TTYS" ] || TTYS=ttyS0
    1.13  	[ -n "$SPEED" ] || SPEED=38400
    1.14  	cat <<EOT
    1.15 -You can launch a serial console (ttyS0, ttyS1 ...) or the lguest console (hvc0)
    1.16 +You can launch a serial console (ttyS0, ttyS1 ... ttyUSB0 ...)
    1.17  <table>
    1.18  <tr>
    1.19  <td>Device</td>
     2.1 --- a/lpd-config/receipt	Sat Oct 31 12:53:44 2015 +0100
     2.2 +++ b/lpd-config/receipt	Sat Oct 31 16:32:19 2015 +0100
     2.3 @@ -8,6 +8,7 @@
     2.4  LICENSE="BSD"
     2.5  WEB_SITE="http://tiny.slitaz.org/"
     2.6  DEPENDS="base-tiny"
     2.7 +SUGGESTED="module-lp module-usblp"
     2.8  
     2.9  # Rules to gen a SliTaz package suitable for Tazpkg.
    2.10  genpkg_rules()
     3.1 --- a/lpd-spooling-config/receipt	Sat Oct 31 12:53:44 2015 +0100
     3.2 +++ b/lpd-spooling-config/receipt	Sat Oct 31 16:32:19 2015 +0100
     3.3 @@ -8,6 +8,7 @@
     3.4  LICENSE="BSD"
     3.5  WEB_SITE="http://tiny.slitaz.org/"
     3.6  DEPENDS="base-tiny"
     3.7 +SUGGESTED="module-lp module-usblp"
     3.8  
     3.9  # Rules to gen a SliTaz package suitable for Tazpkg.
    3.10  genpkg_rules()
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/module-serial/receipt	Sat Oct 31 16:32:19 2015 +0100
     4.3 @@ -0,0 +1,34 @@
     4.4 +# SliTaz package receipt.
     4.5 +
     4.6 +PACKAGE="module-serial"
     4.7 +VERSION="2.6.14"
     4.8 +CATEGORY="base-system"
     4.9 +SHORT_DESC="Kernel module for the serial port"
    4.10 +MAINTAINER="pascal.bellard@slitaz.org"
    4.11 +LICENSE="GPL2"
    4.12 +WEB_SITE="http://tiny.slitaz.org/"
    4.13 +WANTED="linux"
    4.14 +
    4.15 +# Rules to gen a SliTaz package suitable for Tazpkg.
    4.16 +genpkg_rules()
    4.17 +{
    4.18 +	local path
    4.19 +	export src=$WOK/$WANTED/source/linux-$VERSION
    4.20 +	export _pkg=$WOK/$WANTED/install
    4.21 +	path=lib/modules/$(ls $_pkg/lib/modules)/kernel
    4.22 +	mkdir -p $fs/$path $fs/dev
    4.23 +	$src/slitaz/list_modules.sh drivers/serial | while read module; do
    4.24 +		dir=$path/$(dirname $module)
    4.25 +		[ -d $fs/$dir ] || mkdir -p $fs/$dir
    4.26 +		cp -a $_pkg/$path/$module $fs/$dir
    4.27 +	done
    4.28 +	for i in 0 1 2 3; do
    4.29 +		mknod $fs/dev/ttyS$i c 4 $((64+$i))
    4.30 +	done
    4.31 +}
    4.32 +
    4.33 +# Post install/remove commands for Tazpkg.
    4.34 +post_install()
    4.35 +{
    4.36 +	echo ${PACKAGE#*-} >> $1/modules
    4.37 +}
     5.1 --- a/module-usbserial/receipt	Sat Oct 31 12:53:44 2015 +0100
     5.2 +++ b/module-usbserial/receipt	Sat Oct 31 16:32:19 2015 +0100
     5.3 @@ -16,12 +16,15 @@
     5.4  	export src=$WOK/$WANTED/source/linux-$VERSION
     5.5  	export _pkg=$WOK/$WANTED/install
     5.6  	path=lib/modules/$(ls $_pkg/lib/modules)/kernel
     5.7 -	mkdir -p $fs/$path
     5.8 +	mkdir -p $fs/$path $fs/dev
     5.9  	$src/slitaz/list_modules.sh drivers/usb/serial/usbserial.ko | while read module; do
    5.10  		dir=$path/$(dirname $module)
    5.11  		[ -d $fs/$dir ] || mkdir -p $fs/$dir
    5.12  		cp -a $_pkg/$path/$module $fs/$dir
    5.13  	done
    5.14 +	for i in 0 1 2 3; do
    5.15 +		mknod $fs/dev/ttyS$i c 188 $i
    5.16 +	done
    5.17  }
    5.18  
    5.19  # Post install/remove commands for Tazpkg.
     6.1 --- a/p910nd/receipt	Sat Oct 31 12:53:44 2015 +0100
     6.2 +++ b/p910nd/receipt	Sat Oct 31 16:32:19 2015 +0100
     6.3 @@ -12,6 +12,7 @@
     6.4  [ -n "$TARGET" ] || TARGET="i486"
     6.5  BUILD_DEPENDS="uclibc-cross-compiler-$TARGET"
     6.6  DEPENDS="base-tiny"
     6.7 +SUGGESTED="module-lp module-usblp"
     6.8  CONFIG_FILES="/etc/inetd.conf /etc/rcS.conf"
     6.9  
    6.10  # Rules to configure and make the package.
     7.1 --- a/wiki/stuff/var/www/wiki/config-de.sh	Sat Oct 31 12:53:44 2015 +0100
     7.2 +++ b/wiki/stuff/var/www/wiki/config-de.sh	Sat Oct 31 16:32:19 2015 +0100
     7.3 @@ -1,10 +1,11 @@
     7.4 -PASSWORD="test"
     7.5 +PASSWORD=""
     7.6  PAGES_DIR="pages/"
     7.7  BACKUP_DIR="historique/"
     7.8  
     7.9  LANG="de"
    7.10  WIKI_TITLE="WiKiss"
    7.11 -START_PAGE="Startseite"
    7.12 +#START_PAGE="Startseite"
    7.13 +START_PAGE="Welcome"
    7.14  HOME_BUTTON="Startseite"
    7.15  HELP_BUTTON="Hilfe"
    7.16  DEFAULT_CONTENT="Die Seite %page% ist leer."
     8.1 --- a/wiki/stuff/var/www/wiki/config-fr.sh	Sat Oct 31 12:53:44 2015 +0100
     8.2 +++ b/wiki/stuff/var/www/wiki/config-fr.sh	Sat Oct 31 16:32:19 2015 +0100
     8.3 @@ -1,4 +1,4 @@
     8.4 -PASSWORD="test"
     8.5 +PASSWORD=""
     8.6  PAGES_DIR="pages/"
     8.7  BACKUP_DIR="historique/"
     8.8  
     9.1 --- a/wiki/stuff/var/www/wiki/config.sh	Sat Oct 31 12:53:44 2015 +0100
     9.2 +++ b/wiki/stuff/var/www/wiki/config.sh	Sat Oct 31 16:32:19 2015 +0100
     9.3 @@ -1,4 +1,4 @@
     9.4 -PASSWORD="test"
     9.5 +PASSWORD=""
     9.6  PAGES_DIR="pages/"
     9.7  BACKUP_DIR="historique/"
     9.8  
    10.1 --- a/wiki/stuff/var/www/wiki/index.sh	Sat Oct 31 12:53:44 2015 +0100
    10.2 +++ b/wiki/stuff/var/www/wiki/index.sh	Sat Oct 31 16:32:19 2015 +0100
    10.3 @@ -5,13 +5,14 @@
    10.4  # Copyright (C) Pascal Bellard
    10.5  # Based on WiKiss - http://wikiss.tuxfamily.org/
    10.6  
    10.7 -. /usr/bin/httpd_helper.sh
    10.8 +. /usr/bin/httphelper.sh
    10.9  
   10.10 -CONFIG=config-${HTTP_ACCEPT_LANGUAGE%%,*}.sh
   10.11 -[ -r "$CONFIG" ] || CONFIG=config.sh
   10.12 +cd $(dirname $0)
   10.13 +CONFIG=config-${HTTP_ACCEPT_LANGUAGE%%[,;_-]*}.sh
   10.14 +[ -x "$CONFIG" ] || CONFIG=config.sh
   10.15  . ./$CONFIG
   10.16  
   10.17 -WIKI_VERSION="TazWiKiss 0.3"
   10.18 +WIKI_VERSION="Based on WiKiss 0.3"
   10.19  
   10.20  # Initialisations
   10.21  toc=''				# Table Of Content
   10.22 @@ -55,6 +56,12 @@
   10.23  	cache_auth "$PASSWORD"
   10.24  }
   10.25  
   10.26 +sedesc()
   10.27 +{
   10.28 +	echo "$1" | sed 's|[/&"]|\\&|g' | \
   10.29 +		sed ':a;N;$!ba;s|\n|\\n|g;s|'$(echo -en "\r")'||g'
   10.30 +}
   10.31 +
   10.32  plugin_call_method()
   10.33  {
   10.34  	local status
   10.35 @@ -69,13 +76,16 @@
   10.36  		. $i
   10.37  		eval $name "$@"
   10.38  		[ $? == 0 ] && status=true
   10.39 -	done
   10.40 +	done 2> /tmp/tazwiki$$stderr
   10.41 +	[ -s /tmp/tazwiki$$stderr ] &&
   10.42 +		logger -t "httpd/wiki/plugin" < /tmp/tazwiki$$stderr
   10.43 +	rm -f /tmp/tazwiki$$stderr 2> /dev/null
   10.44  	$status
   10.45  }
   10.46  
   10.47  curdate()
   10.48  {
   10.49 -	date '+%Y/%m/%d %H:%M'
   10.50 +	date '+%Y-%m-%d %H:%M'
   10.51  }
   10.52  
   10.53  filedate()
   10.54 @@ -108,18 +118,20 @@
   10.55  
   10.56  # Ecrire les modifications, s'il y a lieu
   10.57  PAGE_txt="$PAGES_DIR$PAGE_TITLE.txt"
   10.58 +plugin_call_method "init" $PAGE_txt
   10.59  if [ -n "$content" ]; then	# content => page
   10.60  	if authentified; then
   10.61 -		sed 's/</\&lt;/g' > $PAGE_txt <<EOT
   10.62 -$POST_content
   10.63 +		CR="$(echo -en '\r')"
   10.64 +		sed 's/</\&lt;/g;s/'$CR' /'$CR'\n/g' > $PAGE_txt <<EOT
   10.65 +$POST_content_1
   10.66  EOT
   10.67  		if [ -n "$BACKUP_DIR" ]; then
   10.68  			complete_dir_s="$BACKUP_DIR$PAGE_TITLE/"
   10.69 -			if [ -d "$complete_dir_s" ]; then
   10.70 +			if [ ! -d "$complete_dir_s" ]; then
   10.71  				mkdir -p $complete_dir_s
   10.72  				chmod 777 $complete_dir_s
   10.73  			fi
   10.74 -			cat >> $complete_dir_s$(curdate).bak <<EOT
   10.75 +			cat >> "$complete_dir_s$(curdate).bak" <<EOT
   10.76  
   10.77  // $datew / $REMOTE_ADDR
   10.78  $(cat $PAGE_txt)
   10.79 @@ -136,8 +148,8 @@
   10.80  if [ -r "$PAGE_txt" -o -n "$action" ]; then
   10.81  	CONTENT=""
   10.82  	if [ -e "$PAGE_txt" ]; then
   10.83 -		TIME=$(filedate $PAGE_txt)
   10.84 -		CONTENT="$(cat $PAGE_txt)"
   10.85 +		TIME=$(filedate "$PAGE_txt")
   10.86 +		CONTENT="$(cat "$PAGE_txt")"
   10.87  	fi
   10.88  	# Restaurer une page
   10.89  	[ -n "$(GET page)" -a -n "$gtime" -a "$(GET restore)" == 1 ] &&
   10.90 @@ -148,7 +160,7 @@
   10.91  EOT
   10.92  )"
   10.93  else
   10.94 -	CONTENT="$(sed -e "s#%page%#$PAGE_TITLE#" <<EOT
   10.95 +	CONTENT="$(sed -e "s/%page%/$(sedesc "$PAGE_TITLE")/" <<EOT
   10.96  $DEFAULT_CONTENT
   10.97  EOT
   10.98  )"
   10.99 @@ -161,19 +173,24 @@
  10.100  	local new
  10.101  	old="$BACKUP_DIR$(GET page)/$1"
  10.102  	new="$BACKUP_DIR$(GET page)/$2"
  10.103 -	[ -n "$2" ] || new=$PAGES_DIR$(GET page).txt
  10.104 +	[ -s "$old" ] || old=/dev/null
  10.105 +	[ -n "$2" -a "$2" != "none" ] || new=$PAGES_DIR$(GET page).txt
  10.106  	files="$old $new"
  10.107 -	[ "$old" -nt "$new" ] && files="$new $old"
  10.108 +	[ "$old" -nt "$new" -a "$old" != "/dev/null" ] && files="$new $old"
  10.109  	diff -aU 99999 $files | sed -e '1,3d' -e '/^\\/d' -e 's|$|<br/>|' \
  10.110 -	 -e 's|-\(.*\)$|<font color=red>\1</font>|' \
  10.111 -	 -e 's|+\(.*\)$|<font color=green>\1</font>|'
  10.112 +	 -e 's|^-\(.*\)$|<font color=red>\1</font>|' \
  10.113 +	 -e 's|^+\(.*\)$|<font color=green>\1</font>|'
  10.114  }
  10.115  
  10.116  # Actions speciales du Wiki
  10.117  case "$action" in
  10.118  edit)
  10.119  	editable=false
  10.120 -	HISTORY="<a href=\"$urlbase?page=$(urlencode $PAGE_TITLE)\&amp;action=history\" accesskey=\"6\" rel=\"nofollow\">$HISTORY_BUTTON</a><br />"
  10.121 +	HISTORY="<a href=\"$urlbase?page=$(urlencode $PAGE_TITLE)&amp;action=history\" accesskey=\"6\" rel=\"nofollow\">$HISTORY_BUTTON</a><br />"
  10.122 +	CONTENT="$(sed 's/%/\&#37;/g' <<EOT
  10.123 +$CONTENT
  10.124 +EOT
  10.125 +)"
  10.126  	CONTENT="<form method=\"post\" action=\"$urlbase\">
  10.127  <textarea name=\"content\" cols=\"83\" rows=\"30\" style=\"width: 100%;\">
  10.128  $CONTENT
  10.129 @@ -190,9 +207,9 @@
  10.130  history)
  10.131  	complete_dir="$BACKUP_DIR$PAGE_TITLE/"
  10.132  	if [ -n "$gtime" ]; then
  10.133 -		HISTORY="<a href=\"$urlbase?page=$PAGE_TITLE\&amp;action=history\" rel=\"nofollow\">$HISTORY_BUTTON</a>"
  10.134 +		HISTORY="<a href=\"$urlbase?page=$PAGE_TITLE&amp;action=history\" rel=\"nofollow\">$HISTORY_BUTTON</a>"
  10.135  		if [ -r "$complete_dir$gtime" ]; then
  10.136 -			HISTORY="$HISTORY <a href=\"$urlbase?page=$PAGE_TITLE\&amp;action=edit\&amp;time=$gtime&amp;restore=1\" rel=\"nofollow\">$RESTORE</a>"
  10.137 +			HISTORY="$HISTORY <a href=\"$urlbase?page=$PAGE_TITLE&amp;action=edit&amp;time=$gtime&amp;restore=1\" rel=\"nofollow\">$RESTORE</a>"
  10.138  			CONTENT="$(cat $complete_dir$gtime | sed -e s/$(echo -ne '\r')//g -e 's|$|<br/>|g')"
  10.139  		else
  10.140  			HISTORY="$HISTORY -"
  10.141 @@ -213,11 +230,11 @@
  10.142  	fi ;;
  10.143  diff)
  10.144  	if [ -n "$(GET f1)" ]; then
  10.145 -		HISTORY="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")\&amp;action=history\">$HISTORY_BUTTON</a>"
  10.146 -		CONTENT="$(htmldiff $(GET f1) $(GET f2) )"
  10.147 +		HISTORY="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")&amp;action=history\">$HISTORY_BUTTON</a>"
  10.148 +		CONTENT="$(htmldiff "$(GET f1)" "$(GET f2)" )"
  10.149  	else
  10.150  		# diff auto entre les 2 dernières versions
  10.151 -		ls "$BACKUP_DIR$PAGE_TITLE/" | sort -r | head -n 2 | while read f1 f2; do
  10.152 +		ls "$BACKUP_DIR$PAGE_TITLE/" | ( sort -r ; echo none ; echo ) | head -n 2 | while read f1 f2; do
  10.153  			redirect "$urlbase?page=$(urlencode "$PAGE_TITLE")&action=$action&f1=$f1&f2=$f2"
  10.154  		done
  10.155  	fi ;;
  10.156 @@ -260,7 +277,8 @@
  10.157  		mkdir $tmpdir
  10.158  		unesc="$(echo "$CONTENT" | sed 's/\^\(.\)/\n^\1\n/g' | grep '\^' |\
  10.159  		  sort | uniq | grep -v "['[!]" | hexdump -e '"" 3/1 "%d " "\n"' |\
  10.160 -		  awk '{ printf "-e '\''s/\\^%c/\\&#%d;/g'\'' ",$2,$2}') \
  10.161 +		  awk '{ printf "-e '\''s/\\^%c/\\&#%d;/g'\'' ",$2,$2}' | \
  10.162 +		  sed 's/\^\([*.]\)/^\\\1/') \
  10.163  		  -e 's/\\^'\\''/\\&#39;/g' -e 's/\^\!/\&#33;/g' \
  10.164  		  -e 's/\^\[/\&#91;/g'"
  10.165  		CONTENT="$(eval sed $unesc <<EOT | \
  10.166 @@ -304,12 +322,22 @@
  10.167  		 	-e 's/([eE])/\&euro;/g' -e 's/([pP])/\&pound;/g' \
  10.168  		 	-e 's/([yY])/\&yen;/g'  -e 's/([tT][mM])/\&trade;/g' \
  10.169  		 	-e 's/([cC])/\&copy;/g' -e 's/([rR])/\&reg;/g' \
  10.170 +		 	-e 's/([dD])/\&deg;/g'  -e 's/(1\/2)/\&frac12;/g' \
  10.171 +		 	-e 's/(1\/4)/\&frac14;/g' -e 's/(3\/4)/\&frac34;/g' \
  10.172 +		 	-e 's/(phone)/\&#9742;/' -e 's/(wphone)/\&#9743;/' \
  10.173 +		 	-e 's/(skull)/\&#9760;/' -e 's/(radioactive)/\&#9762;/' \
  10.174 +		 	-e 's/(sad)/\&#9785;/'  -e 's/(smile)/\&#9786;/' \
  10.175 +		 	-e 's/(recycle)/\&#9842;/' -e 's/(wheelchair)/\&#9855;/' \
  10.176 +		 	-e 's/(wflag)/\&#9872;/' -e 's/(bflag)/\&#9873;/' \
  10.177 +		 	-e 's/(anchor)/\&#9875;/' -e 's/(flower)/\&#9880;/' \
  10.178 +		 	-e 's/(gear)/\&#9881;/' -e 's/(volt)/\&#9889;/' \
  10.179 +		 	-e 's/(warn)/\&#9888;/' -e 's/(star)/\&#9733;/' \
  10.180  		 	-e 's/(&lt;=)/\&le;/g'  -e 's/(>=)/\&ge;/g' \
  10.181  		 	-e 's/(!=)/\&ne;/g'     -e 's/(+-)/\&plusmn;/g' <<EOT
  10.182  $CONTENT
  10.183  EOT
  10.184  )"
  10.185 -		rg_url="[0-9a-zA-Z\.\#/~\-\_%=\?\&,\+\:@;!\(\)\*\$']*" # TODO: verif & / &amp;
  10.186 +		rg_url="[0-9a-zA-Z\.\#/~\_%=\?\&,\+\:@;!\(\)\*\$'\-]*" # TODO: verif & / &amp;
  10.187  		rg_link_local="$rg_url"
  10.188  		rg_link_http="https\?://$rg_url"
  10.189  		rg_img_local="$rg_url\.jpe\?g\|$rg_url\.gif\|$rg_url\.png"
  10.190 @@ -317,6 +345,8 @@
  10.191  
  10.192  		# image, image link, link, wikipedia, email ...
  10.193  		CONTENT="$(sed \
  10.194 +			-e "s#\[\($rg_img_http\)\]#<img src=\"\1\" alt=\"\1\" style=\"float:\"/>#g" \
  10.195 +			-e "s#\[\($rg_img_local\)\]#<img src=\"\1\" alt=\"\1\" style=\"float:\"/>#g" \
  10.196  			-e "s#\[\($rg_img_http\)|*\([a-z]*\)*\]#<img src=\"\1\" alt=\"\1\" style=\"float:\2;\"/>#g" \
  10.197  			-e "s#\[\($rg_img_local\)|*\([a-z]*\)*\]#<img src=\"\1\" alt=\"\1\" style=\"float:\2;\"/>#g" \
  10.198  			-e "s#\[\($rg_img_http\)|\($rg_link_http\)|*\([a-z]*\)*\]#<a href=\"\2\" class=\"url\"><img src=\"\1\" alt=\"\1\" title=\"\1\"style=\"float:\3;\"/></a>#g" \
  10.199 @@ -341,6 +371,7 @@
  10.200  			-e ':x;/<\/ul>$/{N;s/\n//;$P;$D;bx;}' | sed \
  10.201  			-e ':x;s/<\/ul><ul>//g;tx' -e ':x;s/<\/ol><ol>//g;tx' \
  10.202  			-e 's|----*$|<hr />|' -e 's|$|<br />|' \
  10.203 +			-e 's|</ul>|&\n|g' -e 's|</ol>|&\n|g' \
  10.204  			-e 's#</li>#&\n#g' -e 's#\(</h[123456]>\)<br />#\1#g' \
  10.205  			-e "s#'--\([^']*\)--'#<del>\1</del>#g" \
  10.206  			-e "s#'__\([^']*\)__'#<u>\1</u>#g" \
  10.207 @@ -351,8 +382,8 @@
  10.208  EOT
  10.209  )"
  10.210  		while read link; do
  10.211 -			[ -s $PAGES_DIR$link.txt ] && continue
  10.212 -			CONTENT="$(sed "s/\\?page=$link\"/& class=\"pending\"/" <<EOT
  10.213 +			[ -s "$PAGES_DIR$link.txt" ] && continue
  10.214 +			CONTENT="$(sed "s/\\?page=$(sedesc "$link")\"/& class=\"pending\"/" <<EOT
  10.215  $CONTENT
  10.216  EOT
  10.217  )"
  10.218 @@ -368,38 +399,44 @@
  10.219  EOT
  10.220  )"
  10.221  		done
  10.222 +		read hastoc <<EOT
  10.223 +$CONTENT
  10.224 +EOT
  10.225  		CONTENT="$(sed -e 's/^ /\&nbsp;\&nbsp;\&nbsp;\&nbsp;/' -e '1s/^TOC//' <<EOT
  10.226  $CONTENT
  10.227  EOT
  10.228  )"
  10.229  		toc='<div id="toc">'
  10.230 -		i=1
  10.231 -		for pat in '^![^!]' '^!![^!]' '^!!![^!]' '^!!!![^!]' '^!!!!!' ; do
  10.232 -			while read line; do
  10.233 -				[ -n "$line" ] || continue
  10.234 -				label="$(echo $line | sed 's/[^\dA-Za-z]/_/g')"
  10.235 -				toc="$(cat <<EOT
  10.236 +		while read line; do
  10.237 +			[ -n "$line" ] || continue
  10.238 +			i=$(echo "$line" | sed 's/^!\(!*\).*/\1/' | wc -c)
  10.239 +			line="$(echo "$line" | sed 's/^!!*//')"
  10.240 +			label="$(echo "$line" | sed 's/[^\dA-Za-z]/_/g')"
  10.241 +			toc="$(cat <<EOT
  10.242  $toc
  10.243  	<h$i><a href="#$label">$line</a></h$i>
  10.244  EOT
  10.245  )"
  10.246 -				CONTENT="$(sed "s#^!!* *$line\$#<h$i><a name=\"$label\">$line</a></h$i>#" <<EOT
  10.247 +			CONTENT="$(sed "s/^!!* *$(sedesc "$line")\$/<h$i><a name=\"$label\">$(sedesc "$line")<\/a><\/h$i>/" <<EOT
  10.248  $CONTENT
  10.249  EOT
  10.250  )"
  10.251 -			done <<EOT
  10.252 -$(grep "$pat" <<EOM | sed -e 's/^!!*//' -e 's/#/\#/g' -e 's/&/\\\&/g'
  10.253 +		done <<EOT
  10.254 +$(grep "^!" <<EOM | sed -e 's/#/\#/g' -e 's/&/\\\&/g'
  10.255  $CONTENT
  10.256  EOM
  10.257  )
  10.258  EOT
  10.259 -			i=$(( $i + 1 ))
  10.260 -		done
  10.261  		toc="$(cat <<EOT
  10.262  $toc
  10.263  </div>
  10.264  EOT
  10.265  )"
  10.266 +		false &&
  10.267 +		case "$hastoc" in
  10.268 +		TOC*) ;;
  10.269 +		*) toc='';;
  10.270 +		esac
  10.271  		CONTENT="$(awk -v tmpdir=$tmpdir '{
  10.272  s=$0
  10.273  while (1) {
  10.274 @@ -431,10 +468,10 @@
  10.275  [ "$action" != "edit" ] && HELP=""
  10.276  
  10.277  [ -r "$template" ] || die "'$template' is missing!"
  10.278 -html="$(sed -e "s#{\([^}]*\)RECENT_CHANGES\([^}]*\)}#\1$RECENT\2#" \
  10.279 -           -e "s#{\([^}]*\)HOME\([^}]*\)}#\1$HOME\2#" \
  10.280 -           -e "s#{\([^}]*\)HELP\([^}]*\)}#$HELP#" \
  10.281 -           -e "s#{SEARCH}#<form method=\"get\" action=\"$urlbase?page=$(urlencode "$PAGE_TITLE" | sed 's/#/\\#/g')\"><div><input type=\"hidden\" name=\"action\" value=\"search\" /><input type=\"text\" name=\"query\" value=\"$(htmlentities $(GET query) )\" tabindex=\"1\" /> <input type=\"submit\" value=\"$SEARCH_BUTTON\" accesskey=\"q\" /></div></form>#" \
  10.282 +html="$(sed -e "s/{\([^}]*\)RECENT_CHANGES\([^}]*\)}/\1$(sedesc "$RECENT")\2/" \
  10.283 +           -e "s/{\([^}]*\)HOME\([^}]*\)}/\1$(sedesc "$HOME")\2/" \
  10.284 +           -e "s/{\([^}]*\)HELP\([^}]*\)}/$(sedesc "$HELP")/" \
  10.285 +           -e "s/{SEARCH}/<form method=\"get\" action=\"$(sedesc "$urlbase?page=$(urlencode "$PAGE_TITLE" | sed 's/#/\\#/g')")\"><div><input type=\"hidden\" name=\"action\" value=\"search\" \/><input type=\"text\" name=\"query\" value=\"$(sedesc "$(htmlentities $(GET query) )")\" tabindex=\"1\" \/> <input type=\"submit\" value=\"$(sedesc "$SEARCH_BUTTON")\" accesskey=\"q\" \/><\/div><\/form>/" \
  10.286             < $template )"
  10.287  [ "$action" != "" -a "$action" != "edit" -o ! -e "$PAGE_txt" ] && TIME="-"
  10.288  plugin_call_method template
  10.289 @@ -447,37 +484,40 @@
  10.290  if $editable ; then
  10.291  	EDIT="$PROTECTED_BUTTON"
  10.292  	[ -w "$PAGE_txt" -o ! -e "$PAGE_txt" ] &&
  10.293 -        EDIT="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")\&amp;action=edit\" accesskey=\"5\" rel=\"nofollow\">$EDIT_BUTTON</a>"
  10.294 +        EDIT="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")&amp;action=edit\" accesskey=\"5\" rel=\"nofollow\">$EDIT_BUTTON</a>"
  10.295  fi
  10.296 -[ -n "$toc" ] && toc="\1$toc\2"
  10.297 +[ $(echo "$toc" | wc -l) -gt 2 ] && toc="\1$toc\2" || toc=""
  10.298  AUTH_GET=""
  10.299  AUTH_POST=""
  10.300  if authentified; then
  10.301 -	AUTH_GET="auth=$AUTH\&"
  10.302 +	AUTH_GET="auth=$AUTH&"
  10.303  	AUTH_POST="\n<input type=\"hidden\" name=\"auth\" value=\"$AUTH\" />"
  10.304  fi
  10.305  
  10.306 -header
  10.307 -sed	-e "s#{ERROR}#$ERROR#"		-e "s#{WIKI_TITLE}#$WIKI_TITLE#" \
  10.308 -	-e "s#{\([^}]*\)HISTORY\([^}]*\)}#$HISTORY#" \
  10.309 -	-e "s#{PAGE_TITLE}#$PAGE_TITLE_str#" \
  10.310 -	-e "s#{\([^}]*\)EDIT\([^}]*\)}#\1$EDIT\2#" \
  10.311 -	-e "s|{\([^}]*\)TOC\([^}]*\)}|$(awk '{ printf "%s\\n" $0 }' <<EOT | \
  10.312 -		sed -e 's/&/\\\&/g' -e 's/|/\\|/g'
  10.313 -$toc
  10.314 +html2="$(sed	-e "s/{ERROR}/$(sedesc "$ERROR")/" \
  10.315 +	-e "s/{WIKI_TITLE}/$(sedesc "$WIKI_TITLE")/" \
  10.316 +	-e "s/{\([^}]*\)HISTORY\([^}]*\)}/$(sedesc "$HISTORY")/" \
  10.317 +	-e "s/{PAGE_TITLE}/$(sedesc "$PAGE_TITLE_str")/" \
  10.318 +	-e "s/{\([^}]*\)EDIT\([^}]*\)}/\1$(sedesc "$EDIT")\2/" \
  10.319 +	-e "s/{\([^}]*\)TOC\([^}]*\)}/$(sedesc "$toc")/" \
  10.320 +	-e "s/{PAGE_TITLE_BRUT}/$(sedesc "$(htmlentities "$PAGE_TITLE")")/" \
  10.321 +	-e "s/{LAST_CHANGE}/$(sedesc "$LAST_CHANGES") :/" \
  10.322 +	-e "s/{LANG}/$(sedesc "$LANG")/g" \
  10.323 +	-e "s/href=\"?/href=\"$(sedesc "$urlbase?$AUTH_GET")/g" \
  10.324 +	-e "s/action=\"$(sedesc "$urlbase")\">/&$(sedesc "$AUTH_POST")/g" \
  10.325 +	-e "s/{WIKI_VERSION}/$(sedesc "$WIKI_VERSION")/" \
  10.326 +	-e "s/{TIME}/$(sedesc "$TIME")/" -e "s/{DATE}/$(sedesc "$datew")/" \
  10.327 +	-e "s/{IP}/$REMOTE_ADDR/" -e "s/{COOKIE}//" -e "s/{RSS}//" <<EOT
  10.328 +$html
  10.329  EOT
  10.330 -)|" \
  10.331 -	-e "s#{PAGE_TITLE_BRUT}#$(htmlentities "$PAGE_TITLE")#" \
  10.332 -	-e "s#{LAST_CHANGE}#$LAST_CHANGES :#" \
  10.333 -	-e "s#{CONTENT}#$(awk '{ printf "%s\\n" $0 }' <<EOT | \
  10.334 -		sed -e 's/&/\\\&/g' -e 's/#/\\#/g'
  10.335 +)"
  10.336 +header "Content-type: text/html"
  10.337 +sed '/{CONTENT}/{s/{CONTENT}.*//;q}' <<EOT
  10.338 +$html2
  10.339 +EOT
  10.340 +cat <<EOT
  10.341  $CONTENT
  10.342  EOT
  10.343 -)#" \
  10.344 -	-e "s#{LANG}#$LANG#"		-e "s#href=\"?#href=\"$urlbase?#g" \
  10.345 -	-e "s#$urlbase?#&$AUTH_GET#g" -e "s#action=\"$urlbase\">#&$AUTH_POST#g" \
  10.346 -	-e "s#{WIKI_VERSION}#$WIKI_VERSION#" \
  10.347 -	-e "s#{TIME}#$TIME#"		-e "s#{DATE}#$datew#" \
  10.348 -	-e "s#{IP}#$REMOTE_ADDR#"	-e "s#{COOKIE}##" <<EOT
  10.349 -$html
  10.350 +sed ':a;N;/{CONTENT}/!ba;s/.*{CONTENT}//;:b;N;$!bb' <<EOT
  10.351 +$html2
  10.352  EOT
    11.1 --- a/wiki/stuff/var/www/wiki/pages/Aide.txt	Sat Oct 31 12:53:44 2015 +0100
    11.2 +++ b/wiki/stuff/var/www/wiki/pages/Aide.txt	Sat Oct 31 16:32:19 2015 +0100
    11.3 @@ -47,8 +47,11 @@
    11.4     print "Hello",sys.argv[1]}}
    11.5  ----
    11.6  Certains caractères spéciaux sont reconnus :
    11.7 -* Flèches : &lt;^-- : &lt;--, ^--> : -->, &lt;^--> : &lt;-->
    11.8 +* Flèches : &lt;^-- : &lt;--, ^--> : -->, &lt;^--> : &lt;-->, &lt;^== : &lt;==, ^==> : ==>, &lt;^==> : &lt;==>
    11.9  * Copyrights : ^(c) ou ^(C) : (c), ^(r) ou ^(R) : (r)
   11.10 +* Fractions : ^(1/2) : (1/2), ^(1/4) : (1/4), ^(3/4) : (3/4)
   11.11 +* Divers : ^(+-) : (+-), ^(!=) : (!=)
   11.12 +* Quelques icônes : ^(phone) : (phone), ^(wphone) : (wphone), ^(bflag) : (bflag), ^(wflag) : (wflag) ^(radioactive) : (radioactive), ^(sad) : (sad), ^(smile) : (smile), ^(recycle) : (recycle), ^(wheelchair) : (wheelchair), ^(anchor) : (anchor), ^(flower) : (flower), ^(gear) : (gear), ^(volt) : (volt), ^(warn) : (warn), ^(skull) : (skull), ^(star) : (star)
   11.13  ----
   11.14  Les liens externes et les adresses eMail sont reconnus automagiquement ...
   11.15  ^http://wikiss.tuxfamily.org/ --> http://wikiss.tuxfamily.org/
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/wiki/stuff/var/www/wiki/pages/Help.txt	Sat Oct 31 16:32:19 2015 +0100
    12.3 @@ -0,0 +1,130 @@
    12.4 +TOC
    12.5 +!Help
    12.6 +
    12.7 +Here is a summary of all the formatting rules in ''WiKiss''.
    12.8 +Click "Edit" on top or bottom of this page to see how it works.
    12.9 +(if you see "Page Locked", do a chmod 775 on this file via a ftp client)
   12.10 +
   12.11 +See also [AideTables] to create tables.
   12.12 +
   12.13 +----
   12.14 +
   12.15 +Tiles use the exclamation mark '''!'''
   12.16 +^! Big
   12.17 +^!! Less big
   12.18 +^!!! Smaller
   12.19 +gives you :
   12.20 +! Big
   12.21 +!! Less big
   12.22 +!!! Smaller
   12.23 +
   12.24 +To automatically add a table of contents in a page, add the '''TOC''' mark in it :
   12.25 +* at the last line to be clearer, there is no influence on position ;
   12.26 +* at the first line if you need to write TOC in your page. Only the first occurrence will be replaced.
   12.27 +
   12.28 +----
   12.29 +
   12.30 +Styles use the single quote '
   12.31 +* ^''^'Bold^''^' --> '''Bold'''
   12.32 +* ^''italic^'' --> ''italic''
   12.33 +* ^''^''^'Bold and italic^''^''^' --> '''''Bold and italic'''''
   12.34 +
   12.35 +----
   12.36 +
   12.37 +Stroke of a work use quote and two dashes
   12.38 +^'--Stroked--' --> '--Stroked--'
   12.39 +
   12.40 +the same applies for underline, quote followed by by two underscore
   12.41 +^'__Underlined__' --> '__Underlined__'
   12.42 +
   12.43 +----
   12.44 +
   12.45 +The ordered lists use sharp '''#'''
   12.46 +# First
   12.47 +# Second
   12.48 +# Third
   12.49 +
   12.50 +----
   12.51 +
   12.52 +Non ordered lists use the star '''*'''
   12.53 +* Apple
   12.54 +* Pear
   12.55 +* Peach
   12.56 +
   12.57 +----
   12.58 +
   12.59 +The code, and all of those things where formatting is important, use the braces
   12.60 +^{{import sys
   12.61 +if len(sys.argv) == 2:
   12.62 +   print "Hello",sys.argv^[1]}}
   12.63 +give :
   12.64 +{{import sys
   12.65 +if len(sys.argv) == 2:
   12.66 +   print "Hello",sys.argv[1]}}
   12.67 +
   12.68 +----
   12.69 +
   12.70 +The separation between paragraphs of text is done through an empty line.
   12.71 +To force a line break in the middle of a paragraph, use: ^
   12.72 +
   12.73 +----
   12.74 +
   12.75 +Some special characters are recognized:
   12.76 +* Arrows: &lt;^-- : &lt;--, ^--> : -->, &lt;^--> : &lt;-->, &lt;^== : &lt;==, ^==> : ==>, &lt;^==> : &lt;==>
   12.77 +* Copyrights: ^(c) or ^(C) : (c), ^(r) or ^(R) : (r)
   12.78 +* Fractions: ^(1/2) : (1/2), ^(1/4) : (1/4), ^(3/4) : (3/4)
   12.79 +* Miscellaneous: ^(+-) : (+-), ^(!=) : (!=)
   12.80 +* Some icons: ^(phone) : (phone), ^(wphone) : (wphone), ^(bflag) : (bflag), ^(wflag) : (wflag) ^(radioactive) : (radioactive), ^(sad) : (sad), ^(smile) : (smile), ^(recycle) : (recycle), ^(wheelchair) : (wheelchair), ^(anchor) : (anchor), ^(flower) : (flower), ^(gear) : (gear), ^(volt) : (volt), ^(warn) : (warn), ^(skull) : (skull), ^(star) : (star)
   12.81 +
   12.82 +----
   12.83 +
   12.84 +Links to wiki-pages use square brackets :
   12.85 +'''^['''Accueil''']''' --> [Accueil]
   12.86 +
   12.87 +If a page does not exists, it will be created on first click.
   12.88 +Click on "SandBox" below and you will be able to create it ...
   12.89 +[SandBox]
   12.90 +
   12.91 +To link a wiki-page with a different text use :
   12.92 +'''^['''Beginning'''|?page='''Accueil''']''' --> [Beginning|?page=Accueil]
   12.93 +
   12.94 +The external links and addresses eMail are automagically recognized ...
   12.95 +* ^http://wikiss.tuxfamily.org/ --> http://wikiss.tuxfamily.org/
   12.96 +* wikiss^@example.org --> wikiss@example.org
   12.97 +
   12.98 +or through a text between square brackets :
   12.99 +* '''^['''Visit WiKiss web site'''|'''^http://wikiss.tuxfamily.org/''']''' --> [Visit WiKiss web site|http://wikiss.tuxfamily.org/]
  12.100 +
  12.101 +with a ? you get a Wikipedia link in the current language :
  12.102 +* '''^[?'''Wiki''']''' --> [?Wiki]
  12.103 +
  12.104 +----
  12.105 +
  12.106 +Images are automagically inserted with the picture URL between square brackets
  12.107 +'''^['''^http://wikiss.tuxfamily.org/img/logo_100.png''']''' -->
  12.108 +[http://wikiss.tuxfamily.org/img/logo_100.png]
  12.109 +
  12.110 +You can also use an image as a link : 
  12.111 +'''^['''^http://wikiss.tuxfamily.org/img/logo_100.png'''|'''^http://wikiss.tuxfamily.org/''']''' --> 
  12.112 +[http://wikiss.tuxfamily.org/img/logo_100.png|http://wikiss.tuxfamily.org/]
  12.113 +
  12.114 +But also position the image on a floating left or right: 
  12.115 +[http://wikiss.tuxfamily.org/img/logo_100.png|left] [http://wikiss.tuxfamily.org/img/logo_100.png|http://wikiss.tuxfamily.org|right]
  12.116 +
  12.117 +
  12.118 +&lt;-- '''^['''^http://wikiss.tuxfamily.org/img/logo_100.png'''|left]'''
  12.119 +'''^['''^http://wikiss.tuxfamily.org/img/logo_100.png'''|'''^http://wikiss.tuxfamily.org'''|right]''' -->
  12.120 +
  12.121 +
  12.122 +----
  12.123 +
  12.124 +... to insert lines, simply use four dashes :  '''---- '''
  12.125 +
  12.126 +----
  12.127 +
  12.128 +Finally, in order to neutralize the syntax WiKiss, use the caret ^ 
  12.129 +Thus, enter '''^^^['''WiKiss''']''' can display ^[WiKiss] rather than [WiKiss]
  12.130 +
  12.131 +----
  12.132 +
  12.133 +Try it, you'll see, it's very simple.
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/wiki/stuff/var/www/wiki/pages/HelpTables.txt	Sat Oct 31 16:32:19 2015 +0100
    13.3 @@ -0,0 +1,70 @@
    13.4 +! Help on the table syntax
    13.5 +
    13.6 +!! Table creation
    13.7 +Tables are defined with the pipe character |
    13.8 +
    13.9 +Basically you just need to draw the table :
   13.10 +
   13.11 +{{|cell 1|cell 2|
   13.12 +|cell 3|cell 4|
   13.13 +}}
   13.14 +
   13.15 +will be displayed as :
   13.16 +|cell 1|cell 2|
   13.17 +|cell 3|cell 4|
   13.18 +
   13.19 +You can also format your cell. For that, add some characters at the beginning :
   13.20 +
   13.21 +* a '''h''' if the cell is a header
   13.22 +* more letters followed by a space to defined alignment :
   13.23 +** t : vertically aligned on top
   13.24 +** b : vertically aligned on bottom
   13.25 +** l : horizontally aligned on left
   13.26 +** r : horizontally aligned on right
   13.27 +* two numbers can be added to connect cells
   13.28 +** first one to give how many columns has to be connected
   13.29 +** second one, after a comma connects lines
   13.30 +
   13.31 +{{
   13.32 +|hl Title on left|hr Title on right|
   13.33 +|r right         |l    left    |
   13.34 +|2 Two columns                 |
   13.35 +|t ,2 Two lines  | A |
   13.36 +                 | B |
   13.37 +|,2 two lines    | C |
   13.38 +                 | D |}}
   13.39 +
   13.40 +|hl Title on left|hr title on right|
   13.41 +|r right       |l    left    |
   13.42 +|2 Two columns                |
   13.43 +|t ,2 Two lines  | A |
   13.44 +                 | B |
   13.45 +|,2 two lines    | C |
   13.46 +                 | D |
   13.47 +
   13.48 +!! Other syntax included in a table
   13.49 +
   13.50 +|h 3 Supported wiki syntax |
   13.51 +|ht ,7 Formatting | ^''italic^'' | ''italic'' |
   13.52 +                     |  '^''bold'^''  |  '''bold'''  |
   13.53 +                     |'^'^'^''bold italic'^'^'^''|'''''bold italic'''''|
   13.54 +                     |^'--stroked--'|'--stroked--'|
   13.55 +                     |^'__underlined__'|'__underlined__'|
   13.56 +                     | Special chars | (c) (r) --> &lt;-- |
   13.57 +                     |^{{code}}|{{code}}|
   13.58 +|ht ,3 Links         |^[WikiLink] | [WikiLink] |
   13.59 +                     |^[Link 2^|?page=Link]| [Link 2|?page=Link] |
   13.60 +                     |^[?Wikipedia]| [?Wikipedia] |
   13.61 +|ht ,4 Images        |^[^http://wikiss.tuxfamily.org/img/logo_100.png]|[http://wikiss.tuxfamily.org/img/logo_100.png]|
   13.62 +    |^[/logo_100.png^|^http://wikiss.tuxfamily.org/]|[http://wikiss.tuxfamily.org/img/logo_100.png|http://wikiss.tuxfamily.org/]|
   13.63 +    |^[^http://wikiss.tuxfamily.org/img/logo_100.png^|right] | [http://wikiss.tuxfamily.org/img/logo_100.png|right]|
   13.64 +    |^[/logo_100.png^|^http://wikiss.tuxfamily.org/^|left] | [http://wikiss.tuxfamily.org/img/logo_100.png|http://wikiss.tuxfamily.org/|left]|
   13.65 +
   13.66 +and
   13.67 +
   13.68 +|h 2 Not supported syntax|
   13.69 +|Titles   | !! Titles|
   13.70 +|,2 Lists | * non ordered |
   13.71 +          | # ordered |
   13.72 +|Lines    |----|
   13.73 +
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/wiki/stuff/var/www/wiki/plugins/wkp_Admin.sh	Sat Oct 31 16:32:19 2015 +0100
    14.3 @@ -0,0 +1,152 @@
    14.4 +plugin="<a href=\"?action=admin\" title=\"Wiki administration\">Administration</a>"
    14.5 +description_fr="Administration du Wiki"
    14.6 +description="Wiki administration"
    14.7 +      
    14.8 +admin_enable()
    14.9 +{
   14.10 +	[ -n "$(POST $1)" ] || return
   14.11 +	chmod 444 $4/$2*
   14.12 +	for i in $(POST); do
   14.13 +		case "$i" in $3*) chmod 755 $4/${i/$3/$2}.* ;; esac
   14.14 +	done
   14.15 +}
   14.16 +
   14.17 +admin_download()
   14.18 +{
   14.19 +	cat - $1 <<EOT
   14.20 +Content-Type: application/octet-stream
   14.21 +Content-Length: $(stat -c %s $1)
   14.22 +Content-Disposition: attachment; filename=${2:-$1}
   14.23 +
   14.24 +EOT
   14.25 +}
   14.26 +
   14.27 +action()
   14.28 +{
   14.29 +	case "$1" in
   14.30 +	list|config|admin);;
   14.31 +	backup)	file=$(FILE file tmpname)
   14.32 +		if [ -z "$file" ]; then
   14.33 +			file=$(mktemp -p /tmp)
   14.34 +			find */ | cpio -o -H newc | gzip -9 > $file
   14.35 +			admin_download $file wiki-$(date '+%Y%m%d%H%M').cpio.gz
   14.36 +			rm -f $file
   14.37 +			exit 0
   14.38 +		else
   14.39 +			zcat $file | cpio -idmu $(echo */ | sed 's|/||g')
   14.40 +			rm -rf $(dirname $file)
   14.41 +			return 1
   14.42 +		fi ;;
   14.43 +	*)	return 1 ;;
   14.44 +	esac
   14.45 +	PAGE_TITLE_link=false
   14.46 +	editable=false
   14.47 +	lang="${HTTP_ACCEPT_LANGUAGE%%[,;_-]*}"
   14.48 +	PAGE_TITLE="Administration"
   14.49 +	curpass="$(POST curpass)"
   14.50 +	secret="admin.secret"
   14.51 +	if [ -n "$(POST setpass)" ]; then
   14.52 +		if [ -z "$curpass" ]; then	# unauthorized
   14.53 +			if [ ! -s $secret -o "$(cat $secret 2> /dev/null)" == \
   14.54 +				  "$(echo $(POST password) | md5sum)" ]; then
   14.55 +				curpass="$(POST password)"
   14.56 +			fi
   14.57 +		fi
   14.58 +		[ -n "$curpass" ] && echo $curpass | md5sum > $secret &&
   14.59 +		chmod 400 $secret
   14.60 +	fi
   14.61 +	if [ -n "$(POST save)" ]; then
   14.62 +		admin_download $(POST file)
   14.63 +		exit 0
   14.64 +	fi
   14.65 +	[ -n "$(POST restore)" ] && mv -f $(FILE data tmpname) $(POST file)
   14.66 +	admin_enable Locales config- config_ .
   14.67 +	admin_enable Plugins wkp_ wkp_ plugins
   14.68 +	admin_enable Pages '' page pages
   14.69 +	disabled="disabled=disabled"
   14.70 +	[ -n "$curpass" ] && disabled="" && 
   14.71 +	curpass="<input type=\"hidden\" name=\"curpass\" value=\"$curpass\" />
   14.72 +"
   14.73 +	hr="$curpass<tr><td colspan=2><hr /></td><tr />"
   14.74 +	CONTENT="
   14.75 +<table width=\"100%\">
   14.76 +<form method=\"post\" action=\"?action=admin\">
   14.77 +<tr><td><h2>$MDP</h2></td>
   14.78 +<td><input type=\"text\" name=\"password\" />$curpass
   14.79 +<input type=\"submit\" value=\"$DONE_BUTTON\" name=\"setpass\" /></td></tr>
   14.80 +</form>
   14.81 +"
   14.82 +	mform="form method=\"post\" enctype=\"multipart/form-data\" action=\"?action"
   14.83 +	while read section files test; do
   14.84 +		CONTENT="$CONTENT
   14.85 +<$mform=admin\">
   14.86 +$hr
   14.87 +<tr><td><h2>$section</h2></td>
   14.88 +<td><input type=\"submit\" $disabled value=\"$DONE_BUTTON\" name=\"$section\" /></td></tr>
   14.89 +"
   14.90 +		for i in $files ; do
   14.91 +			case "$section" in
   14.92 +			Plugins)
   14.93 +				plugin=
   14.94 +				eval $(grep ^plugin= $i)
   14.95 +				[ -n "$plugin" ] || continue
   14.96 +				eval $(grep ^description= $i)
   14.97 +				alt="$(grep ^description_$lang= $i)"
   14.98 +				[ -n "$alt" ] && eval $(echo "$alt" | sed 's/_..=/=/')
   14.99 +				help=
  14.100 +				eval $(grep ^help= $i)
  14.101 +				alt="$(grep ^help_$lang= $i)"
  14.102 +				[ -n "$alt" ] && eval $(echo "$alt" | sed 's/_..=/=/')
  14.103 +				name="$(basename $i .sh)"
  14.104 +				[ -n "$help" ] && description=" <a href='?page=$help' title='$plugin help page'>$description</a>"
  14.105 +				;;
  14.106 +			Locales)
  14.107 +				j=${i#config-}
  14.108 +				j=${j%.sh}
  14.109 +				[ -n "$j" ] || continue
  14.110 +				name="config_$j"
  14.111 +				plugin="$j"
  14.112 +				description="$(. ./$i ; echo $WIKI_TITLE)"
  14.113 +				;;
  14.114 +			Pages)
  14.115 +				j="$(basename $i .txt)"
  14.116 +				plugin="<a href=\"?page=$j\">$j</a>"
  14.117 +				name="page$j"
  14.118 +				description="$([ -w $i ] || echo -n $PROTECTED_BUTTON)"
  14.119 +				;;
  14.120 +			esac
  14.121 +			CONTENT="$CONTENT
  14.122 +<tr><td><b>
  14.123 +<input type=checkbox $disabled $([ $test $i ] && echo 'checked=checked ') name=\"$name\" />
  14.124 +$plugin</b></td><td><i>$description</i></td></tr>"
  14.125 +		done
  14.126 +		CONTENT="$CONTENT</form>"
  14.127 +	done <<EOT
  14.128 +Plugins	$plugins_dir/*.sh	-x
  14.129 +Locales	config-*.sh		-x
  14.130 +Pages	pages/*.txt		-w
  14.131 +EOT
  14.132 +	CONTENT="$CONTENT
  14.133 +<$mform=admin\">
  14.134 +$hr
  14.135 +<tr><td><h2>Configuration</h2></td>
  14.136 +<td><select name="file" $disabled>
  14.137 +$(for i in template.html style.css config*.sh; do
  14.138 +  [ -x $i ] && echo "<option>$i</option>"; done)
  14.139 +</select>
  14.140 +<input type=\"submit\" $disabled value=\"$DONE_BUTTON\" name=\"save\" />
  14.141 +<input type=\"file\" $disabled name=\"data\" />
  14.142 +<input type=\"submit\" $disabled value=\"$RESTORE\" name=\"restore\" /></td></tr>
  14.143 +</form>
  14.144 +<$mform=backup\">
  14.145 +$hr
  14.146 +<tr><td><h2>Data</h2></td>
  14.147 +<td><input type=\"submit\" $disabled name=\"save\" value=\"$DONE_BUTTON\" />
  14.148 +<input type=\"file\" $disabled name=\"file\" value=\"file\" />
  14.149 +<input type=\"submit\" $disabled name=\"restore\" value=\"$RESTORE\" />
  14.150 +</td></tr>
  14.151 +$(du -hs */ | sed 's|\(.*\)\t\(.*\)|<tr><td><b>\1</b></td><td><i>\2</i></td></tr>|')
  14.152 +</form>
  14.153 +</table>
  14.154 +"
  14.155 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/wiki/stuff/var/www/wiki/plugins/wkp_Calc.css	Sat Oct 31 16:32:19 2015 +0100
    15.3 @@ -0,0 +1,33 @@
    15.4 +.bordercalc {
    15.5 +    background-color: #ccc;
    15.6 +    font-weight: bold;
    15.7 +    text-align: center;
    15.8 +    border: 1px solid #999;
    15.9 +    padding: 0;
   15.10 +}
   15.11 +
   15.12 +.inputcalc {
   15.13 +    border: none;
   15.14 +    min-width: 80px;
   15.15 +    width: 80px;
   15.16 +    font-size: inherit;
   15.17 +    padding: 2px;
   15.18 +}
   15.19 +
   15.20 +.inputcalc:hover {
   15.21 +    background-color: #eee;
   15.22 +}
   15.23 +
   15.24 +.inputcalc:focus {
   15.25 +    background-color: #ccf;
   15.26 +}
   15.27 +
   15.28 +.tablecalc {
   15.29 +    border-collapse: collapse;  
   15.30 +}
   15.31 +
   15.32 +.cellcalc {
   15.33 +    border: 1px solid #999;
   15.34 +    padding: 0;
   15.35 +    font-size: 14px;
   15.36 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/wiki/stuff/var/www/wiki/plugins/wkp_Calc.sh	Sat Oct 31 16:32:19 2015 +0100
    16.3 @@ -0,0 +1,200 @@
    16.4 +plugin="Calc"
    16.5 +description_fr="Feuille de calcul au format CSV"
    16.6 +description="CSV format spreadsheet"
    16.7 +help_fr="AideCalc"
    16.8 +help="HelpCalc"
    16.9 +
   16.10 +case "$1" in
   16.11 +showhead) cat <<EOT
   16.12 +<!-- Based on http://jsfiddle.net/ondras/hYfN3/ by Ondřej Žára -->
   16.13 +<script type="text/javascript">
   16.14 +<!--
   16.15 +function csv(id,rows,cols) {
   16.16 +    var data = "";
   16.17 +    for (var i=1; i<=rows; i++) {
   16.18 +	for (var j=1; j<=cols; j++) {
   16.19 +            var letter = String.fromCharCode("A".charCodeAt(0)+j-1);
   16.20 +	    data += document.getElementById(id+letter+i).title+';';
   16.21 +	}
   16.22 +	data += "\\n";
   16.23 +    }
   16.24 +    alert(data);
   16.25 +}
   16.26 +
   16.27 +function cnt(from,to) {
   16.28 +    return (to.charCodeAt(0) - from.charCodeAt(0) + 1) *
   16.29 +           (parseInt(to.substring(1)) - parseInt(from.substring(1)) + 1)
   16.30 +}
   16.31 +
   16.32 +function zone(id,from,to,init,func) {
   16.33 +    var result=init
   16.34 +    for (var l=from.charCodeAt(0);;l++) {
   16.35 +        for (var n=parseInt(from.substring(1));
   16.36 +        	 n <= parseInt(to.substring(1));n++) {
   16.37 +            var e=document.getElementById(id+String.fromCharCode(l)+n)
   16.38 +            result=func(result,parseFloat(e.value))
   16.39 +        }
   16.40 +        if (l == to.charCodeAt(0)) break
   16.41 +    }
   16.42 +    return result;
   16.43 +}
   16.44 +
   16.45 +var DATA={};
   16.46 +function buildCalc(id, rows, cols) {
   16.47 +    DATA[id] = {};
   16.48 +    var maths = [ "abs", "acos", "asin", "atan", "atan2", "ceil", "cos", "exp",
   16.49 +		  "floor", "log", "pow", "random", "round", "sin",
   16.50 +		  "tan", "sqrt", "PI", "E" ];
   16.51 +    for (var i=0; v = maths[i]; i++)
   16.52 +	eval("DATA[id]."+v+" = DATA[id]."+v.toUpperCase()+" = Math."+v);
   16.53 +    DATA[id].rand = DATA[id].RAND = Math.random;
   16.54 +    DATA[id].ln   = DATA[id].LN   = Math.log;
   16.55 +    DATA[id].log10= DATA[id].LOG10= function(n){return Math.log(n)/Math.LN10;};
   16.56 +    DATA[id].log2 = DATA[id].LOG2 = function(n){return Math.log(n)/Math.LN2;};
   16.57 +    DATA[id].fact = DATA[id].FACT = 
   16.58 +	function(n){var x=1;while(n>1)x*=n--;return x;};
   16.59 +    DATA[id].fib  = DATA[id].FIB  = 
   16.60 +	function(n){var c=0,p=1;while(n-->0){var x=c;c+=p;p=x};return c;};
   16.61 +    DATA[id].sum  = DATA[id].SUM  =
   16.62 +	function(a,b){return zone(id,a,b,0,function(a,b){return a+b});};
   16.63 +    DATA[id].min  = DATA[id].MIN  =
   16.64 +	function(a,b){return zone(id,a,b,Number.MAX_VALUE,Math.min);};
   16.65 +    DATA[id].max  = DATA[id].MAX  =
   16.66 +	function(a,b){return zone(id,a,b,Number.MIN_VALUE,Math.max);};
   16.67 +    DATA[id].cnt  = DATA[id].CNT  = cnt
   16.68 +    for (var i=0; i<=rows; i++) {
   16.69 +        var row = document.getElementById(id).insertRow(-1);
   16.70 +        for (var j=0; j<=cols && j<=26; j++) {
   16.71 +            var letter = String.fromCharCode("A".charCodeAt(0)+j-1);
   16.72 +	    var cell = row.insertCell(-1);
   16.73 +	    if (i&&j) {
   16.74 +		cell.className = "cellcalc";
   16.75 +		cell.innerHTML = "<input id='"+ id+letter+i +"' class='inputcalc'/>";
   16.76 +	    }
   16.77 +	    else {
   16.78 +		cell.className = "bordercalc";
   16.79 +		cell.title = "Show CSV";
   16.80 +		cell.onclick = function(){csv(id,rows,cols);};
   16.81 +		cell.innerHTML = (i||j) ? i||letter : "&radic;";
   16.82 +	    }
   16.83 +        }
   16.84 +    }
   16.85 +}
   16.86 +
   16.87 +function getWidth(s)
   16.88 +{
   16.89 +	var e = document.getElementById("widthcalc");
   16.90 +	e.innerHTML = s;
   16.91 +	return (e.offsetWidth < e.minWidth || s.charAt(0) == "=") ?
   16.92 +		 e.minWidth : e.offsetWidth;
   16.93 +}
   16.94 +
   16.95 +function setCell(e, v)
   16.96 +{
   16.97 +    e.style.width = getWidth(v)+"px";
   16.98 +    e.style.textAlign = 
   16.99 +	(isNaN(parseFloat(v)) && v.charAt(0) != "=") ? "left" : "right";
  16.100 +    e.title = v;
  16.101 +}
  16.102 +//-->
  16.103 +</script>
  16.104 +<span id="widthcalc" class="cellcalc" style="visibility:hidden;"></span>
  16.105 +EOT
  16.106 +	exit 0 ;;
  16.107 +showtail) cat <<EOT
  16.108 +<script type="text/javascript">
  16.109 +<!--
  16.110 +var INPUTS=[].slice.call(document.getElementsByClassName("inputcalc"));
  16.111 +INPUTS.forEach(function(elm) {
  16.112 +    elm.onfocus = function(e) {
  16.113 +        e.target.value = e.target.title || "";
  16.114 +    };
  16.115 +    elm.onblur = function(e) {
  16.116 +	setCell(e.target, e.target.value);
  16.117 +        computeAll();
  16.118 +    };
  16.119 +    var calcid = elm.id.substring(0,4), cellid = elm.id.substring(4);
  16.120 +    var getter = function() {
  16.121 +        var value = elm.title || "";
  16.122 +        if (value.charAt(0) == "=")
  16.123 +		with (DATA[calcid]) return eval(value.substring(1));
  16.124 +        else return (value == "" || isNaN(value)) ? value : parseFloat(value);
  16.125 +    };
  16.126 +    Object.defineProperty(DATA[calcid], cellid, {get:getter});
  16.127 +    Object.defineProperty(DATA[calcid], cellid.toLowerCase(), {get:getter});
  16.128 +});
  16.129 +(window.computeAll = function() {
  16.130 +    INPUTS.forEach(function(elm) {
  16.131 +	var calcid = elm.id.substring(0,4), cellid = elm.id.substring(4);
  16.132 +	try { elm.value = DATA[calcid][cellid]; } catch(e) {} });
  16.133 +})();
  16.134 +//-->
  16.135 +</script>
  16.136 +EOT
  16.137 +	exit 0 ;;
  16.138 +esac
  16.139 +
  16.140 +formatEnd()
  16.141 +{
  16.142 +CONTENT=$(awk -v prg=$plugins_dir/wkp_$plugin.sh '
  16.143 +function showcalc()
  16.144 +{
  16.145 +	if (lines > 1 && rows > 1) {
  16.146 +		id="C" (100+cnt++)
  16.147 +		print "<noscript><a href=\"http://www.enable-javascript.com/\" target=\"_blank\">Enable javascript to see the spreadsheet " id "</a></noscript>"
  16.148 +		print "<table id=\"" id "\" class=\"tablecalc\"></table>"
  16.149 +		print "<script type=\"text/javascript\">"
  16.150 +		print "<!--"
  16.151 +		print "buildCalc(\"" id "\"," lines "," rows ");"
  16.152 +		for (i = 1; i <= lines; i++) {
  16.153 +			gsub("&lt;","<",line[i])
  16.154 +			for (j = 1; j < split(line[i],tmp,";"); j++) {
  16.155 +				if (tmp[j] == "") continue
  16.156 +				gsub("\"","\\\\\"",tmp[j])
  16.157 +				s = "setCell(document.getElementById(\"" id
  16.158 +				c = substr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",j,1)
  16.159 +				print s c i "\"), \"" tmp[j] "\")";
  16.160 +			}
  16.161 +		}
  16.162 +		print "//-->"
  16.163 +		print "</script>"
  16.164 +	}
  16.165 +	else for (i = 1; i <= lines; i++) print line[i]
  16.166 +	rows = lines = gotcalc = 0
  16.167 +}
  16.168 +{
  16.169 +	if (/;<br \/>$/) {
  16.170 +		gotcalc = 1
  16.171 +		if (!headdone) {
  16.172 +			headdone = 1
  16.173 +			showtail = 1
  16.174 +			system("/bin/sh " prg " showhead")
  16.175 +		}
  16.176 +		line[++lines] = $0
  16.177 +		gsub("&lt;","<",$0)
  16.178 +		i = split($0,tmp,";")-1
  16.179 +		if (lines == 1) rows = i
  16.180 +		if (i != rows) rows = -1
  16.181 +	}
  16.182 +	else {
  16.183 +		if (gotcalc) showcalc()
  16.184 +		print
  16.185 +	}
  16.186 +}
  16.187 +END {
  16.188 +	if (gotcalc) showcalc()
  16.189 +	if (showtail) system("/bin/sh " prg " showtail")
  16.190 +}
  16.191 +' <<EOT
  16.192 +$CONTENT
  16.193 +EOT
  16.194 +)
  16.195 +}
  16.196 +
  16.197 +template()
  16.198 +{
  16.199 +	html=$(sed 's|</head>|\t<style type="text/css"> @import "plugins/wkp_Calc.css"; </style>\n&|' <<EOT
  16.200 +$html
  16.201 +EOT
  16.202 +)
  16.203 +}
    17.1 --- a/wiki/stuff/var/www/wiki/plugins/wkp_ListPlugins.sh	Sat Oct 31 12:53:44 2015 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,44 +0,0 @@
    17.4 -plugin="ListPlugins"
    17.5 -description_fr="Affiche la liste des plugins chargés"
    17.6 -description="List plugins"
    17.7 -      
    17.8 -action()
    17.9 -{
   17.10 -	[ "$1" == "list" -o "$1" == "config" ] || return 1
   17.11 -	CONTENT='
   17.12 -<table width="100%">
   17.13 -<tr><td span=2><h2>Plugins</h2></td></tr>
   17.14 -'
   17.15 -	PAGE_TITLE_link=false
   17.16 -	editable=false
   17.17 -	lang="${HTTP_ACCEPT_LANGUAGE%%,*}"
   17.18 -	PAGE_TITLE="Configuration"
   17.19 -	for i in $plugins_dir/*.sh ; do
   17.20 -		eval $(grep ^plugin= $i)
   17.21 -		eval $(grep ^description= $i)
   17.22 -		alt="$(grep ^description_$lang= $i)"
   17.23 -		[ -n "$alt" ] && eval $(echo "$alt" | sed 's/_..=/=/')
   17.24 -		CONTENT="$CONTENT
   17.25 -<tr><td><b>
   17.26 -<input type=checkbox disabled=disabled $([ -x $i ] && echo 'checked=checked ')/>
   17.27 -$plugin</b></td><td><i>$description</i></td></tr>"
   17.28 -	done
   17.29 -	CONTENT="$CONTENT
   17.30 -<tr><td span=2><br /><h2>Locales</h2></td></tr>
   17.31 -"
   17.32 -	for i in config-*.sh ; do
   17.33 -		i=${i#config-}
   17.34 -		i=${i%.sh}
   17.35 -		[ -n "$i" ] || continue
   17.36 -	CONTENT="$CONTENT
   17.37 -<tr><td><b>
   17.38 -<input type=checkbox disabled=disabled $([ "$i" == "$lang" ] && echo 'checked=checked ')/>
   17.39 -$i</b></td></tr>
   17.40 -"
   17.41 -	done
   17.42 -	CONTENT="$CONTENT
   17.43 -<tr><td span=2><br /><h2>Data</h2></td></tr>
   17.44 -$(du -hs */ | awk '{ printf "<tr><td><b>%s</b></td><td><i>%s</i></td></tr>\n",$1,$2 }')
   17.45 -</table>
   17.46 -"
   17.47 -}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/wiki/stuff/var/www/wiki/plugins/wkp_Password.sh	Sat Oct 31 16:32:19 2015 +0100
    18.3 @@ -0,0 +1,78 @@
    18.4 +plugin="Password"
    18.5 +description_fr="Ajoute un mot de passe &agrave; une page avec {PASSWORD=code}"
    18.6 +description="Add a password to a page with {PASSWORD=something}"
    18.7 +   
    18.8 +pagepass_hash()
    18.9 +{
   18.10 +	echo $1 | md5sum | cut -c1-8
   18.11 +}
   18.12 +
   18.13 +init()
   18.14 +{
   18.15 +	if grep -qs '{HASHPASSWORD=' $1; then
   18.16 +		case "$(GET action)" in
   18.17 +			pagepass|'') return ;;
   18.18 +		esac
   18.19 +		hash="$(sed '/{HASHPASSWORD=.*}/!d;s/.*{HASHPASSWORD=\([^}]*\)}.*/\1/;q' <$1)"
   18.20 +		cookie="pagepass$(pagepass_hash $PWD$PAGE_txt)"
   18.21 +		[ "$(COOKIE $cookie)" == "$hash" ] && return
   18.22 +		header
   18.23 +		echo "<script> history.go(-1); </script>"
   18.24 +		exit 0
   18.25 +	fi
   18.26 +}
   18.27 +
   18.28 +action()
   18.29 +{
   18.30 +	[ "$1" == "pagepass" ] || return 1
   18.31 +	uri="$SCRIPT_NAME?page=$(POST page)&auth=$(POST auth)"
   18.32 +	if [ "$(pagepass_hash $(POST pass))" == "$(POST hash)" ]; then
   18.33 +		header  "HTTP/1.0 302 Found" \
   18.34 +			"location: $uri" \
   18.35 +			"Set-Cookie: $(POST cookie)=$(POST hash)"
   18.36 +##			"Set-Cookie: $(POST cookie)=$(POST hash); Max-Age=3600; Path=$(dirname $SCRIPT_NAME); HttpOnly"
   18.37 +	else
   18.38 +		header  "HTTP/1.0 302 Found" \
   18.39 +			"location: $uri&error=1"
   18.40 +	fi
   18.41 +	exit 0
   18.42 +}
   18.43 +
   18.44 +formatBegin()
   18.45 +{
   18.46 +	hash="$(sed '/{HASHPASSWORD=.*}/!d;s/.*{HASHPASSWORD=\([^}]*\)}.*/\1/;q' <<EOT
   18.47 +$CONTENT
   18.48 +EOT
   18.49 +)"
   18.50 +	cookie="pagepass$(pagepass_hash $PWD$PAGE_txt)"
   18.51 +	if [ "$(COOKIE $cookie)" != "$hash" ]; then
   18.52 +		editable=false
   18.53 +		CONTENT="<form method=\"post\" action=\"?action=pagepass\">
   18.54 +<input type=\"hidden\" name=\"page\" value=\"$(GET page)\" /> \
   18.55 +<input type=\"hidden\" name=\"auth\" value=\"$(GET auth)\" /> \
   18.56 +<input type=\"hidden\" name=\"hash\" value=\"$hash\" /> \
   18.57 +<input type=\"hidden\" name=\"cookie\" value=\"$cookie\" /> \
   18.58 +$MDP <input type=\"text\" name=\"pass\" /> \
   18.59 +<input type=\"submit\" value=\"$DONE_BUTTON\" />
   18.60 +</form>"
   18.61 +	else
   18.62 +		CONTENT="$(sed 's/{HASHPASSWORD=[^}]*}//' <<EOT
   18.63 +$CONTENT
   18.64 +EOT
   18.65 +)"
   18.66 +	fi
   18.67 +}
   18.68 +
   18.69 +pagepass_sedexpr()
   18.70 +{
   18.71 +	sed '/{PASSWORD=.*}/!d;s/.*{PASSWORD=\([^}]*\)}.*/\1/' $1 | \
   18.72 +	while read pass; do
   18.73 +		echo -n "-e 's|{PASSWORD=$pass|{HASHPASSWORD=$(pagepass_hash $pass)|' "
   18.74 +	done
   18.75 +	echo -n "-e 's|{PASSWORD=}||' "
   18.76 +}
   18.77 +
   18.78 +writedPage()
   18.79 +{
   18.80 +	eval sed -i $(pagepass_sedexpr $1) $1 $BACKUP_DIR$PAGE_TITLE/\*.bak
   18.81 +}
    19.1 --- a/wiki/stuff/var/www/wiki/plugins/wkp_Rss.sh	Sat Oct 31 12:53:44 2015 +0100
    19.2 +++ b/wiki/stuff/var/www/wiki/plugins/wkp_Rss.sh	Sat Oct 31 16:32:19 2015 +0100
    19.3 @@ -6,30 +6,30 @@
    19.4  {
    19.5  	# Attention, bug si https ou port différent de 80 ?
    19.6  	ADR_ACCUEIL="http://$SERVER_NAME$SCRIPT_NAME"
    19.7 +	RSS_DESCRIPTION="Flux RSS de $WIKI_TITLE"
    19.8  	CONTENT_RSS=""      
    19.9 +	cat > rss.xml <<EOT
   19.10 +<rss version="0.91">
   19.11 +<channel>
   19.12 +<title>$WIKI_TITLE</title>
   19.13 +<link>$ADR_ACCUEIL</link>
   19.14 +<description>$RSS_DESCRIPTION</description>
   19.15 +<language>$LANG</language>
   19.16 +EOT
   19.17  	for file in $(ls -l $PWD/$PAGES_DIR/*.txt 2> /dev/null | awk '{ print $9 }' | tail -n 10) ; do
   19.18  		filename=$(basename $file ".txt")
   19.19  		timestamp=$(filedate $file)
   19.20  		CONTENT="$CONTENT<a href=\"?page=$filename\">$filename</a> ($timestamp - <a href=\"./?page=$filename&amp;action=diff\">diff</a>)<br />"
   19.21 -CONTENT_RSS="$CONTENT_RSS<item>
   19.22 +		cat >> rss.xml <<EOT
   19.23 +<item>
   19.24  <title>$filename</title>
   19.25  <pubDate>$timestamp</pubDate>
   19.26  <link>$ADR_ACCUEIL?page=$(urlencode '$filename')</link>
   19.27  <description>$filename $timestamp</description>
   19.28 -</item>"
   19.29 +</item>
   19.30 +EOT
   19.31  	done
   19.32 -	sed -e "s#{WIKI_TITLE}#$WIKI_TITLE#" \
   19.33 -	    -e "s#{ADR_ACCUEIL}#$ADR_ACCUEIL#" \
   19.34 -	    -e "s#{LANG}#$LANG#" \
   19.35 -	    -e "s#{WIKI_DESCRIPTION}#Flux RSS de $WIKI_TITLE#" \
   19.36 -	    -e "s#{CONTENT_RSS}#$CONTENT_RSS#" > rss.xml <<EOT
   19.37 -<rss version="0.91">
   19.38 -<channel>
   19.39 -<title>{WIKI_TITLE}</title>
   19.40 -<link>{ADR_ACCUEIL}</link>
   19.41 -<description>{WIKI_DESCRIPTION}</description>
   19.42 -<language>{LANG}</language>
   19.43 -{CONTENT_RSS}
   19.44 +	cat >> rss.xml <<EOT
   19.45  </channel>
   19.46  </rss>
   19.47  EOT
    20.1 --- a/wiki/stuff/var/www/wiki/plugins/wkp_Tables.sh	Sat Oct 31 12:53:44 2015 +0100
    20.2 +++ b/wiki/stuff/var/www/wiki/plugins/wkp_Tables.sh	Sat Oct 31 16:32:19 2015 +0100
    20.3 @@ -9,10 +9,10 @@
    20.4      -e 's,^\( *|\)|,\1,' -e 's/|\( *\)$/\1/' <<EOT | awk '
    20.5  {
    20.6    if (/^ *\|.*\|$/) {
    20.7 -    if (in_array == 0) print "<table class=\"wikitable\">"
    20.8 +    if (in_array == 0) printf "<table class=\"wikitable\">"
    20.9      in_array = 1
   20.10      s = $0
   20.11 -    print "<tr>"
   20.12 +    printf "<tr>"
   20.13      while (match(s,/\|[^\|]*\|/)) {
   20.14        q = substr(s,RSTART+1,RLENGTH-2)
   20.15        s = substr(s,RSTART+RLENGTH)
   20.16 @@ -40,9 +40,9 @@
   20.17          c = c " rowspan=\"" substr(q,2,RLENGTH-1) "\""
   20.18          q = substr(q,n+1)
   20.19        }
   20.20 -      print "  <td" c ">" q "</td>"
   20.21 +      printf "  <td" c ">" q "</td>"
   20.22      }
   20.23 -    print "</tr>"
   20.24 +    printf "</tr>"
   20.25    }
   20.26    else {
   20.27      if (in_array != 0) print "</table>"
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/wiki/stuff/var/www/wiki/plugins/wkp_Upload.sh	Sat Oct 31 16:32:19 2015 +0100
    21.3 @@ -0,0 +1,113 @@
    21.4 +plugin="<a href=\"?action=upload\" title=\"Upload a file\">Upload</a>"
    21.5 +description_fr="Télécharge des fichiers complémentaires (ex: images)"
    21.6 +description="Upload page extra files (ex: images)"
    21.7 +      
    21.8 +case "$LANG" in
    21.9 +fr) UPLOAD="Chargement" ;;
   21.10 +*)  UPLOAD="Upload" ;;
   21.11 +esac
   21.12 +
   21.13 +template()
   21.14 +{
   21.15 +	case "$(GET action)" in
   21.16 +	edit)	UPLOAD="<a href=\"$urlbase?action=upload\">$UPLOAD</a>"
   21.17 +		html="$(sed "s|HISTORY|$(sedesc "$UPLOAD") / HISTORY|" <<EOT
   21.18 +$html
   21.19 +EOT
   21.20 +)" ;;
   21.21 +	upload*) html="$(sed 's| / <a href.*recent.*</a>||;s|.*name="query".*||' <<EOT
   21.22 +$html
   21.23 +EOT
   21.24 +)" ;;
   21.25 +	*)	return 1 ;;
   21.26 +	esac
   21.27 +	return 0
   21.28 +}
   21.29 +
   21.30 +action()
   21.31 +{
   21.32 +	case "$1" in
   21.33 +	upload) CONTENT="$(cat <<EOT
   21.34 +<form method="post" enctype="multipart/form-data" action="?action=uploadfile">
   21.35 +<input type="file" name="file" value="file"/>
   21.36 +<input type="submit"/>
   21.37 +<table>
   21.38 +EOT
   21.39 +		for i in pages/data/* ; do
   21.40 +			[ -e $i ] || continue
   21.41 +			echo -n "<tr><td><input type=checkbox "
   21.42 +			grep -qs "$i" pages/*.txt &&  echo "checked=checked "
   21.43 +			echo "disabled=disabled /><a href="$i">$(basename $i)</a></td></tr>"
   21.44 +		done
   21.45 +		cat <<EOT
   21.46 +</table>
   21.47 +</form>
   21.48 +EOT
   21.49 +)"
   21.50 +		PAGE_TITLE_link=false
   21.51 +		editable=false
   21.52 +		lang="${HTTP_ACCEPT_LANGUAGE%%[,;_-]*}"
   21.53 +		PAGE_TITLE="$UPLOAD" ;;
   21.54 +	uploadfile)
   21.55 +		mkdir -p pages/data 2> /dev/null
   21.56 +		name=$(FILE file name)
   21.57 +		if [ -z "$name" ]; then
   21.58 +			CONTENT="<script> history.go(-2); </script>"
   21.59 +			return 1
   21.60 +		fi
   21.61 +		n=''
   21.62 +		while [ -e pages/data/$n$name ]; do
   21.63 +			n=$(($n+1))
   21.64 +		done
   21.65 +		filesize=$(stat -c "%s" $(FILE file tmpname))
   21.66 +		ls pages/data | while read file; do
   21.67 +			stat -c "%s %n" pages/data/$file
   21.68 +		done | while read size file; do
   21.69 +			[ $filesize == $size ] && 
   21.70 +			cmp $(FILE file tmpname) $file > /dev/null &&
   21.71 +			ln -s $(basename $file) pages/data/$n$name && break
   21.72 +		done
   21.73 +		if [ -L pages/data/$n$name ]; then
   21.74 +			n=pages/data/$n$name
   21.75 +			name="$(readlink $n)"
   21.76 +			rm -f $n
   21.77 +			n=""
   21.78 +		else
   21.79 +			mv $(FILE file tmpname) pages/data/$n$name
   21.80 +		fi
   21.81 +		rm -rf $(dirname $(FILE file tmpname) )
   21.82 +		URL=pages/data/$n$name
   21.83 +		PAGE_TITLE_link=false
   21.84 +		editable=false
   21.85 +		PAGE_TITLE="$UPLOAD"
   21.86 +		CONTENT="$(cat <<EOT
   21.87 +<h1><a href="javascript:history.go(-2)">$EDIT_BUTTON</a></h1>
   21.88 +<p>
   21.89 +The file $(FILE file name) ($(FILE file size) bytes, $(FILE file type)) is
   21.90 +stored at <a href="$URL">$URL</a>.
   21.91 +</p>
   21.92 +EOT
   21.93 +)"
   21.94 +		case "$(FILE file type)" in
   21.95 +		image*) CONTENT="$(cat <<EOT
   21.96 +$CONTENT
   21.97 +<p>
   21.98 +You can insert this image with <b>[$URL]</b> see
   21.99 +<a href="?page=$HELP_BUTTON">$HELP_BUTTON</a> for details
  21.100 +</p>
  21.101 +<img src="$URL" alt="$URL" />
  21.102 +EOT
  21.103 +)"
  21.104 +		esac ;;
  21.105 +	*)	return 1 ;;
  21.106 +	esac
  21.107 +	return 0
  21.108 +}
  21.109 +
  21.110 +formatEnd()
  21.111 +{
  21.112 +	CONTENT="$(sed 's|href="[^"]*page=pages/data/|href="pages/data/|g' <<EOT
  21.113 +$CONTENT
  21.114 +EOT
  21.115 +)"
  21.116 +}
    22.1 --- a/wiki/stuff/var/www/wiki/style.css	Sat Oct 31 12:53:44 2015 +0100
    22.2 +++ b/wiki/stuff/var/www/wiki/style.css	Sat Oct 31 16:32:19 2015 +0100
    22.3 @@ -1,172 +1,136 @@
    22.4 +/* CSS style for TazWikiss */
    22.5 +
    22.6 +body { font: 13px sans-serif, vernada, arial; margin: 0; }
    22.7 +code { font-size: 12px; }
    22.8 +img { border: 0px; }
    22.9 +a { color: #333C4D; }
   22.10 +a.pending { color: #7F4736; }
   22.11 +a.url { color: #808080; }
   22.12 +a:hover { color: #57A2D4; }
   22.13 +pre { 
   22.14 +	border: 1px dotted #ddd;
   22.15 +	padding: 4px;
   22.16 +	width: 640px;
   22.17 +	overflow: auto;
   22.18 +}
   22.19 +
   22.20  /* Plugin wkp_Tables */
   22.21  table.wikitable {
   22.22 -  border-collapse: collapse;
   22.23 -  border: 1px solid #ccc;
   22.24 +	border-collapse: collapse;
   22.25 +	border: 1px solid #ddd;
   22.26  }
   22.27  
   22.28  table.wikitable td {
   22.29 -  border: 1px solid #ccc;
   22.30 -  text-align: center;
   22.31 -  vertical-align: middle;
   22.32 -  padding: 2px;
   22.33 +	border: 1px solid #ddd;
   22.34 +	text-align: center;
   22.35 +	vertical-align: middle;
   22.36 +	padding: 2px;
   22.37  }
   22.38  
   22.39  table.wikitable td.em {
   22.40 -  background: #ccc;
   22.41 -  font-weight: bold;
   22.42 +	background: #ccc;
   22.43 +	font-weight: bold;
   22.44  } 
   22.45  
   22.46  /* Table Of Content */
   22.47  #toc {
   22.48 -     border: 1px dashed #11141A;
   22.49 -     float:right;
   22.50 -     padding-right: 2em;
   22.51 +	border: 1px dashed #11141A;
   22.52 +	float:right;
   22.53 +	padding-right: 2em;
   22.54  }
   22.55  #toc h1 {
   22.56 -     font-size: 10px;
   22.57 -     padding-left: .5em;
   22.58 +	font-size: 10px;
   22.59 +	padding-left: .5em;
   22.60  }
   22.61  #toc h2 {
   22.62 -     font-size: 9px;
   22.63 -     padding-left: 1.5em;
   22.64 +	font-size: 9px;
   22.65 +	padding-left: 1.5em;
   22.66  }
   22.67  #toc h3 {
   22.68 -     font-size: 8px;
   22.69 -     padding-left: 2em;
   22.70 +	font-size: 8px;
   22.71 +	padding-left: 2em;
   22.72  }
   22.73  #toc h4 {
   22.74 -     font-size: 7px;
   22.75 -     padding-left: 2.5em;
   22.76 +	font-size: 7px;
   22.77 +	padding-left: 2.5em;
   22.78  }
   22.79  #toc h5 {
   22.80 -     font-size: 6px;
   22.81 -     padding-left: 3em;
   22.82 -}
   22.83 -
   22.84 -img {
   22.85 -border: 0px
   22.86 -}
   22.87 -
   22.88 -body {
   22.89 -background-color: #828A99;
   22.90 -font-family: Trebuchet, "Trebuchet MS", sans-serif;
   22.91 -font-size: 14px;
   22.92 -line-height: 16px;
   22.93 -}
   22.94 -
   22.95 -pre
   22.96 -{ 
   22.97 -border: 1px dotted #ccc;
   22.98 -padding: 4px;
   22.99 -width: 640px;
  22.100 -overflow: auto;
  22.101 -}
  22.102 -
  22.103 -code
  22.104 -{
  22.105 -font-family: "Courier New", monospace;
  22.106 -font-size: 12px;
  22.107 -}
  22.108 -
  22.109 -a {
  22.110 -color: #333C4D;
  22.111 -}
  22.112 -
  22.113 -a.pending {
  22.114 -color: #7F4736;
  22.115 -}
  22.116 -
  22.117 -a.url {
  22.118 -color: #808080;
  22.119 -}
  22.120 -
  22.121 -a:hover {
  22.122 -color: #57A2D4;
  22.123 -background: inherit;
  22.124 +	font-size: 6px;
  22.125 +	padding-left: 3em;
  22.126  }
  22.127  
  22.128  .category {
  22.129 -  color: #999;
  22.130 -  background: inherit;
  22.131 +	color: #999;
  22.132 +	background: inherit;
  22.133  }
  22.134  
  22.135 -th
  22.136 -{
  22.137 -padding-left: 1em;
  22.138 -background: #333C4D;
  22.139 -color: white;
  22.140 -text-align: left;
  22.141 -border-bottom: 1px dashed #11141A;
  22.142 +th {
  22.143 +	text-align: left;
  22.144 +	background: #351a0a;
  22.145 +	height: 40px;
  22.146 +	border-bottom: 4px solid #d66018;
  22.147  }
  22.148  
  22.149  th h1 {
  22.150 -font-family: "Futura Condensed", Futura, sans-serif !important;
  22.151 -font-weight: bolder;
  22.152 -padding-top: 10px;
  22.153 -padding-bottom: 4px;
  22.154 -margin-top: 0;
  22.155 -margin-bottom: 0;
  22.156 -}
  22.157 -
  22.158 -h1, h2, h3, h4, h5, h6 {
  22.159 -font-family: "Futura Condensed", Futura, sans-serif !important;
  22.160 +	margin: 0; padding: 8px; color: #fff; font-size: 20px;
  22.161  }
  22.162  
  22.163  th a {
  22.164 -text-decoration: none;
  22.165 -color: white !important;
  22.166 +	text-decoration: none;
  22.167 +	color: white !important;
  22.168  }
  22.169  
  22.170  th p {
  22.171 -font-size: 80%;
  22.172 -margin-top: 0;
  22.173 -margin-bottom: 0;
  22.174 -padding-left: 2em;
  22.175 +	position: absolute;
  22.176 +	top: 2px;
  22.177 +	right: 2px;
  22.178 +	font-size: 80%;
  22.179 +	margin: 0;
  22.180 +	color: white !important;
  22.181  }
  22.182  
  22.183  #mainTable {
  22.184 -border: 1px solid #11141A;
  22.185 +	border-bottom: 1px solid #ddd;
  22.186  }
  22.187  
  22.188  .pageLinks {
  22.189 -padding-left: 1em;
  22.190 -padding-right: 1em;
  22.191 -font-size: 80%;
  22.192 -margin-top: 0;
  22.193 -margin-bottom: 0;
  22.194 -background-color: #eee;
  22.195 -color: #666;
  22.196 +	padding-left: 1em;
  22.197 +	padding-right: 1em;
  22.198 +	font-size: 80%;
  22.199 +	margin-top: 0;
  22.200 +	margin-bottom: 0;
  22.201 +	background-color: #eee;
  22.202 +	color: #666;
  22.203  }
  22.204  .pageLinks a {
  22.205 -font-weight: bold;
  22.206 -text-decoration: none;
  22.207 +	font-weight: bold;
  22.208 +	text-decoration: none;
  22.209  }
  22.210  
  22.211  #headerLinks td {
  22.212 -border-bottom: 1px dashed #ccc !important;
  22.213 +	border-bottom: 1px dashed #ccc !important;
  22.214  }
  22.215  
  22.216  #footerLinks td {
  22.217 -border-top: 1px dashed #ccc !important;
  22.218 +	border-top: 1px dashed #ccc !important;
  22.219  }
  22.220  
  22.221  #mainContent {
  22.222 -font-size: 90%;
  22.223 -padding: 1em;
  22.224 -background-color: white;
  22.225 +	font-size: 90%;
  22.226 +	padding: 1em;
  22.227 +	background-color: white;
  22.228  }
  22.229  
  22.230  #mainContent h2:first-child {
  22.231 -margin-top: 0px;
  22.232 +	margin-top: 0px;
  22.233  }
  22.234  
  22.235 -
  22.236  .error {
  22.237 -color: #F25A5A;
  22.238 -font-size: 80%;
  22.239 -font-weight: bold;
  22.240 +	color: #F25A5A;
  22.241 +	font-size: 80%;
  22.242 +	font-weight: bold;
  22.243  }
  22.244  
  22.245  form {
  22.246 -display: inline
  22.247 +	display: inline
  22.248  }