s4
diff s4-blog.sh @ 942:5d70fa029f8d
Support MathJax rendering
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Mon, 25 Oct 2021 18:39:44 +0900 |
parents | 6c2f8bb3cc6e |
children | 420ad90116e6 |
line diff
1.1 --- a/s4-blog.sh Mon Sep 06 09:11:25 2021 +0900 1.2 +++ b/s4-blog.sh Mon Oct 25 18:39:44 2021 +0900 1.3 @@ -183,6 +183,7 @@ 1.4 blog_notify=`getvalbyid blog notify "$rowid"` 1.5 blog_team=`blog_getteam "$rowid"` 1.6 blog_mode=`getvalbyid blog mode "$rowid"` 1.7 + blog_math=`getvalbyid blog mathjax "$rowid"` 1.8 case "$blog_notify" in # "all", "admin" or "no" (or NULL) 1.9 admin) notifyto=adm ;; 1.10 *) notifyto="" ;; 1.11 @@ -269,7 +270,7 @@ 1.12 ;; 1.13 esac 1.14 fi 1.15 - href4="<a href=\"#bottom\" accesskey=\"b\" title=\"Shortcut: B${nl}to the Bottom\"> 末尾へ</a>" 1.16 + href4="${blog_math:+Math} <a href=\"#bottom\" accesskey=\"b\" title=\"Shortcut: B${nl}to the Bottom\"> 末尾へ</a>" 1.17 $isgrpadmin && 1.18 href5="<a href=\"?blogseen+$rowid\" accesskey=\"s\" title=\"Shortcut: S${nl}State of Accesses\"> 読刻</a>" 1.19 quizmodefile=$tmpd/quiz; rm -f "$quizmodefile" # XXX: Global state 1.20 @@ -416,6 +417,7 @@ 1.21 echo "時間をおいてください(Visit later please)." | html p 1.22 return 1.23 fi 1.24 + echo "${blog_math:+$mathjax}" 1.25 echo '<table class="blog_replies"> <!-- blog:blog_showentry() main table -->' 1.26 # If, nLimit = 50 1.27 # show article:1, hide(2, 3), show(4, ...) 1.28 @@ -447,7 +449,7 @@ 1.29 err "blog_showentry Started: `gdate +%S.%03N` ${fetch_ajax:+ajax}" 1.30 # Start blog_replies table 1.31 $CAT $midfile | 1.32 - while IFS='|' read id edit notify uid author uname icon aid \ 1.33 + while IFS='|' read -r id edit notify uid author uname icon aid \ 1.34 tm reki new hte fa imgids 1.35 do 1.36 if [ -n "$omitline" ]; then 1.37 @@ -661,7 +663,7 @@ 1.38 owner=`getvalbyid blog owner $1` 1.39 title=`getvalbyid blog title $1` 1.40 ge=`gecos "$owner"` 1.41 - htmlowner=`echo ${ge:-$owner}|htmlescape` 1.42 + htmlowner=`printf '%s' "${ge:-$owner}"|htmlescape` 1.43 fh=$tmpd/formhead 1.44 echo "$time [$title]@$htmlowner" > $fh 1.45 lshandoutsub "$owner" "$@" \ 1.46 @@ -670,7 +672,7 @@ 1.47 -D_FORMHEAD_="syscmd(cat $fh)" \ 1.48 -D_FORM_="syscmd(cat)" -D_DUMPHEAD_= -D_DUMPTABLE_= \ 1.49 $layout/html.m4.html $layout/form+dump-whead.m4.html 1.50 - gn=`echo $owner|htmlescape` 1.51 + gn=`printf '%s' "$owner"|htmlescape` 1.52 echo "<p><a href=\"?lshandoutall+$1\">グループ $gn すべてのレポート板集計</a></p>" 1.53 } 1.54 gethandoutcsv() { 1.55 @@ -756,7 +758,7 @@ 1.56 _m4 -D_TITLE_="提出状況" $layout/html.m4.html 1.57 ge=`gecos "$owner"` 1.58 tbls="" 1.59 - grptxt=`echo "${ge:-$owner}"|htmlescape` 1.60 + grptxt=`printf '%s' "${ge:-$owner}"|htmlescape` 1.61 echo "<h1>$grptxt 書き込み状況一覧</h1>" 1.62 fi 1.63 if [ -z "$SQL" ]; then 1.64 @@ -766,7 +768,7 @@ 1.65 [ $brid = 0 ] && continue 1.66 time=`getvalbyid blog ctime $brid|colrm 11` 1.67 title=`getvalbyid blog title $brid` 1.68 - titleH=`echo "$title"|htmlescape` 1.69 + titleH=`printf '%s' "$title"|htmlescape` 1.70 state=`getvalbyid blog state $brid|htmlescape` 1.71 tt="handout_$brid" 1.72 [ "$state" = "frozen" ] && frozen=" $FROZEN_TAG" || frozen="" 1.73 @@ -1053,7 +1055,7 @@ 1.74 cat <<-EOF 1.75 <tr> 1.76 <td><a href="?home+$uid">`echo "$hexge"|unhexize|htmlescape`</a></td> 1.77 - <td>`echo ${u%%@*}|htmlescape`</td> 1.78 + <td>`printf '%s' "${u%%@*}"|htmlescape`</td> 1.79 $td${time:----}</td></tr> 1.80 EOF 1.81 done 1.82 @@ -1180,7 +1182,7 @@ 1.83 rowid=$((${kwd#\#} + 0)) # Force to be a number 1.84 kc="ar.rowid = $rowid" 1.85 else 1.86 - for k in `echo "$kwd" | sed "s/'/''/g"`; do # With wrap quotes 1.87 + for k in `printf '%s' "$kwd" | sed "s/'/''/g"`; do # With wrap quotes 1.88 ctime="" 1.89 if expr x"$k" : 'x@[><= ]*[1-9][][0-9]*-[][0-9:-]*$' >/dev/null >&2; then 1.90 # '@<2016-10-10' -> ctime < '2016-10-10' 1.91 @@ -1218,14 +1220,14 @@ 1.92 e="" 1.93 case "$k" in 1.94 *${likeesc}*) e="" ;; # Giving up char-escaping 1.95 - *%*|*_*) k=`echo "$k"|sed "s/\([%_]\)/${likeesc}\1/g"` 1.96 + *%*|*_*) k=`printf '%s' "$k"|sed "s/\([%_]\)/${likeesc}\1/g"` 1.97 e=" ESCAPE '$likeesc'" ;; 1.98 esac 1.99 kc=$kc${kc:+" AND "}"content LIKE '%$k%'$e" 1.100 fi 1.101 done 1.102 fi 1.103 - kwd=`echo "$kwd"|htmlescape` 1.104 + kwd=`printf '%s' "$kwd"|htmlescape` 1.105 owner=`getpar owner` 1.106 owner=${owner:-$1} 1.107 grid=`getpar grid` 1.108 @@ -1359,11 +1361,11 @@ 1.109 newval=`getvalbyid blog "$2" "$1"` 1.110 alert="${msg:+, \"alert\": \"$msg\"}" 1.111 json=$(cat <<-EOF 1.112 - {"code": $code, "$2": "`echo "$newval"|sed 's/"/\\\\"/g'`"$alert} 1.113 + {"code": $code, "$2": "`printf '%s' "$newval"|sed 's/"/\\\\"/g'`"$alert} 1.114 EOF 1.115 ) 1.116 err blog_setval: returning JSON: "$json" 1.117 - echo "$json" 1.118 + printf '%s\n' "$json" 1.119 exit 1.120 } 1.121 1.122 @@ -1387,7 +1389,7 @@ 1.123 else 1.124 owner=`getpar owner` 1.125 fi 1.126 - htmlowner=`echo $owner|htmlescape` 1.127 + htmlowner=`printf '%s' $owner|htmlescape` 1.128 err blog-add: \$1=$grprowid rowid=$rowid owner=$owner 1.129 if isgroup "$owner"; then 1.130 if [ -z "$grprowid" ]; then 1.131 @@ -1481,7 +1483,7 @@ 1.132 fi 1.133 title=`getvalbyid blog title $rowid` 1.134 owner=`getvalbyid blog owner $rowid` 1.135 - htmlowner=`echo $owner|htmlescape` 1.136 + htmlowner=`printf '%s' $owner|htmlescape` 1.137 qowner=`sqlquotestr "$owner"` 1.138 if [ -z "$title" ]; then 1.139 echo "日記番号指定が無効です。" | html p