Mercurial > hgrepos > hgweb.cgi > s4
comparison 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 |
comparison
equal
deleted
inserted
replaced
941:79c7e64884c4 | 942:5d70fa029f8d |
---|---|
181 fi | 181 fi |
182 err "blog_showentry Entered: `gdate +%S.%03N` blogrowid=$rowid" | 182 err "blog_showentry Entered: `gdate +%S.%03N` blogrowid=$rowid" |
183 blog_notify=`getvalbyid blog notify "$rowid"` | 183 blog_notify=`getvalbyid blog notify "$rowid"` |
184 blog_team=`blog_getteam "$rowid"` | 184 blog_team=`blog_getteam "$rowid"` |
185 blog_mode=`getvalbyid blog mode "$rowid"` | 185 blog_mode=`getvalbyid blog mode "$rowid"` |
186 blog_math=`getvalbyid blog mathjax "$rowid"` | |
186 case "$blog_notify" in # "all", "admin" or "no" (or NULL) | 187 case "$blog_notify" in # "all", "admin" or "no" (or NULL) |
187 admin) notifyto=adm ;; | 188 admin) notifyto=adm ;; |
188 *) notifyto="" ;; | 189 *) notifyto="" ;; |
189 esac | 190 esac |
190 case $blog_mode in | 191 case $blog_mode in |
267 ;; | 268 ;; |
268 esac | 269 esac |
269 ;; | 270 ;; |
270 esac | 271 esac |
271 fi | 272 fi |
272 href4="<a href=\"#bottom\" accesskey=\"b\" title=\"Shortcut: B${nl}to the Bottom\"> 末尾へ</a>" | 273 href4="${blog_math:+Math} <a href=\"#bottom\" accesskey=\"b\" title=\"Shortcut: B${nl}to the Bottom\"> 末尾へ</a>" |
273 $isgrpadmin && | 274 $isgrpadmin && |
274 href5="<a href=\"?blogseen+$rowid\" accesskey=\"s\" title=\"Shortcut: S${nl}State of Accesses\"> 読刻</a>" | 275 href5="<a href=\"?blogseen+$rowid\" accesskey=\"s\" title=\"Shortcut: S${nl}State of Accesses\"> 読刻</a>" |
275 quizmodefile=$tmpd/quiz; rm -f "$quizmodefile" # XXX: Global state | 276 quizmodefile=$tmpd/quiz; rm -f "$quizmodefile" # XXX: Global state |
276 midfile=$tmpd/midfile | 277 midfile=$tmpd/midfile |
277 | 278 |
414 EOF | 415 EOF |
415 if [ $? -ne 0 -a ! -s $midfile ]; then | 416 if [ $? -ne 0 -a ! -s $midfile ]; then |
416 echo "時間をおいてください(Visit later please)." | html p | 417 echo "時間をおいてください(Visit later please)." | html p |
417 return | 418 return |
418 fi | 419 fi |
420 echo "${blog_math:+$mathjax}" | |
419 echo '<table class="blog_replies"> <!-- blog:blog_showentry() main table -->' | 421 echo '<table class="blog_replies"> <!-- blog:blog_showentry() main table -->' |
420 # If, nLimit = 50 | 422 # If, nLimit = 50 |
421 # show article:1, hide(2, 3), show(4, ...) | 423 # show article:1, hide(2, 3), show(4, ...) |
422 # Therefore hide 2 or more article when narts>53 | 424 # Therefore hide 2 or more article when narts>53 |
423 narts=`wc -l < $midfile` | 425 narts=`wc -l < $midfile` |
445 CAT=cat | 447 CAT=cat |
446 fi | 448 fi |
447 err "blog_showentry Started: `gdate +%S.%03N` ${fetch_ajax:+ajax}" | 449 err "blog_showentry Started: `gdate +%S.%03N` ${fetch_ajax:+ajax}" |
448 # Start blog_replies table | 450 # Start blog_replies table |
449 $CAT $midfile | | 451 $CAT $midfile | |
450 while IFS='|' read id edit notify uid author uname icon aid \ | 452 while IFS='|' read -r id edit notify uid author uname icon aid \ |
451 tm reki new hte fa imgids | 453 tm reki new hte fa imgids |
452 do | 454 do |
453 if [ -n "$omitline" ]; then | 455 if [ -n "$omitline" ]; then |
454 n=$((n+1)) | 456 n=$((n+1)) |
455 if [ $n -eq 1 ]; then | 457 if [ $n -eq 1 ]; then |
659 fi | 661 fi |
660 time=`getvalbyid blog ctime $1|colrm 11` | 662 time=`getvalbyid blog ctime $1|colrm 11` |
661 owner=`getvalbyid blog owner $1` | 663 owner=`getvalbyid blog owner $1` |
662 title=`getvalbyid blog title $1` | 664 title=`getvalbyid blog title $1` |
663 ge=`gecos "$owner"` | 665 ge=`gecos "$owner"` |
664 htmlowner=`echo ${ge:-$owner}|htmlescape` | 666 htmlowner=`printf '%s' "${ge:-$owner}"|htmlescape` |
665 fh=$tmpd/formhead | 667 fh=$tmpd/formhead |
666 echo "$time [$title]@$htmlowner" > $fh | 668 echo "$time [$title]@$htmlowner" > $fh |
667 lshandoutsub "$owner" "$@" \ | 669 lshandoutsub "$owner" "$@" \ |
668 |_m4 -D_TITLE_="提出状況" \ | 670 |_m4 -D_TITLE_="提出状況" \ |
669 -D_H1_="提出状況" \ | 671 -D_H1_="提出状況" \ |
670 -D_FORMHEAD_="syscmd(cat $fh)" \ | 672 -D_FORMHEAD_="syscmd(cat $fh)" \ |
671 -D_FORM_="syscmd(cat)" -D_DUMPHEAD_= -D_DUMPTABLE_= \ | 673 -D_FORM_="syscmd(cat)" -D_DUMPHEAD_= -D_DUMPTABLE_= \ |
672 $layout/html.m4.html $layout/form+dump-whead.m4.html | 674 $layout/html.m4.html $layout/form+dump-whead.m4.html |
673 gn=`echo $owner|htmlescape` | 675 gn=`printf '%s' "$owner"|htmlescape` |
674 echo "<p><a href=\"?lshandoutall+$1\">グループ $gn すべてのレポート板集計</a></p>" | 676 echo "<p><a href=\"?lshandoutall+$1\">グループ $gn すべてのレポート板集計</a></p>" |
675 } | 677 } |
676 gethandoutcsv() { | 678 gethandoutcsv() { |
677 # contenttype; echo | 679 # contenttype; echo |
678 CATCSV=1 lshandoutall "$1" | 680 CATCSV=1 lshandoutall "$1" |
754 EOF | 756 EOF |
755 if [ -z "$CATCSV" ]; then | 757 if [ -z "$CATCSV" ]; then |
756 _m4 -D_TITLE_="提出状況" $layout/html.m4.html | 758 _m4 -D_TITLE_="提出状況" $layout/html.m4.html |
757 ge=`gecos "$owner"` | 759 ge=`gecos "$owner"` |
758 tbls="" | 760 tbls="" |
759 grptxt=`echo "${ge:-$owner}"|htmlescape` | 761 grptxt=`printf '%s' "${ge:-$owner}"|htmlescape` |
760 echo "<h1>$grptxt 書き込み状況一覧</h1>" | 762 echo "<h1>$grptxt 書き込み状況一覧</h1>" |
761 fi | 763 fi |
762 if [ -z "$SQL" ]; then | 764 if [ -z "$SQL" ]; then |
763 bridlist=`query "SELECT brid FROM report_type_blogs;"` | 765 bridlist=`query "SELECT brid FROM report_type_blogs;"` |
764 for brid in $bridlist; do # Skip this loop if $SQL set | 766 for brid in $bridlist; do # Skip this loop if $SQL set |
765 brid=$(($brid + 0)) # Ensure to be a number | 767 brid=$(($brid + 0)) # Ensure to be a number |
766 [ $brid = 0 ] && continue | 768 [ $brid = 0 ] && continue |
767 time=`getvalbyid blog ctime $brid|colrm 11` | 769 time=`getvalbyid blog ctime $brid|colrm 11` |
768 title=`getvalbyid blog title $brid` | 770 title=`getvalbyid blog title $brid` |
769 titleH=`echo "$title"|htmlescape` | 771 titleH=`printf '%s' "$title"|htmlescape` |
770 state=`getvalbyid blog state $brid|htmlescape` | 772 state=`getvalbyid blog state $brid|htmlescape` |
771 tt="handout_$brid" | 773 tt="handout_$brid" |
772 [ "$state" = "frozen" ] && frozen=" $FROZEN_TAG" || frozen="" | 774 [ "$state" = "frozen" ] && frozen=" $FROZEN_TAG" || frozen="" |
773 if [ -z "$CATCSV" ]; then | 775 if [ -z "$CATCSV" ]; then |
774 echo "<h2>$time - <a href=\"?replyblog+$brid\">$titleH</a>$frozen</h2>" | 776 echo "<h2>$time - <a href=\"?replyblog+$brid\">$titleH</a>$frozen</h2>" |
1051 td=${time:+"<td>"} # If the variable time is set, td=<td> | 1053 td=${time:+"<td>"} # If the variable time is set, td=<td> |
1052 td=${td:-"<td$warn>"} # else td=<td class="warn"> | 1054 td=${td:-"<td$warn>"} # else td=<td class="warn"> |
1053 cat <<-EOF | 1055 cat <<-EOF |
1054 <tr> | 1056 <tr> |
1055 <td><a href="?home+$uid">`echo "$hexge"|unhexize|htmlescape`</a></td> | 1057 <td><a href="?home+$uid">`echo "$hexge"|unhexize|htmlescape`</a></td> |
1056 <td>`echo ${u%%@*}|htmlescape`</td> | 1058 <td>`printf '%s' "${u%%@*}"|htmlescape`</td> |
1057 $td${time:----}</td></tr> | 1059 $td${time:----}</td></tr> |
1058 EOF | 1060 EOF |
1059 done | 1061 done |
1060 cat <<-EOF | 1062 cat <<-EOF |
1061 </table> | 1063 </table> |
1178 if expr x"$kwd" : 'x#[1-9][0-9]*$' >/dev/null 1>&2; then | 1180 if expr x"$kwd" : 'x#[1-9][0-9]*$' >/dev/null 1>&2; then |
1179 # Like '#1234', assume as artID | 1181 # Like '#1234', assume as artID |
1180 rowid=$((${kwd#\#} + 0)) # Force to be a number | 1182 rowid=$((${kwd#\#} + 0)) # Force to be a number |
1181 kc="ar.rowid = $rowid" | 1183 kc="ar.rowid = $rowid" |
1182 else | 1184 else |
1183 for k in `echo "$kwd" | sed "s/'/''/g"`; do # With wrap quotes | 1185 for k in `printf '%s' "$kwd" | sed "s/'/''/g"`; do # With wrap quotes |
1184 ctime="" | 1186 ctime="" |
1185 if expr x"$k" : 'x@[><= ]*[1-9][][0-9]*-[][0-9:-]*$' >/dev/null >&2; then | 1187 if expr x"$k" : 'x@[><= ]*[1-9][][0-9]*-[][0-9:-]*$' >/dev/null >&2; then |
1186 # '@<2016-10-10' -> ctime < '2016-10-10' | 1188 # '@<2016-10-10' -> ctime < '2016-10-10' |
1187 # '@>=2016-10-10' -> ctime >= '2016-10-10' | 1189 # '@>=2016-10-10' -> ctime >= '2016-10-10' |
1188 # '@2016-10-10' -> ctime GLOB '@2016-10-10' | 1190 # '@2016-10-10' -> ctime GLOB '@2016-10-10' |
1216 kc=$kc${kc:+" AND "}"ctime > '${ctime}'" | 1218 kc=$kc${kc:+" AND "}"ctime > '${ctime}'" |
1217 else | 1219 else |
1218 e="" | 1220 e="" |
1219 case "$k" in | 1221 case "$k" in |
1220 *${likeesc}*) e="" ;; # Giving up char-escaping | 1222 *${likeesc}*) e="" ;; # Giving up char-escaping |
1221 *%*|*_*) k=`echo "$k"|sed "s/\([%_]\)/${likeesc}\1/g"` | 1223 *%*|*_*) k=`printf '%s' "$k"|sed "s/\([%_]\)/${likeesc}\1/g"` |
1222 e=" ESCAPE '$likeesc'" ;; | 1224 e=" ESCAPE '$likeesc'" ;; |
1223 esac | 1225 esac |
1224 kc=$kc${kc:+" AND "}"content LIKE '%$k%'$e" | 1226 kc=$kc${kc:+" AND "}"content LIKE '%$k%'$e" |
1225 fi | 1227 fi |
1226 done | 1228 done |
1227 fi | 1229 fi |
1228 kwd=`echo "$kwd"|htmlescape` | 1230 kwd=`printf '%s' "$kwd"|htmlescape` |
1229 owner=`getpar owner` | 1231 owner=`getpar owner` |
1230 owner=${owner:-$1} | 1232 owner=${owner:-$1} |
1231 grid=`getpar grid` | 1233 grid=`getpar grid` |
1232 msg="" | 1234 msg="" |
1233 if [ -n "$grid" ]; then | 1235 if [ -n "$grid" ]; then |
1357 fi | 1359 fi |
1358 # echo "{\"code\": $code, \"message\": \"foo\"}"; exit | 1360 # echo "{\"code\": $code, \"message\": \"foo\"}"; exit |
1359 newval=`getvalbyid blog "$2" "$1"` | 1361 newval=`getvalbyid blog "$2" "$1"` |
1360 alert="${msg:+, \"alert\": \"$msg\"}" | 1362 alert="${msg:+, \"alert\": \"$msg\"}" |
1361 json=$(cat <<-EOF | 1363 json=$(cat <<-EOF |
1362 {"code": $code, "$2": "`echo "$newval"|sed 's/"/\\\\"/g'`"$alert} | 1364 {"code": $code, "$2": "`printf '%s' "$newval"|sed 's/"/\\\\"/g'`"$alert} |
1363 EOF | 1365 EOF |
1364 ) | 1366 ) |
1365 err blog_setval: returning JSON: "$json" | 1367 err blog_setval: returning JSON: "$json" |
1366 echo "$json" | 1368 printf '%s\n' "$json" |
1367 exit | 1369 exit |
1368 } | 1370 } |
1369 | 1371 |
1370 blog_setfrozen() { | 1372 blog_setfrozen() { |
1371 # $1=GRProwID $2=val={ "frozen" | "" } | 1373 # $1=GRProwID $2=val={ "frozen" | "" } |
1385 if [ -n "$grprowid" ]; then | 1387 if [ -n "$grprowid" ]; then |
1386 owner=`getgroupbyid $grprowid` | 1388 owner=`getgroupbyid $grprowid` |
1387 else | 1389 else |
1388 owner=`getpar owner` | 1390 owner=`getpar owner` |
1389 fi | 1391 fi |
1390 htmlowner=`echo $owner|htmlescape` | 1392 htmlowner=`printf '%s' $owner|htmlescape` |
1391 err blog-add: \$1=$grprowid rowid=$rowid owner=$owner | 1393 err blog-add: \$1=$grprowid rowid=$rowid owner=$owner |
1392 if isgroup "$owner"; then | 1394 if isgroup "$owner"; then |
1393 if [ -z "$grprowid" ]; then | 1395 if [ -z "$grprowid" ]; then |
1394 qgrp=`sqlquote "$owner"` # Inefficient... | 1396 qgrp=`sqlquote "$owner"` # Inefficient... |
1395 grprowid=`query "SELECT rowid FROM grp WHERE gname=$qgrp;"` | 1397 grprowid=`query "SELECT rowid FROM grp WHERE gname=$qgrp;"` |
1479 echo "表示する日記番号が未指定です。" | html p | 1481 echo "表示する日記番号が未指定です。" | html p |
1480 return | 1482 return |
1481 fi | 1483 fi |
1482 title=`getvalbyid blog title $rowid` | 1484 title=`getvalbyid blog title $rowid` |
1483 owner=`getvalbyid blog owner $rowid` | 1485 owner=`getvalbyid blog owner $rowid` |
1484 htmlowner=`echo $owner|htmlescape` | 1486 htmlowner=`printf '%s' $owner|htmlescape` |
1485 qowner=`sqlquotestr "$owner"` | 1487 qowner=`sqlquotestr "$owner"` |
1486 if [ -z "$title" ]; then | 1488 if [ -z "$title" ]; then |
1487 echo "日記番号指定が無効です。" | html p | 1489 echo "日記番号指定が無効です。" | html p |
1488 return | 1490 return |
1489 fi | 1491 fi |