tinycm rev 120

Better blog archive, fix rss feed
author Christophe Lincoln <pankso@slitaz.org>
date Fri Mar 24 23:59:43 2017 +0100 (2017-03-24)
parents 05ccbdd25ab5
children 0893f1ab023c
files plugins/blog/blog.cgi
line diff
     1.1 --- a/plugins/blog/blog.cgi	Mon Mar 20 00:52:01 2017 +0100
     1.2 +++ b/plugins/blog/blog.cgi	Fri Mar 24 23:59:43 2017 +0100
     1.3 @@ -76,14 +76,14 @@
     1.4  	p="$1"
     1.5  	. ${blog}/${p}/post.conf
     1.6  	d="$TITLE"
     1.7 -	
     1.8 +
     1.9  	# Author info
    1.10  	if [ -f "${PEOPLE}/${AUTHOR}/account.conf" ]; then
    1.11  		. ${PEOPLE}/${AUTHOR}/account.conf
    1.12  	else
    1.13  		echo "ERROR: ${PEOPLE}/${AUTHOR}/account.conf"
    1.14  	fi
    1.15 -	
    1.16 +
    1.17  	echo "<h2>$TITLE</h2>"
    1.18  	echo "<div class='blogpost'>"
    1.19  	cat ${blog}/${p}/post.txt | wiki_parser
    1.20 @@ -110,6 +110,11 @@
    1.21  	done
    1.22  }
    1.23  
    1.24 +# RSS feed requested
    1.25 +if [ "$(GET blog)" == "rss" ]; then
    1.26 +	rss && exit 0
    1.27 +fi
    1.28 +
    1.29  #
    1.30  # Index main page can display the latest Blog posts
    1.31  #
    1.32 @@ -153,7 +158,7 @@
    1.33  			DATE=$(date '+%Y-%m-%d')
    1.34  		else
    1.35  			. ${blog}/${p}/post.conf
    1.36 -		fi		
    1.37 +		fi
    1.38  		cat << EOT
    1.39  <h2>$(gettext "Blog post"): $p</h2>
    1.40  
    1.41 @@ -165,12 +170,12 @@
    1.42  		<textarea name="content">$(cat "$blog/$p/post.txt")</textarea>
    1.43  		<div>
    1.44  			<input type="submit" value="$(gettext "Post content")" />
    1.45 -			<input style="width: 20%;" type="text" 
    1.46 +			<input style="width: 20%;" type="text"
    1.47  				name="author" value="$AUTHOR" />
    1.48  			<input style="width: 20%; display: inline;" type="text"
    1.49  				name="date" value="$DATE" />
    1.50  		</div>
    1.51 -		
    1.52 +
    1.53  		<p>
    1.54  		$(gettext "Code Helper:")
    1.55  		$(cat lib/jseditor.html)
    1.56 @@ -203,13 +208,13 @@
    1.57  		fi
    1.58  		[ -f "${blog}/${p}/post.xml" ] || gen_rss
    1.59  		header "Location: $script?blog&p=$p" ;;
    1.60 -	
    1.61 +
    1.62  	*\ rm\ *)
    1.63  		if check_auth && admin_user; then
    1.64  			rm -rf ${blog}/"$(GET p)"
    1.65  		fi
    1.66  		header "Location: $script?blog" ;;
    1.67 -	
    1.68 +
    1.69  	*\ archives\ *)
    1.70  		# List all posts with title only
    1.71  		d="Blog archives"
    1.72 @@ -217,41 +222,52 @@
    1.73  		html_header
    1.74  		user_box
    1.75  		blog_tools
    1.76 -		echo "<h2>Blog archives</h2>"
    1.77 -		echo "<pre>"
    1.78 +		cat << EOT
    1.79 +<h2>Blog archives</h2>
    1.80 +<div id="plugins">
    1.81 +<table>
    1.82 +	<thead>
    1.83 +		<td>$(gettext "Date")</td>
    1.84 +		<td>$(gettext "Title")</td>
    1.85 +	</thead>
    1.86 +EOT
    1.87  		for p in $(ls $blog | sort -nr)
    1.88  		do
    1.89  			. ${blog}/${p}/post.conf
    1.90 -			echo "\
    1.91 -<span class='date'>$DATE :</span> <a href='$script?blog&amp;p=$p'>$TITLE</a>"
    1.92 -		done 
    1.93 -		echo "</pre>" 
    1.94 +			cat << EOT
    1.95 +	<tr>
    1.96 +		<td>$DATE</td>
    1.97 +		<td><a href='$script?blog&amp;p=$p'>$TITLE</a></td>
    1.98 +	</tr>
    1.99 +EOT
   1.100 +		done
   1.101 +		echo "</table></div>"
   1.102  		html_footer && exit 0 ;;
   1.103 -		
   1.104 +
   1.105  	*\ blog\ *)
   1.106 -		if [ "$(GET blog)" == "rss" ]; then
   1.107 -			rss && exit 0
   1.108 -		fi
   1.109  		d="Blog posts"
   1.110  		count="10"
   1.111  		header
   1.112  		html_header
   1.113  		user_box
   1.114  		blog_tools
   1.115 +
   1.116  		# Exit if plugin is disabled
   1.117  		if [ ! -d "$blog" ]; then
   1.118  			echo "<p class='error box'>"
   1.119  			gettext "Blog plugin is not yet active."; echo "</p>"
   1.120  			html_footer && exit 0
   1.121  		fi
   1.122 +
   1.123  		# Single post
   1.124  		if [ "$(GET p)" ]; then
   1.125  			show_post "$(GET p)"
   1.126  		else
   1.127  			show_posts ${count}
   1.128  			echo "<p><a href='$script?blog=archives'>$(gettext "Blog archives")</a></p>"
   1.129 -		fi 
   1.130 +		fi
   1.131 +
   1.132  		html_footer && exit 0 ;;
   1.133  esac
   1.134 -	
   1.135  
   1.136 +