changeset 451:8965bdad3172

Add convenient link pattern [[#ArticleId]] for direct link to articles.
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 14 Aug 2017 12:32:36 +0859
parents 8023dbe45826
children 30ab12e54324
files examples/common/default/default.css s4-blog.sh s4-funcs.sh s4.cgi
diffstat 4 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/examples/common/default/default.css	Mon Aug 14 09:45:35 2017 +0859
+++ b/examples/common/default/default.css	Mon Aug 14 12:32:36 2017 +0859
@@ -67,6 +67,11 @@
 input.action[value="rm"]:checked ~ label.confirm {
     display: inline;
 }
+input.hidesub ~ input[type="submit"] {visibility: hidden;}
+input.hidesub:focus ~ input[type="submit"],
+p:active input[type="submit"]
+{visibility: visible;}
+input[type=text]:focus {background: #ffa;}
 
 form.replyblog {xxx-margin-bottom: 40%;}
 div.blogcomment {
--- a/s4-blog.sh	Mon Aug 14 09:45:35 2017 +0859
+++ b/s4-blog.sh	Mon Aug 14 12:32:36 2017 +0859
@@ -945,3 +945,17 @@
 	    -D_DUMPTABLE_="syscmd(cat)" -D_DUMPHEAD_="" \
 	    $layout/html.m4.html $layout/form+dump-whead.m4.html
 }
+
+blog_reply_article() {		# Direct link to article in some blog
+  arid=${1:-0}			# Already sanitized to digits
+  brid=`query "SELECT rowid FROM blog WHERE \
+	       id=(SELECT blogid FROM article WHERE rowid=$arid);"`
+  if [ -n "$brid" ]; then
+    newurl="?replyblog+$brid#$arid"
+    echo "Refresh: 0; $newurl"; echo
+    exit 0
+  else
+    contenttype; echo
+    echo "無効な記事番号です." | html p
+  fi
+}
--- a/s4-funcs.sh	Mon Aug 14 09:45:35 2017 +0859
+++ b/s4-funcs.sh	Mon Aug 14 12:32:36 2017 +0859
@@ -466,7 +466,8 @@
   #   {{{URL}}	}	- <iframe src="URL"></iframe>
   #   {{{URL|height}}	- <iframe src="URL" height="height"></iframe>
   _hrefptn="[-A-Za-z0-9,.:;/~_%#&+?=@!]*"
-  sed -e "s|\[\[\($_hrefptn\)\|\([^]]*\)\]\]|<a href=\"\1\">\2</a>|g" \
+  sed -e "s|\[\[\#\([0-9][0-9]*\)\]\]|<a href=\"?aid\1\">#\1</a>|g" \
+      -e "s|\[\[\($_hrefptn\)\|\([^]]*\)\]\]|<a href=\"\1\">\2</a>|g" \
       -e "s|\[\[\($_hrefptn\)\]\]|<a href=\"\1\">\1</a>|" \
       -e "s|{{{\($_hrefptn\)\|\(.*\)}}}|<iframe src=\"\1\" height=\"\2\"></iframe>|g" \
       -e "s|{{{\($_hrefptn\)}}}|<iframe src=\"\1\"></iframe>|g" \
--- a/s4.cgi	Mon Aug 14 09:45:35 2017 +0859
+++ b/s4.cgi	Mon Aug 14 12:32:36 2017 +0859
@@ -2,6 +2,7 @@
 #!/bin/ksh
 # 愛
 mydir=`dirname $0`
+echo "1=[$1]" >> tmp/debug.out
 . $mydir/s4-funcs.sh
 
 cgiinit
@@ -23,7 +24,7 @@
     ;;
 esac
 
-# err 1=$1 2=$2 3=$3 4=$4
+err "1=$1 2=$2 3=$3 4=$4"
 stage=`getpar stage`
 stage=${stage:-$1}
 case ${stage} in
@@ -66,6 +67,13 @@
 err blog_reply2 $rowid
     blog_reply $rowid
     ;;
+  aid[1-9]*)
+    arid=${1#aid}
+    arid=${arid%%[!0-9]*}
+    . ./s4-blog.sh
+err b_r_a "$arid"
+    blog_reply_article "$arid"
+    ;;
   reload*)	# Dirty workaround for reloading page just after submit
     newurl="$urlbase?replyblog+${stage#*/}#bottom"
     echo "Refresh: 0; $newurl"; echo

yatex.org