changeset 866:a2e2bf4ee7eb

Archive report files order by uname.
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 06 Sep 2020 11:24:28 +0859
parents 8c69e0c2e6af
children 1b0669c854cf
files s4-blog.sh scripts/s4-sns.case
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/s4-blog.sh	Wed Sep 02 17:09:24 2020 +0900
+++ b/s4-blog.sh	Sun Sep 06 11:24:28 2020 +0859
@@ -232,7 +232,7 @@
 	case "$isgrpadmin$blog_mode" in
 	  false*closed*|false*quiz|false*enquete*) ;;
 	  *)
-	    href3="(<a href=\"?gethandout+$rowid\" accesskey=\"f\" title=\"Shortcut: F${nl}File Retrieval\">ファイル取得</a>)"
+	    href3="(ファイル取得[<a href=\"?gethandout+$rowid\" accesskey=\"f\" title=\"Shortcut: F${nl}File Retrieval\">記事順</a>|<a href=\"?gethandout+$rowid+by_uname\" accesskey=\"u\" title=\"Shortcut: F${nl}File Retrieval by User\">著者順</a>])"
 	    ;;
 	esac
 	;;
@@ -792,6 +792,7 @@
 gethandout() {
   # $1=rowid of blog
   rid=`numericalize "$1"`
+  test x"$2" = x"by_uname" && by_uname="$2"
   blog_writable $rid $user
   rc=$?		# =0: writable, $BLOG_NOTMEM bit set => not member
   if [ $((rc & $BLOG_NOTMEM)) -gt 0 ] ; then
@@ -881,23 +882,33 @@
   query <<-EOF > $midfile		# Using tempfile for quick db-unlock
 	SELECT a.rowid, a.id artid, a.author, hex(s.val)
 	FROM article a JOIN article_s s ON a.id=s.id
-	WHERE blogid=(SELECT id FROM blog WHERE rowid=$rid);
+	WHERE blogid=(SELECT id FROM blog WHERE rowid=$rid)
+	ORDER BY a.rowid;
 	EOF
   cat $midfile | while IFS='|' read rowid artid author text; do
     $isgrpowner || $isopenblogauthor \
       || isfilereadable $user article_s $rowid || continue
-    dir=`printf $bd/%d/%06d "$rid" "$rowid"`
+    if [ "$by_uname" ]; then
+      dir=`printf $bd/%d/%s "$rid" "$author"`
+    else
+      dir=`printf $bd/%d/%06d "$rid" "$rowid"`
+    fi
+    txt=`printf %06d $rowid`.txt
     mkdir -p $dir
     echo "$author" > $dir/Author
-    echo "$text" | unhexize > $dir/Text
+    echo "$text" | unhexize > $dir/$txt
     i=0
     query "SELECT m.rowid, m.val FROM article_m m \
 	   WHERE id='$artid' AND m.key IN ('image', 'document', 'binary');" \
       | while IFS='|' read mrowid filename; do
           i=$((i+1))
-          outfile=`printf "%s/%02d-%s" "$dir" $i "$filename"`
+    	  if [ "$by_uname" ]; then
+            outfile=`printf "%s/%06d-%s" "$dir" $rowid "$filename"`
+	  else
+            outfile=`printf "%s/%02d-%s" "$dir" $i "$filename"`
+	  fi
           query "SELECT quote(bin) FROM article_m WHERE rowid=$mrowid;" \
-		| unhexize > $outfile
+		| unhexize > "$outfile"
     done
   done
   if [ ! -d $bd/$rid ]; then
--- a/scripts/s4-sns.case	Wed Sep 02 17:09:24 2020 +0900
+++ b/scripts/s4-sns.case	Sun Sep 06 11:24:28 2020 +0859
@@ -56,7 +56,8 @@
       return
     fi
     . ./s4-blog.sh
-    $stage $rowid
+    shift; shift
+    $stage $rowid "$@"
     ;;
   lsmyfile)
     contenttype; echo

yatex.org