changeset 802:1de1319dce99 feature-world

merged
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 14 Jun 2020 12:48:43 +0900
parents 12a567f00744 (current diff) d368b937956e (diff)
children fc271965bd56
files s4-blog.sh s4-funcs.sh scripts/s4-sns.case
diffstat 3 files changed, 30 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/s4-blog.sh	Sun Jun 14 11:33:02 2020 +0900
+++ b/s4-blog.sh	Sun Jun 14 12:48:43 2020 +0900
@@ -113,7 +113,7 @@
 )
 
 blog_showentry() {
-  # $1=table $2=rowid
+  # $1=table $2=rowid $3(optional)=control-sequence
   # if [ -n "$2" ]; then
   #   if [ -n "$imgcached" ]; then
   #     bstmpdir=$tmpdir/$imgcached/$thumbxy
@@ -123,6 +123,7 @@
   #     # tmpfiles=$tmpfiles" $tmpd"
   #   fi
   # fi
+  control=$3
   td=`getcachedir "article/$2"`
   [ -d "$td" ] || mkdir -p $td
   tbl=${1%%[!A-Z0-9a-z_]*} rowid=${2%%[!A-Z0-9a-z_]*}
@@ -273,7 +274,7 @@
 	echo "${blogtype}モードは本人と管理者の書き込みのみが表示されます。"
 	;;
     esac | html p 'class="warn"'
-    echo '<table class="blog_replies"> <!-- blog:blog_showentry() main table -->'
+
     if [ x"$blogtype" = x"クイズ" -o x"$blogtype" = x"XXXX集計" ]; then
       if $isgroup; then
 	# Failsafe to query timeout
@@ -298,6 +299,16 @@
     echo "時間をおいて繋いでください(Please visit later)." | html p
     return
   fi
+  ## Parse control sequence
+  nlimit=$listartlimit
+  case "$control" in
+    n:[Aa][Ll][Ll])
+	unset nlimit ;;
+    n:*)
+	nlimit=${control##*:}
+	nlimit=${nlimit%%[!A-Z0-9a-z_]*}
+	;;
+  esac
   lkhome="<a href=\"$myname?home" lke='">'
   lkedit="<a href=\"$myname?editart"
   hlink="$myname?home" elink="$myname?editart"
@@ -379,7 +390,17 @@
     echo "時間をおいてください(Visit later please)." | html p
     return
   fi
-  cat $midfile |
+  if [ -n "$nlimit" -a `wc -l < $midfile` -gt "$nlimit" ]; then
+    CAT="tail -n $nlimit"
+    limitedmsg="<small class=\"warn\">※最新${nlimit}件のみの表示</small>"
+    showalllink="<a title=\"Show All\" href=\"?replyblog+$rowid+n:all\">全件表示</a>"
+    echo $limitedmsg$showalllink | html p
+  else
+    CAT=cat
+  fi
+  # Start blog_replies table
+  echo '<table class="blog_replies"> <!-- blog:blog_showentry() main table -->'
+  $CAT $midfile |
   while IFS='|' read id edit notify uid author uname icon aid \
 	   tm reki new hte fa imgids
   do
@@ -532,7 +553,8 @@
 	 href="?reload/$rowid" accesskey="r"
 	  title="Shortcut: R${nl}Reload">再読込</a> / <a
 	 href="#title" id="bottom" accesskey="t"
-	  title="Shortcut: T${nl}to the Top">先頭へ</a></p>
+	  title="Shortcut: T${nl}to the Top">先頭へ</a>
+	 ${showalllink:+/ $showalllink$limitedmsg}</p>
 	EOF
   $iswritable && cat<<-EOF
 	<div class="blogcomment">
@@ -1250,6 +1272,7 @@
 }
 
 blog_reply() {		# Posting to blog article
+  # $1=rowid $2=control-sequence
   rowid=`numericalize $1`	# Ensure (already purified in s4.cgi)
 
   if [ -z "$rowid" ]; then
@@ -1329,7 +1352,7 @@
   def=$formdir/article.def
   echo "$title" | htmlescape > $tmpd/title.$$
   echo "$subtitle$frozen_flag" > $tmpd/subtitle.$$
-  ${BLOG_SHOW:-blog_showentry} blog $rowid \
+  ${BLOG_SHOW:-blog_showentry} blog $rowid "$2" \
       | _m4 -D_TITLE_="spaste(\`$tmpd/title.$$')" \
 	    -D_BODYCLASS_=general"${memclass:+ $memclass}" \
 	    -D_FORMHEAD_="spaste(\`$tmpd/subtitle.$$')" \
--- a/s4-funcs.sh	Sun Jun 14 11:33:02 2020 +0900
+++ b/s4-funcs.sh	Sun Jun 14 12:48:43 2020 +0900
@@ -38,6 +38,7 @@
 sesstb=tmp.sess
 workdb=$dbdir/tmpdata.sq3
 listentlimit=${LISTENTLIMIT:-30}
+listartlimit=${LISTARTLIMIT:-50}
 admin=${ADMIN:-hostmaster@example.org}
 noreply=${NOREPLY:-noreply@example.org}
 noreply_from="${S4NAME:-s4} message notification <$noreply>"
--- a/scripts/s4-sns.case	Sun Jun 14 11:33:02 2020 +0900
+++ b/scripts/s4-sns.case	Sun Jun 14 12:48:43 2020 +0900
@@ -33,7 +33,7 @@
     contenttype; echo
     rowid=${2%%[!A-Z0-9a-z_]*}
     . ./s4-blog.sh
-    blog_reply $rowid
+    blog_reply $rowid "$3"
     ;;
   aid[1-9]*)
     arid=${1#aid}

yatex.org