changeset 291:1df64f0490ca

`|col|col|...' like table conversion enabled
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 23 Aug 2016 09:14:42 +0859
parents 8a1012410035
children 3866eb7c2a23
files examples/common/default/default.css s4-blog.sh s4-funcs.sh
diffstat 3 files changed, 55 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/examples/common/default/default.css	Mon Aug 22 16:05:58 2016 +0859
+++ b/examples/common/default/default.css	Tue Aug 23 09:14:42 2016 +0859
@@ -80,7 +80,7 @@
     white-space: pre-wrap;
 }
 table.blog_replies+p.update_link {margin-top: 0; margin-bottom: 14em;}
-.blog_replies td:nth-child(2) {
+.blog_replies td.repl {
     vertical-align: top; min-width: 30em; height: 3em;
     max-width: 50em;
 }
@@ -91,6 +91,15 @@
 .blog_replies td.new {	/* New Article from last visit */
     background: white
 }
+table.mini, table.mini tr, table.mini th, table.mini td {
+    margin: 0; border-width: 0;
+    border-collapse: collapse;
+    vertical-align: top; width: auto; height: 1em;
+}
+table.mini th {text-align: justify;}
+table.mini td, table.mini th {padding: 1px 1ex;}
+table.mini {margin-left: 1em; border-left: 2px solid #686;}
+
 p.profimg {float: left; max-width: 400px; max-height: 400px;
 	   overflow: hidden; margin-right: 1em;
 	   padding: 0; border: white 1px solid; box-shadow: 2px 3px 4px
--- a/s4-blog.sh	Mon Aug 22 16:05:58 2016 +0859
+++ b/s4-blog.sh	Tue Aug 23 09:14:42 2016 +0859
@@ -68,6 +68,7 @@
   #   fi
   # fi
   td=`getcachedir "article/$2"`
+  [ -d "$td" ] || mkdir -p $td
   tbl=${1%%[!A-Z0-9a-z_]*} rowid=${2%%[!A-Z0-9a-z_]*}
 err rowid=$rowid, '$2'=$2
   ts=${tbl}_s tm=${tbl}_m
@@ -184,14 +185,15 @@
   while IFS='|' read id edit notify uid uname aid tm new hte imgids; do
     nt="<label style=\"font-size: 70%;\"><input type=\"checkbox\"
 	 name=\"notifyto\" value=\"$uid\">返信通知送信</label>"
-    cat<<EOF |
+    cat<<EOF
 <tr id="$id">
 <td${new:+ class="new"}>${edit:+<a href="$elink+$edit">編集</a> }#$aid
 <a href="$hlink+$uid">$uname</a>
 $tm
-${notify:+$nt}</td><td id="$aid">`echo "$hte"|unhexize|htmlescape`
+${notify:+$nt}</td>
 EOF
-    hreflink
+    echo -n "<td id=\"$aid\" class=\"repl\">"
+    echo "$hte"|unhexize|htmlescape|hreflink|minitbl
     usecache='' tsfile=$td/$id.stamp
     for i in $imgids; do
       mrid=${i%%:*}; i=${i#*:}; sz=`size_h ${i%%:*}`
@@ -231,7 +233,7 @@
 		| sed -e 's/\(..\)/%\1/g' \
 	    	      -e "s|^|<a href=\"$catlink+$mrid\"><img src=\"data:image/$fmt,|" \
 		      -e "s|\$|\">$fnb</a>|"
-	    [ -d $td ] || mkdir -p "$td"
+	    # [ -d $td ] || mkdir -p "$td"
 	    echo $tm > $tsfile
 	  fi
 	  ;;
--- a/s4-funcs.sh	Mon Aug 22 16:05:58 2016 +0859
+++ b/s4-funcs.sh	Tue Aug 23 09:14:42 2016 +0859
@@ -457,6 +457,30 @@
       -e "s|^href=\($_hrefptn\)|<a &>\1</a>|" \
       -e "s|^iframe=\($_hrefptn\)|<iframe src=\"\1\"></iframe>|"
 }
+minitbl() {
+  sed -n '
+	/^|[^|]/ {;			# If the line begin with "|"
+	 s,|$,,;				# Remove trailing "|" first
+	 s,|\* *\([^|]*\) *,<th>\1</th>,g;	# "|*..." to "<th>...</th>"
+	 s,| *\([^|]*\) *,<td>\1</td>,g;	# "|..."  to "<td>...</td>"
+	 s,^,<tr>,; s,$,</tr>,;		# Enclose with "<tr>" and "</tr>"
+	 H;				# Concat this line to HoldSpace
+	 s/.*//;			# Delete PatternSpace for finalization
+	 $ b cont
+	 d;	# If in final line, output the rest, else jump to next turn
+	}
+	:cont
+	x;				# For non-"|" lines, check HoldSpace
+	/^./ {;				# If HoldSpace has "|" table elements
+	  s|^|<table class="mini">|;	# Enclose whole elements like this:
+	  # s|$|</table>|;		# <table class="mini">..\n..</table>
+	  p;				# Print whole "table" element
+	  s/.*//;			# Erase all when done.
+	  x; s|^|</table>|; x;		# Preppend /table to the next line
+	}
+	x;				# Back to the newest line
+	p;				# Print rest'
+}
 acclog() (
   # $1=table, $2=rowid
   n=${2%%[!0-9]*}	# Remove non-digit chars from $2(should be rowid)
@@ -2094,32 +2118,27 @@
 	 ORDER by a.gecos;"
   err grpaction: `echo "$sql"`
   tf=$tmpd/title.$$
-  echo "グループ[<a href=\"?grp+$grid\">$grp<a>]参加メンバーに対する操作" > $tf
-  cmmsg="<div class=\"fold\">
-`cgi_radio rm commission id=\"cmadmin\"`<label
- for=\"cmadmin\">下でチェックした人にグループ管理者委任</label>
+  echo "グループ[<a href=\"?grp+$grid\">$grp</a>]参加メンバーに対する操作" > $tf
+  cmmsg="`cgi_radio rm commission id=\"cmadmin\"`<label
+ for=\"cmadmin\">グループ管理者委任</label>
 <div><p>このグループでの全権を付与します。信頼できる人に託してください。
