diff s4-blog.sh @ 78:0cbbb0874eb5

Code cleaning
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 01 Aug 2015 23:00:57 +0900
parents 3dc3ddd2d3e5
children 39e69daa2071
line wrap: on
line diff
--- a/s4-blog.sh	Fri Jul 31 23:53:56 2015 +0900
+++ b/s4-blog.sh	Sat Aug 01 23:00:57 2015 +0900
@@ -144,10 +144,8 @@
   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
-    # name=''	# Get gecos??
-    # td=$(echo $bstmpdir/`echo $at|md5`)
-err td=$td
+    err a=$a, aid=$aid, author=$author
+    err td=$td
     val=`getvalbyid article image "$arid" "$td"`
     err val="[$val]" and td as follows:
     
@@ -293,7 +291,47 @@
   echo
   cat $arc
 }
-
+searchart() {
+  kwd=`getpar kwd`
+  if [ -z "$kwd" ]; then
+    echo "検索語を指定してください" | html p; return
+  fi
+  owner=`getpar owner`
+  owner=${owner:-$1}
+  echo "「$kwd」による検索結果" | html p
+  if [ -n "$owner" ]; then
+    cond="where key='owner' and val='$owner'"
+    if isuser $owner; then
+      echo "(`linkhome $owner` さんの記録からの検索)" | html p
+    else
+      linkhome $owner 1>&3
+      echo "(`linkhome $owner` グループからの検索)" | html p
+    fi
+  fi
+  # article_s:	id=article-id, key='text', val='TEXT'
+  # article:	id=article-id, blogid=blogkd
+  # blog:		id=blog-id, author=LeaderAuthor
+  # blog_s:		id=blog-id, key='title', val='BLOG-TITLE'
+  # WANT: blog-ROWid,article-id,val(TEXT)
+  sql="select b.rowid||'#'||x.id as '',
+		  b.title as TITLE,
+		  substr(x.val, 0, 80) as TEXT
+	from (select blog.rowid,blog.*,bs.val as title from blog join blog_s bs
+		on blog.id=bs.id and bs.key='title') b
+	  join
+	    (select a.id,a.blogid,s.val from article a join article_s s
+		 on a.id=s.id where s.val like '%$kwd%')
+	     x on b.id=x.blogid
+	 where b.id in (select id from blog_s
+	$cond);"
+  sedopt="s,<TR><TD>\([^<]*\)</TD>,<TR><TD><a\
+ href=\"?replyblog+\1\">VIEW</a></TD>,"
+  cat<<EOF
+<table class="b searchart">
+`sq -header -html $db "$sql"|sed "$sedopt"`
+</table>
+EOF
+}
 listblog() (
   # $1={user,group}
   qow=`sqlquote $1`

yatex.org