slitaz-dev-tools rev 244

tazwikiss: filter & in sed exp for EDIT HISTORY and PAGE_TITLE_str
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Aug 20 21:26:04 2015 +0200 (2015-08-20)
parents cbddfd886247
children 46bb16b07f1a
files tazwikiss/rootfs/var/www/wiki/index.sh
line diff
     1.1 --- a/tazwikiss/rootfs/var/www/wiki/index.sh	Sun May 10 10:15:53 2015 +0300
     1.2 +++ b/tazwikiss/rootfs/var/www/wiki/index.sh	Thu Aug 20 21:26:04 2015 +0200
     1.3 @@ -180,7 +180,7 @@
     1.4  case "$action" in
     1.5  edit)
     1.6  	editable=false
     1.7 -	HISTORY="<a href=\"$urlbase?page=$(urlencode $PAGE_TITLE)\&amp;action=history\" accesskey=\"6\" rel=\"nofollow\">$HISTORY_BUTTON</a><br />"
     1.8 +	HISTORY="<a href=\"$urlbase?page=$(urlencode $PAGE_TITLE)&amp;action=history\" accesskey=\"6\" rel=\"nofollow\">$HISTORY_BUTTON</a><br />"
     1.9  	CONTENT="$(sed 's/%/\&#37;/g' <<EOT
    1.10  $CONTENT
    1.11  EOT
    1.12 @@ -201,9 +201,9 @@
    1.13  history)
    1.14  	complete_dir="$BACKUP_DIR$PAGE_TITLE/"
    1.15  	if [ -n "$gtime" ]; then
    1.16 -		HISTORY="<a href=\"$urlbase?page=$PAGE_TITLE\&amp;action=history\" rel=\"nofollow\">$HISTORY_BUTTON</a>"
    1.17 +		HISTORY="<a href=\"$urlbase?page=$PAGE_TITLE&amp;action=history\" rel=\"nofollow\">$HISTORY_BUTTON</a>"
    1.18  		if [ -r "$complete_dir$gtime" ]; then
    1.19 -			HISTORY="$HISTORY <a href=\"$urlbase?page=$PAGE_TITLE\&amp;action=edit\&amp;time=$gtime&amp;restore=1\" rel=\"nofollow\">$RESTORE</a>"
    1.20 +			HISTORY="$HISTORY <a href=\"$urlbase?page=$PAGE_TITLE&amp;action=edit&amp;time=$gtime&amp;restore=1\" rel=\"nofollow\">$RESTORE</a>"
    1.21  			CONTENT="$(cat $complete_dir$gtime | sed -e s/$(echo -ne '\r')//g -e 's|$|<br/>|g')"
    1.22  		else
    1.23  			HISTORY="$HISTORY -"
    1.24 @@ -224,7 +224,7 @@
    1.25  	fi ;;
    1.26  diff)
    1.27  	if [ -n "$(GET f1)" ]; then
    1.28 -		HISTORY="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")\&amp;action=history\">$HISTORY_BUTTON</a>"
    1.29 +		HISTORY="<a href=\"$urlbase?page=$(urlencode "$PAGE_TITLE")&amp;action=history\">$HISTORY_BUTTON</a>"
    1.30  		CONTENT="$(htmldiff "$(GET f1)" "$(GET f2)" )"
    1.31  	else
    1.32  		# diff auto entre les 2 dernières versions
    1.33 @@ -316,7 +316,15 @@
    1.34  		 	-e 's/([yY])/\&yen;/g'  -e 's/([tT][mM])/\&trade;/g' \
    1.35  		 	-e 's/([cC])/\&copy;/g' -e 's/([rR])/\&reg;/g' \
    1.36  		 	-e 's/([dD])/\&deg;/g'  -e 's/(1\/2)/\&frac12;/g' \
    1.37 -		 	-e 's/(1\/4)/\&frac14;/g'  -e 's/(3\/4)/\&frac34;/g' \
    1.38 +		 	-e 's/(1\/4)/\&frac14;/g' -e 's/(3\/4)/\&frac34;/g' \
    1.39 +		 	-e 's/(phone)/\&#9742;/' -e 's/(wphone)/\&#9743;/' \
    1.40 +		 	-e 's/(skull)/\&#9760;/' -e 's/(radioactive)/\&#9762;/' \
    1.41 +		 	-e 's/(sad)/\&#9785;/'  -e 's/(smile)/\&#9786;/' \
    1.42 +		 	-e 's/(recycle)/\&#9742;/' -e 's/(wheelchair)/\&#9755;/' \
    1.43 +		 	-e 's/(wflag)/\&#9872;/' -e 's/(bflag)/\&#9873;/' \
    1.44 +		 	-e 's/(anchor)/\&#9875;/' -e 's/(flower)/\&#9880;/' \
    1.45 +		 	-e 's/(gear)/\&#9881;/' -e 's/(volt)/\&#9889;/' \
    1.46 +		 	-e 's/(warn)/\&#9888;/' -e 's/(star)/\&#9733;/' \
    1.47  		 	-e 's/(&lt;=)/\&le;/g'  -e 's/(>=)/\&ge;/g' \
    1.48  		 	-e 's/(!=)/\&ne;/g'     -e 's/(+-)/\&plusmn;/g' <<EOT
    1.49  $CONTENT
    1.50 @@ -482,9 +490,9 @@
    1.51  
    1.52  header "Content-type: text/html"
    1.53  sed	-e "s#{ERROR}#$ERROR#"		-e "s#{WIKI_TITLE}#$WIKI_TITLE#" \
    1.54 -	-e "s#{\([^}]*\)HISTORY\([^}]*\)}#$HISTORY#" \
    1.55 -	-e "s#{PAGE_TITLE}#$PAGE_TITLE_str#" \
    1.56 -	-e "s#{\([^}]*\)EDIT\([^}]*\)}#\1$EDIT\2#" \
    1.57 +	-e "s|{\([^}]*\)HISTORY\([^}]*\)}|${HISTORY//&/\&}|" \
    1.58 +	-e "s|{PAGE_TITLE}|${PAGE_TITLE_str//&/\&}|" \
    1.59 +	-e "s|{\([^}]*\)EDIT\([^}]*\)}|\1${EDIT//&/\&}\2|" \
    1.60  	-e "s|{\([^}]*\)TOC\([^}]*\)}|$(awk '{ printf "%s\\n" $0 }' <<EOT | \
    1.61  		sed -e 's/&/\\\&/g' -e 's/|/\\|/g'
    1.62  $toc