s4

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 diff
     1.1 --- a/examples/common/default/default.css	Mon Aug 14 09:45:35 2017 +0859
     1.2 +++ b/examples/common/default/default.css	Mon Aug 14 12:32:36 2017 +0859
     1.3 @@ -67,6 +67,11 @@
     1.4  input.action[value="rm"]:checked ~ label.confirm {
     1.5      display: inline;
     1.6  }
     1.7 +input.hidesub ~ input[type="submit"] {visibility: hidden;}
     1.8 +input.hidesub:focus ~ input[type="submit"],
     1.9 +p:active input[type="submit"]
    1.10 +{visibility: visible;}
    1.11 +input[type=text]:focus {background: #ffa;}
    1.12  
    1.13  form.replyblog {xxx-margin-bottom: 40%;}
    1.14  div.blogcomment {
     2.1 --- a/s4-blog.sh	Mon Aug 14 09:45:35 2017 +0859
     2.2 +++ b/s4-blog.sh	Mon Aug 14 12:32:36 2017 +0859
     2.3 @@ -945,3 +945,17 @@
     2.4  	    -D_DUMPTABLE_="syscmd(cat)" -D_DUMPHEAD_="" \
     2.5  	    $layout/html.m4.html $layout/form+dump-whead.m4.html
     2.6  }
     2.7 +
     2.8 +blog_reply_article() {		# Direct link to article in some blog
     2.9 +  arid=${1:-0}			# Already sanitized to digits
    2.10 +  brid=`query "SELECT rowid FROM blog WHERE \
    2.11 +	       id=(SELECT blogid FROM article WHERE rowid=$arid);"`
    2.12 +  if [ -n "$brid" ]; then
    2.13 +    newurl="?replyblog+$brid#$arid"
    2.14 +    echo "Refresh: 0; $newurl"; echo
    2.15 +    exit 0
    2.16 +  else
    2.17 +    contenttype; echo
    2.18 +    echo "無効な記事番号です." | html p
    2.19 +  fi
    2.20 +}
     3.1 --- a/s4-funcs.sh	Mon Aug 14 09:45:35 2017 +0859
     3.2 +++ b/s4-funcs.sh	Mon Aug 14 12:32:36 2017 +0859
     3.3 @@ -466,7 +466,8 @@
     3.4    #   {{{URL}}	}	- <iframe src="URL"></iframe>
     3.5    #   {{{URL|height}}	- <iframe src="URL" height="height"></iframe>
     3.6    _hrefptn="[-A-Za-z0-9,.:;/~_%#&+?=@!]*"
     3.7 -  sed -e "s|\[\[\($_hrefptn\)\|\([^]]*\)\]\]|<a href=\"\1\">\2</a>|g" \
     3.8 +  sed -e "s|\[\[\#\([0-9][0-9]*\)\]\]|<a href=\"?aid\1\">#\1</a>|g" \
     3.9 +      -e "s|\[\[\($_hrefptn\)\|\([^]]*\)\]\]|<a href=\"\1\">\2</a>|g" \
    3.10        -e "s|\[\[\($_hrefptn\)\]\]|<a href=\"\1\">\1</a>|" \
    3.11        -e "s|{{{\($_hrefptn\)\|\(.*\)}}}|<iframe src=\"\1\" height=\"\2\"></iframe>|g" \
    3.12        -e "s|{{{\($_hrefptn\)}}}|<iframe src=\"\1\"></iframe>|g" \
     4.1 --- a/s4.cgi	Mon Aug 14 09:45:35 2017 +0859
     4.2 +++ b/s4.cgi	Mon Aug 14 12:32:36 2017 +0859
     4.3 @@ -2,6 +2,7 @@
     4.4  #!/bin/ksh
     4.5  # 愛
     4.6  mydir=`dirname $0`
     4.7 +echo "1=[$1]" >> tmp/debug.out
     4.8  . $mydir/s4-funcs.sh
     4.9  
    4.10  cgiinit
    4.11 @@ -23,7 +24,7 @@
    4.12      ;;
    4.13  esac
    4.14  
    4.15 -# err 1=$1 2=$2 3=$3 4=$4
    4.16 +err "1=$1 2=$2 3=$3 4=$4"
    4.17  stage=`getpar stage`
    4.18  stage=${stage:-$1}
    4.19  case ${stage} in
    4.20 @@ -66,6 +67,13 @@
    4.21  err blog_reply2 $rowid
    4.22      blog_reply $rowid
    4.23      ;;
    4.24 +  aid[1-9]*)
    4.25 +    arid=${1#aid}
    4.26 +    arid=${arid%%[!0-9]*}
    4.27 +    . ./s4-blog.sh
    4.28 +err b_r_a "$arid"
    4.29 +    blog_reply_article "$arid"
    4.30 +    ;;
    4.31    reload*)	# Dirty workaround for reloading page just after submit
    4.32      newurl="$urlbase?replyblog+${stage#*/}#bottom"
    4.33      echo "Refresh: 0; $newurl"; echo