changeset 352:dd0c70353869

More HELP text for search form. Add search result report.
author HIROSE Yuuji <yuuji@gentei.org>
date Wed, 26 Oct 2016 12:25:05 +0859
parents deb4cc74a415
children 240e695ed574
files examples/common/default/default.css s4-blog.sh s4-funcs.sh
diffstat 3 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/examples/common/default/default.css	Tue Oct 25 23:00:46 2016 +0859
+++ b/examples/common/default/default.css	Wed Oct 26 12:25:05 2016 +0859
@@ -221,6 +221,15 @@
     margin: 1em; padding: 0 0.5ex; padding-left: 18px;
     background: url("../../img/loupe.png") left center no-repeat
 		   rgba(242,240,240,0.7);
+    position: relative;
+}
+div.search div.fr {position: relative;}
+div.search p.help {display: none;}
+div.search input:focus + p.help {
+    display: block; background: white;
+    position: absolute; right: 15em; white-space: pre;
+    border: 1px solid #888; border-radius: 1em; padding: 1ex;
+    box-shadow: #555 2px 2px;
 }
 
 /*
--- a/s4-blog.sh	Tue Oct 25 23:00:46 2016 +0859
+++ b/s4-blog.sh	Wed Oct 26 12:25:05 2016 +0859
@@ -490,6 +490,12 @@
       elif [ x"$k" = x"@week" ]; then
 	ctime=`query "SELECT datetime('now', 'localtime', '-7 days');"`
 	kc=$kc${kc:+" AND "}"ctime > '${ctime}'"
+      elif [ x"$k" = x"@month" ]; then
+	ctime=`query "SELECT datetime('now', 'localtime', '-1 month');"`
+	kc=$kc${kc:+" AND "}"ctime > '${ctime}'"
+      elif [ x"$k" = x"@year" ]; then
+	ctime=`query "SELECT datetime('now', 'localtime', '-1 year');"`
+	kc=$kc${kc:+" AND "}"ctime > '${ctime}'"
       else
 	kc=$kc${kc:+" AND "}"content LIKE '%$k%'"
       fi
@@ -560,11 +566,20 @@
   sedopt="s,<TR><TD>\([^<]*\)</TD>,<TR><TD><a\
  href=\"?replyblog+\1\">VIEW</a></TD>,"
   # echo "$sql2" > tmp/sql.out
+  result=$tmpd/result.$$
   cat<<EOF
 <table class="b searchart">
-`sq -header -html $db "$sql2"|sed "$sedopt"`
+`sq -header -html $db "$sql2"|sed "$sedopt"|tee $result`
 </table>
 EOF
+  if [ -s "$result" ]; then
+    found=`grep "^<TR><TD>" $result | wc -l`
+    found=$((found+0))
+    one=${found%1}
+    echo "$found match${one:+es} found"
+  else
+    echo orz...
+  fi
 }
 listblog() (
   # $1={user,group}
--- a/s4-funcs.sh	Tue Oct 25 23:00:46 2016 +0859
+++ b/s4-funcs.sh	Wed Oct 26 12:25:05 2016 +0859
@@ -38,6 +38,10 @@
 nl="
 "
 iconcachekey="profimgcache_S"
+case "$HTTP_USER_AGENT" in
+  *i[Pp]hone*|*[Aa]ndroid*)	touchpanel=1 ;;
+  *)				touchpanel="" ;;
+esac
 . ./s4-cgi.sh
 
 : <<EOF
@@ -1522,6 +1526,9 @@
 search_form() {
   help="(1)空白区切りの単語で本文検索
 (2)@YYYY-MM-DD 日付け(シェルパターン可)で日付け検索
+   @2016-0[1-6]  → 2016年1月から6月
+   @>2016-01 @<2016-02-15  → 2016年1月から2月14日までの期間
+   @week  → 最近一週間
 (3)#番号 で記事ID検索
 (1)と(2)は組み合わせOK
   例: @2016-10-0[1-9] 芋煮
@@ -1542,6 +1549,7 @@
 	<form action="$myname">$auth
 	<input type="text" name="kwd" value="" title="$help"
 	 placeholder=" $placeholder " width="10" accesskey="k">
+	 ${touchpanel:+<p class="help">$help</p>}
 	<input type="hidden" name="stage" value="searchart">
 	</form>
 	</div>

yatex.org