s4

changeset 192:50e6195130b3

blog_showentry2() is now blog_showentry() (Old code removed)
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 23 Apr 2016 22:57:54 +0859
parents 24e0f2b4d51b
children 5d83ff0bbd40
files s4-blog.sh
diffstat 1 files changed, 1 insertions(+), 180 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Sat Apr 23 21:10:55 2016 +0859
     1.2 +++ b/s4-blog.sh	Sat Apr 23 22:57:54 2016 +0859
     1.3 @@ -49,6 +49,7 @@
     1.4  `echo "$3"|sed 's/^/> /'`
     1.5  EOF
     1.6  )
     1.7 +
     1.8  blog_showentry() {
     1.9    # $1=table $2=rowid
    1.10    # if [ -n "$2" ]; then
    1.11 @@ -87,188 +88,6 @@
    1.12        fi
    1.13      fi
    1.14    fi
    1.15 -
    1.16 -  err "SELECT id from $tbl where rowid=$rowid"
    1.17 -  id=`query "select id from $tbl where rowid=$rowid;"`
    1.18 -err id=$id
    1.19 -err "select val from $ts where key='title' and id='$id';"
    1.20 -
    1.21 -
    1.22 -  #(1)Display root article
    1.23 -  cat<<EOF
    1.24 -<form class="replyblog" action="$myname?replyblog+${rowid}#bottom" method="POST" enctype="multipart/form-data">
    1.25 -<table class="bloghead">
    1.26 -EOF
    1.27 -
    1.28 -  href="<a href=\"?editheading+$rowid\"> 編集 </a>"
    1.29 -  if $iswritable; then
    1.30 -    href2="<a href=\"?lshandout+$rowid\"> 提出状況 </a>"
    1.31 -    href3="(<a href=\"?gethandout+$rowid\">ファイル取得</a>)"
    1.32 -  fi
    1.33 -  cat<<EOF | sq -html $db \
    1.34 -      | sed -e "s|\(<TR><TD>\),e,|\1 $href |" \
    1.35 -	    -e "s|,s,\(</TD>\)|$href2$href3\1|"
    1.36 --- select val from $ts where key="title" and id="$id";
    1.37 -select
    1.38 - coalesce((select ",e," from blog where rowid=$rowid and author='$user'),'')
    1.39 -||val||" "
    1.40 -||case (select val from $ts where key="mode" and id="$id")
    1.41 -  when 'report-closed' then "レポート提出用(自身のファイルのみ参照可),s,"
    1.42 -  when 'report-open' then "レポート提出用,s,"
    1.43 -  else ""
    1.44 -  end
    1.45 - from $ts where key="ctime" and id="$id";
    1.46 -select val from $ts where key="heading" and id="$id";
    1.47 -EOF
    1.48 -  cat<<EOF
    1.49 -</table>
    1.50 -<table class="blog_replies">
    1.51 -EOF
    1.52 -
    1.53 -  #(2)Display following articles
    1.54 -textform='<div><table class="b">
    1.55 -<tr><td><textarea name="text" cols="40" rows="4"></textarea></td></tr>
    1.56 -<tr><td>添付ファイル: <input type="file" name="image" multiple></td></tr>
    1.57 -</table>
    1.58 -<input type="submit" value="送信">
    1.59 -<input type="reset" value="リセット"></div>
    1.60 -'
    1.61 -  ## 6/11の次: articleを出して行く
    1.62 -: <<EOF
    1.63 -シリアル:id:p:serial:
    1.64 -blogID:blogid:f:blog(id):
    1.65 -筆者:author:s:owner
    1.66 -時刻:ctime:s:stamp:
    1.67 -参照元:parent:s:parent: 
    1.68 -パス:path:s:path:
    1.69 -本文:text:s:textarea:cols="60" rows="8"
    1.70 -画像:image:m:image:
    1.71 -stage:stage:x:hidden:value="replyblog"
    1.72 -
    1.73 -article(id, blogid, author)
    1.74 -article_s: Visible = ctime, text	Invisible = parent, path
    1.75 -article_m: image
    1.76 -
    1.77 -article	=	hoge|1433812374x20849|yuuji@gentei.org
    1.78 -article_s =	hoge|ctime|string|2015-06-13 12:27:34|
    1.79 -		hoge|text|string|Shall we dance?|
    1.80 -EOF
    1.81 -  ## 
    1.82 -  ## 
    1.83 -err "select id from $at where blogid='$id';"
    1.84 -#  arts=`sq $db "select a.rowid,a.id,
    1.85 -#-- coalesce(b.gecos, a.author)
    1.86 -# a.author from $at a
    1.87 -# LEFT JOIN (select name,val as gecos from user_s where key='gecos') b
    1.88 -# on a.author=b.name where blogid='$id'";`
    1.89 -  arts=`query "select rowid,id,author from $at where blogid='$id';"`
    1.90 -# err  arts="[$arts]"
    1.91 -  number=0
    1.92 -  hrefhome0="<a href=\"?home"
    1.93 -  for a in $arts; do
    1.94 -    arid=${a%%\|*} aid=`echo "$a"|cut -d'|' -f2` author=${a##*\|} imgs=""
    1.95 -    ## err a=$a, aid=$aid, author=$author
    1.96 -    ## err td=$td
    1.97 -    val=`getvalbyid article image "$arid" "$td"`
    1.98 -    ## err val="[$val]" and td as follows:
    1.99 -    
   1.100 -    if [ -n "$val" ]; then
   1.101 -      hrfb="$myname?showattc+article_m"
   1.102 -      imgs="<br>"$(echo "$val"\
   1.103 -			|while read fn; do
   1.104 -
   1.105 -			   #data=`percenthex $td/$fn`
   1.106 -			   #ct=`cat $td/$fn.content-type`
   1.107 -			   sz=`cat $td/$fn.size`
   1.108 -			   ri=`cat $td/$fn.rowid`
   1.109 -	##  err fn=$fn ct=$ct ri=$ri ls::: "`ls -lF $td/`"
   1.110 -			   iconhref2 $td/$fn "$hrfb+$ri" "$fn" "$fn($sz)"
   1.111 -			   echo "<br>"
   1.112 -			 done)
   1.113 -      imgs=`echo "$imgs"|tr -d '\n'`	# kill newlines for sed
   1.114 -    fi
   1.115 -
   1.116 -    ### number=$((number+1))
   1.117 -#    reply="<input type=\"radio\" name=\"parent\" class=\"replybtn\" \
   1.118 -# value=\"$number\">"
   1.119 -    getgecos="(select rowid from user where name='$author')||':'||\
   1.120 -	coalesce((select val from user_s \
   1.121 -	where name='$author' and key='gecos'), '$author')||',[/a],'"
   1.122 -    href="$myname?editart+$arid+$rowid"
   1.123 -    link="<a href=\"$href\">編集</a>"
   1.124 -    cat<<EOF | sq -html $db \
   1.125 -	| sed -e "s|,n,\([0-9]*\):|,n,$hrefhome0+\1\">|" \
   1.126 -	      -e 's|,\[/a\],|</a>|' \
   1.127 -	      -e 's/,n,/<br>/g' -e "s|,i,|$imgs|" \
   1.128 -	      -e "s|<TR>\(<TD>\)|<TR id=\"$aid\">\1|" \
   1.129 -	      -e "s|^href=\([-A-Za-z0-9,.:/~_%#&+?]*\)|<a &>\1</a>|" \
   1.130 -	      -e "s|\(<TR.*>\)\(<TD>\),e,|\1\2$link|"
   1.131 -select
   1.132 -  coalesce((select ",e," from article where id='$aid' and author='$user'),"")
   1.133 -  ||
   1.134 -  max(case key when 'ctime' then ",n,"||val||
   1.135 -  ",n,"||$getgecos end) as TIME,
   1.136 ---  max(case key when 'parent' then val||"への返信" end) as REPLYTO,
   1.137 -  max(case key when 'text' then val||",i," end) as TEXT
   1.138 -  from article_s where id = '$aid'
   1.139 -  group by id order by TIME;
   1.140 -EOF
   1.141 -  done
   1.142 -  echo "</table>"
   1.143 -
   1.144 -  
   1.145 -  $iswritable && cat<<EOF
   1.146 -<div class="blogcomment">
   1.147 -<p>コメント記入</p>
   1.148 -<input type="hidden" name="blogid" value="$id">
   1.149 -<input type="hidden" name="stage" value="replyblog">
   1.150 -<input type="hidden" name="serial" value="$serial">
   1.151 -$textform
   1.152 -</div>
   1.153 -EOF
   1.154 -  echo "</form><p id=\"bottom\"></p>"
   1.155 -  # Record access log
   1.156 -  acclog blog $rowid
   1.157 -}
   1.158 -
   1.159 -blog_showentry2() {
   1.160 -  # $1=table $2=rowid
   1.161 -  # if [ -n "$2" ]; then
   1.162 -  #   if [ -n "$imgcached" ]; then
   1.163 -  #     bstmpdir=$tmpdir/$imgcached/$thumbxy
   1.164 -  #   else
   1.165 -  #     bstmpdir=$tmpd
   1.166 -  #     # tmpd=`mktempd`
   1.167 -  #     # tmpfiles=$tmpfiles" $tmpd"
   1.168 -  #   fi
   1.169 -  # fi
   1.170 -  td=`getcachedir "article/$2"`
   1.171 -  tbl=${1%%[!A-Z0-9a-z_]*} rowid=${2%%[!A-Z0-9a-z_]*}
   1.172 -err rowid=$rowid, '$2'=$2
   1.173 -  ts=${tbl}_s tm=${tbl}_m
   1.174 -  at=article as=article_s am=article_m
   1.175 -  serial=$(($(date +%s)-1420038000))s$$
   1.176 -  blog_writable $rowid $user && iswritable=true || iswritable=false
   1.177 -  # This function grasps blog entry definiton directly.
   1.178 -  # blog:   id
   1.179 -  # blog_s: title,ctime,heading
   1.180 -  # blog_m: *article
   1.181 -
   1.182 -  # 2015-10-05 check readable
   1.183 -  if ! $iswritable; then
   1.184 -    blogowner=`getvalbyid blog owner "$2"`
   1.185 -    # err blogowner=$blogowner
   1.186 -    if isgroup $blogowner; then
   1.187 -      regmode=`getgroupattr $blogowner regmode`
   1.188 -      # err regmode=$regmode
   1.189 -      if [ x"$regmode" = x"moderated" ]; then
   1.190 -	if ! ismember $user $blogowner; then
   1.191 -	  echo "加入してからどうぞ" | html p
   1.192 -	  return
   1.193 -	fi
   1.194 -      fi
   1.195 -    fi
   1.196 -  fi
   1.197    case `getvalbyid blog notify "$2"` in # "all", "admin" or "no" (or NULL)
   1.198      admin)	notifyto=1 ;;
   1.199      *)		notifyto="" ;;