Mercurial > hgrepos > hgweb.cgi > 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(+), 182 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-blog.sh Sat Apr 23 21:10:55 2016 +0859 +++ b/s4-blog.sh Sat Apr 23 22:57:54 2016 +0859 @@ -49,6 +49,7 @@ `echo "$3"|sed 's/^/> /'` EOF ) + blog_showentry() { # $1=table $2=rowid # if [ -n "$2" ]; then @@ -87,188 +88,6 @@ fi fi fi - - err "SELECT id from $tbl where rowid=$rowid" - id=`query "select id from $tbl where rowid=$rowid;"` -err id=$id -err "select val from $ts where key='title' and id='$id';" - - - #(1)Display root article - cat<<EOF -<form class="replyblog" action="$myname?replyblog+${rowid}#bottom" method="POST" enctype="multipart/form-data"> -<table class="bloghead"> -EOF - - href="<a href=\"?editheading+$rowid\"> 編集 </a>" - if $iswritable; then - href2="<a href=\"?lshandout+$rowid\"> 提出状況 </a>" - href3="(<a href=\"?gethandout+$rowid\">ファイル取得</a>)" - fi - cat<<EOF | sq -html $db \ - | sed -e "s|\(<TR><TD>\),e,|\1 $href |" \ - -e "s|,s,\(</TD>\)|$href2$href3\1|" --- select val from $ts where key="title" and id="$id"; -select - coalesce((select ",e," from blog where rowid=$rowid and author='$user'),'') -||val||" " -||case (select val from $ts where key="mode" and id="$id") - when 'report-closed' then "レポート提出用(自身のファイルのみ参照可),s," - when 'report-open' then "レポート提出用,s," - else "" - end - from $ts where key="ctime" and id="$id"; -select val from $ts where key="heading" and id="$id"; -EOF - cat<<EOF -</table> -<table class="blog_replies"> -EOF - - #(2)Display following articles -textform='<div><table class="b"> -<tr><td><textarea name="text" cols="40" rows="4"></textarea></td></tr> -<tr><td>添付ファイル: <input type="file" name="image" multiple></td></tr> -</table> -<input type="submit" value="送信"> -<input type="reset" value="リセット"></div> -' - ## 6/11の次: articleを出して行く -: <<EOF -シリアル:id:p:serial: -blogID:blogid:f:blog(id): -筆者:author:s:owner -時刻:ctime:s:stamp: -参照元:parent:s:parent: -パス:path:s:path: -本文:text:s:textarea:cols="60" rows="8" -画像:image:m:image: -stage:stage:x:hidden:value="replyblog" - -article(id, blogid, author) -article_s: Visible = ctime, text Invisible = parent, path -article_m: image - -article = hoge|1433812374x20849|yuuji@gentei.org -article_s = hoge|ctime|string|2015-06-13 12:27:34| - hoge|text|string|Shall we dance?| -EOF - ## - ## -err "select id from $at where blogid='$id';" -# arts=`sq $db "select a.rowid,a.id, -#-- coalesce(b.gecos, a.author) -# a.author from $at a -# LEFT JOIN (select name,val as gecos from user_s where key='gecos') b -# on a.author=b.name where blogid='$id'";` - arts=`query "select rowid,id,author from $at where blogid='$id';"` -# err arts="[$arts]" - number=0 - hrefhome0="<a href=\"?home" - for a in $arts; do - arid=${a%%\|*} aid=`echo "$a"|cut -d'|' -f2` author=${a##*\|} imgs="" - ## err a=$a, aid=$aid, author=$author - ## err td=$td - val=`getvalbyid article image "$arid" "$td"` - ## err val="[$val]" and td as follows: - - if [ -n "$val" ]; then - hrfb="$myname?showattc+article_m" - imgs="<br>"$(echo "$val"\ - |while read fn; do - - #data=`percenthex $td/$fn` - #ct=`cat $td/$fn.content-type` - sz=`cat $td/$fn.size` - ri=`cat $td/$fn.rowid` - ## err fn=$fn ct=$ct ri=$ri ls::: "`ls -lF $td/`" - iconhref2 $td/$fn "$hrfb+$ri" "$fn" "$fn($sz)" - echo "<br>" - done) - imgs=`echo "$imgs"|tr -d '\n'` # kill newlines for sed - fi - - ### number=$((number+1)) -# reply="<input type=\"radio\" name=\"parent\" class=\"replybtn\" \ -# value=\"$number\">" - getgecos="(select rowid from user where name='$author')||':'||\ - coalesce((select val from user_s \ - where name='$author' and key='gecos'), '$author')||',[/a],'" - href="$myname?editart+$arid+$rowid" - link="<a href=\"$href\">編集</a>" - cat<<EOF | sq -html $db \ - | sed -e "s|,n,\([0-9]*\):|,n,$hrefhome0+\1\">|" \ - -e 's|,\[/a\],|</a>|' \ - -e 's/,n,/<br>/g' -e "s|,i,|$imgs|" \ - -e "s|<TR>\(<TD>\)|<TR id=\"$aid\">\1|" \ - -e "s|^href=\([-A-Za-z0-9,.:/~_%#&+?]*\)|<a &>\1</a>|" \ - -e "s|\(<TR.*>\)\(<TD>\),e,|\1\2$link|" -select - coalesce((select ",e," from article where id='$aid' and author='$user'),"") - || - max(case key when 'ctime' then ",n,"||val|| - ",n,"||$getgecos end) as TIME, --- max(case key when 'parent' then val||"への返信" end) as REPLYTO, - max(case key when 'text' then val||",i," end) as TEXT - from article_s where id = '$aid' - group by id order by TIME; -EOF - done - echo "</table>" - - - $iswritable && cat<<EOF -<div class="blogcomment"> -<p>コメント記入</p> -<input type="hidden" name="blogid" value="$id"> -<input type="hidden" name="stage" value="replyblog"> -<input type="hidden" name="serial" value="$serial"> -$textform -</div> -EOF - echo "</form><p id=\"bottom\"></p>" - # Record access log - acclog blog $rowid -} - -blog_showentry2() { - # $1=table $2=rowid - # if [ -n "$2" ]; then - # if [ -n "$imgcached" ]; then - # bstmpdir=$tmpdir/$imgcached/$thumbxy - # else - # bstmpdir=$tmpd - # # tmpd=`mktempd` - # # tmpfiles=$tmpfiles" $tmpd" - # fi - # fi - td=`getcachedir "article/$2"` - tbl=${1%%[!A-Z0-9a-z_]*} rowid=${2%%[!A-Z0-9a-z_]*} -err rowid=$rowid, '$2'=$2 - ts=${tbl}_s tm=${tbl}_m - at=article as=article_s am=article_m - serial=$(($(date +%s)-1420038000))s$$ - blog_writable $rowid $user && iswritable=true || iswritable=false - # This function grasps blog entry definiton directly. - # blog: id - # blog_s: title,ctime,heading - # blog_m: *article - - # 2015-10-05 check readable - if ! $iswritable; then - blogowner=`getvalbyid blog owner "$2"` - # err blogowner=$blogowner - if isgroup $blogowner; then - regmode=`getgroupattr $blogowner regmode` - # err regmode=$regmode - if [ x"$regmode" = x"moderated" ]; then - if ! ismember $user $blogowner; then - echo "加入してからどうぞ" | html p - return - fi - fi - fi - fi case `getvalbyid blog notify "$2"` in # "all", "admin" or "no" (or NULL) admin) notifyto=1 ;; *) notifyto="" ;;