# HG changeset patch # User HIROSE Yuuji # Date 1592131928 -32400 # Node ID f5f3f932339b5fc74a1dde98c3d06c9f34444297 # Parent f84cf537b5fb355cc8bdad443c89e43f2ac5ede7 Always showing article No.1 diff -r f84cf537b5fb -r f5f3f932339b s4-blog.sh --- a/s4-blog.sh Sun Jun 14 16:37:47 2020 +0900 +++ b/s4-blog.sh Sun Jun 14 19:52:08 2020 +0900 @@ -391,22 +391,29 @@ return fi echo '' + # If, nLimit = 50 + # show article:1, hide(2, 3), show(4, ...) + # Therefore hide 2 or more article when narts>53 narts=`wc -l < $midfile` - if [ -n "$nlimit" -a "$narts" -gt "$nlimit" ]; then + if [ -n "$nlimit" -a "$narts" -gt "$((nlimit+2))" ]; then newtop=`cat -n $midfile | grep "|new|" | head -1 | cut -f1` if [ -n "$newtop" ]; then afternew=$((narts-newtop+1)) - [ $afternew -gt $nlimit ] && nlimit=$((afternew+0)) + [ $afternew -gt $((nlimit+2)) ] && nlimit=$((afternew+0)) err Newtop=$newtop lines=$narts afternew=$afternew nlim=$nilmit fi fi - if [ $nlimit -lt $narts ]; then - CAT="tail -n $nlimit" + if [ $nlimit -lt $((narts-2)) ]; then + n=0 + omitline=$td/omitline + #CAT="tail -n $nlimit" + CAT=cat limitedmsg="※最新${nlimit}件のみの表示※" showalllink="全件表示" - cat<<-EOF - - + cat<<-EOF > $omitline + + + EOF else CAT=cat @@ -416,6 +423,17 @@ while IFS='|' read id edit notify uid author uname icon aid \ tm reki new hte fa imgids do + if [ -n "$omitline" ]; then + n=$((n+1)) + if [ $n -eq 1 ]; then + : + elif [ $n -eq 2 ]; then + cat $omitline + continue + elif [ $n -lt $((narts-nlimit+1)) ]; then + continue + fi + fi mf2=$tmpd/midfile2 cachefile="$td/$id.row.html" stampfile="$td/$id.row.stamp"
$limitedmsg
($((narts-$nlimit))件省略)
$showalllink
:
$limitedmsg
($((narts-$nlimit-1))件省略)
:
$showalllink