diff s4-funcs.sh @ 350:a6ff48595a4d

Add link to raw format of text file
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 25 Oct 2016 22:56:41 +0859
parents 332765572341
children deb4cc74a415
line wrap: on
line diff
--- a/s4-funcs.sh	Tue Oct 25 22:48:19 2016 +0859
+++ b/s4-funcs.sh	Tue Oct 25 22:56:41 2016 +0859
@@ -3338,7 +3338,7 @@
   GF_VIEWONLY=1 genform "$@"
 }
 showattc() {
-  # $1=table_m $2=rowid
+  # $1=table_m $2=rowid &optional $3=RawFlag
   err \$1=$1 \$2=$2
   if ! isfilereadable $user $1 $2; then
     contenttype; echo
@@ -3361,12 +3361,17 @@
       case $charset in
 	ASCII*)	charset=""	;;
       esac
-      ct="text/html${charset:+; charset=$charset}"
-      cat $bin | htmlescape \
-	  | sed 's,^,<span></span>,' \
-	  | _m4 -D_TITLE_="$fn" -D_CONTENT_TYPE_="$ct" \
-		-D_BODY_="syscmd(\`cat')" $layout/pretty.m4.txt
-      exit $?
+      if [ -z "$3" ]; then
+	ct="text/html${charset:+; charset=$charset}"
+	link="?showattc+$1+$2+raw"
+	cat $bin | htmlescape \
+	    | sed 's,^,<span></span>,' \
+	    | _m4 -D_TITLE_="$fn" -D_CONTENT_TYPE_="$ct" \
+		  -D_LINK_="$link" \
+		  -D_BODY_="syscmd(\`cat')" $layout/pretty.m4.txt
+	exit $?
+      fi
+      ct="text/plain${charset:+; charset=$charset}"
       ;;
   esac
   contenttype "$ct"

yatex.org