Mercurial > hgrepos > hgweb.cgi > s4
diff s4-blog.sh @ 942:5d70fa029f8d draft
Support MathJax rendering
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Mon, 25 Oct 2021 18:39:44 +0900 |
parents | 6c2f8bb3cc6e |
children | 420ad90116e6 |
line wrap: on
line diff
--- a/s4-blog.sh Wed Sep 22 08:39:36 2021 +0900 +++ b/s4-blog.sh Mon Oct 25 18:39:44 2021 +0900 @@ -183,6 +183,7 @@ blog_notify=`getvalbyid blog notify "$rowid"` blog_team=`blog_getteam "$rowid"` blog_mode=`getvalbyid blog mode "$rowid"` + blog_math=`getvalbyid blog mathjax "$rowid"` case "$blog_notify" in # "all", "admin" or "no" (or NULL) admin) notifyto=adm ;; *) notifyto="" ;; @@ -269,7 +270,7 @@ ;; esac fi - href4="<a href=\"#bottom\" accesskey=\"b\" title=\"Shortcut: B${nl}to the Bottom\"> 末尾へ</a>" + href4="${blog_math:+Math} <a href=\"#bottom\" accesskey=\"b\" title=\"Shortcut: B${nl}to the Bottom\"> 末尾へ</a>" $isgrpadmin && href5="<a href=\"?blogseen+$rowid\" accesskey=\"s\" title=\"Shortcut: S${nl}State of Accesses\"> 読刻</a>" quizmodefile=$tmpd/quiz; rm -f "$quizmodefile" # XXX: Global state @@ -416,6 +417,7 @@ echo "時間をおいてください(Visit later please)." | html p return fi + echo "${blog_math:+$mathjax}" echo '<table class="blog_replies"> <!-- blog:blog_showentry() main table -->' # If, nLimit = 50 # show article:1, hide(2, 3), show(4, ...) @@ -447,7 +449,7 @@ err "blog_showentry Started: `gdate +%S.%03N` ${fetch_ajax:+ajax}" # Start blog_replies table $CAT $midfile | - while IFS='|' read id edit notify uid author uname icon aid \ + while IFS='|' read -r id edit notify uid author uname icon aid \ tm reki new hte fa imgids do if [ -n "$omitline" ]; then @@ -661,7 +663,7 @@ owner=`getvalbyid blog owner $1` title=`getvalbyid blog title $1` ge=`gecos "$owner"` - htmlowner=`echo ${ge:-$owner}|htmlescape` + htmlowner=`printf '%s' "${ge:-$owner}"|htmlescape` fh=$tmpd/formhead echo "$time [$title]@$htmlowner" > $fh lshandoutsub "$owner" "$@" \ @@ -670,7 +672,7 @@ -D_FORMHEAD_="syscmd(cat $fh)" \ -D_FORM_="syscmd(cat)" -D_DUMPHEAD_= -D_DUMPTABLE_= \ $layout/html.m4.html $layout/form+dump-whead.m4.html - gn=`echo $owner|htmlescape` + gn=`printf '%s' "$owner"|htmlescape` echo "<p><a href=\"?lshandoutall+$1\">グループ $gn すべてのレポート板集計</a></p>" } gethandoutcsv() { @@ -756,7 +758,7 @@ _m4 -D_TITLE_="提出状況" $layout/html.m4.html ge=`gecos "$owner"` tbls="" - grptxt=`echo "${ge:-$owner}"|htmlescape` + grptxt=`printf '%s' "${ge:-$owner}"|htmlescape` echo "<h1>$grptxt 書き込み状況一覧</h1>" fi if [ -z "$SQL" ]; then @@ -766,7 +768,7 @@ [ $brid = 0 ] && continue time=`getvalbyid blog ctime $brid|colrm 11` title=`getvalbyid blog title $brid` - titleH=`echo "$title"|htmlescape` + titleH=`printf '%s' "$title"|htmlescape` state=`getvalbyid blog state $brid|htmlescape` tt="handout_$brid" [ "$state" = "frozen" ] && frozen=" $FROZEN_TAG" || frozen="" @@ -1053,7 +1055,7 @@ cat <<-EOF <tr> <td><a href="?home+$uid">`echo "$hexge"|unhexize|htmlescape`</a></td> - <td>`echo ${u%%@*}|htmlescape`</td> + <td>`printf '%s' "${u%%@*}"|htmlescape`</td> $td${time:----}</td></tr> EOF done @@ -1180,7 +1182,7 @@ rowid=$((${kwd#\#} + 0)) # Force to be a number kc="ar.rowid = $rowid" else - for k in `echo "$kwd" | sed "s/'/''/g"`; do # With wrap quotes + for k in `printf '%s' "$kwd" | sed "s/'/''/g"`; do # With wrap quotes ctime="" if expr x"$k" : 'x@[><= ]*[1-9][][0-9]*-[][0-9:-]*$' >/dev/null >&2; then # '@<2016-10-10' -> ctime < '2016-10-10' @@ -1218,14 +1220,14 @@ e="" case "$k" in *${likeesc}*) e="" ;; # Giving up char-escaping - *%*|*_*) k=`echo "$k"|sed "s/\([%_]\)/${likeesc}\1/g"` + *%*|*_*) k=`printf '%s' "$k"|sed "s/\([%_]\)/${likeesc}\1/g"` e=" ESCAPE '$likeesc'" ;; esac kc=$kc${kc:+" AND "}"content LIKE '%$k%'$e" fi done fi - kwd=`echo "$kwd"|htmlescape` + kwd=`printf '%s' "$kwd"|htmlescape` owner=`getpar owner` owner=${owner:-$1} grid=`getpar grid` @@ -1359,11 +1361,11 @@ newval=`getvalbyid blog "$2" "$1"` alert="${msg:+, \"alert\": \"$msg\"}" json=$(cat <<-EOF - {"code": $code, "$2": "`echo "$newval"|sed 's/"/\\\\"/g'`"$alert} + {"code": $code, "$2": "`printf '%s' "$newval"|sed 's/"/\\\\"/g'`"$alert} EOF ) err blog_setval: returning JSON: "$json" - echo "$json" + printf '%s\n' "$json" exit } @@ -1387,7 +1389,7 @@ else owner=`getpar owner` fi - htmlowner=`echo $owner|htmlescape` + htmlowner=`printf '%s' $owner|htmlescape` err blog-add: \$1=$grprowid rowid=$rowid owner=$owner if isgroup "$owner"; then if [ -z "$grprowid" ]; then @@ -1481,7 +1483,7 @@ fi title=`getvalbyid blog title $rowid` owner=`getvalbyid blog owner $rowid` - htmlowner=`echo $owner|htmlescape` + htmlowner=`printf '%s' $owner|htmlescape` qowner=`sqlquotestr "$owner"` if [ -z "$title" ]; then echo "日記番号指定が無効です。" | html p