-</p></div></div>"
-  excmsg="<div class=\"fold\">
-`cgi_radio rm yes `下でチェックした人のグループ登録解除
-<div>
-本当に消します! `cgi_checkbox confirm yes` 確認
+</p></div>"
+  excmsg="`cgi_radio rm yes id=\"conf\"`<label
+ for=\"conf\">グループ登録解除</label>
+<div>本当に消します! `cgi_checkbox confirm yes` 確認
 <p>この操作による通知は本人に行きません。
 あらかじめ通知するか、登録解除してよい状況かしっかり確認してください。</p>
-</div>
 </div>"
   # Get team list to which current user belongs into $hexteams
   myhexteams=$(hexteams "$grp" "$user")
   allhexteams=$(hexteams "$grp")
   if [ -n "$myhexteams" ]; then
-    rmteammsg="<div class=\"fold\">
-`cgi_radio rm rmteam 'id=\"cmrmteam\"'`<label
+    rmteammsg="`cgi_radio rm rmteam 'id=\"cmrmteam\"'`<label
 for=\"cmrmteam\">下でチェックした人からチーム属性を除去する</label>
 <div>チーム属性:`cgi_select_h rmteam \"2d2d2d\" $myhexteams`
 を除去します: `cgi_checkbox teamconfirm yes` 確認
 <p>この操作による通知は本人に行きません。
 あらかじめ通知するか、登録解除してよい状況かしっかり確認してください。</p>
-</div>
 </div><!-- end of $rmteammsg -->
 "
   fi
@@ -2136,21 +2155,22 @@
 	      -D_SUBTITLE_="チェック後操作ボタン" \
 	      -D_FORM_="syscmd(cat)" -D_DUMPTABLE_="" \
 	      $layout/form+dump.m4.html
-<div class="fold">
+<p>下でチェックした人を対象として:</p>
+<div class="foldtabs">
 `cgi_radio rm addteam 'id="cmteam"'`<label
-for="cmteam">下でチェックした人に同じチーム属性を与える</label>
+for="cmteam">同じチーム属性を付与</label>
 <div>チーム名:`cgi_text team "" 'id="inteam" list="teams"'`
 `cgi_datalist_h teams $allhexteams`
-</div></div>
+</div>
 ${rmteammsg}
-<div class="fold">
 `cgi_radio rm send id="sendmsg"`<label
- for="sendmsg">下でチェックした人にメッセージを送信する</label>
+ for="sendmsg">メッセージ送信</label>
 <div>
 `cgi_textarea text "" cols=40`
 </div>
+${isowner:+$cmmsg$excmsg}
+`cgi_radio rm close id="x"`<label for="x">×</label>
 </div>
-${isowner:+$cmmsg$excmsg}
 <h4>$grp 参加者一覧</h4>
 <table class="td2r">
 `sq $db -header -html "$sql"`

yatex.org