ref: f377a85907803538f4f475a7d88eb44e601f4ff7
parent: f4e0733bbabdcedd5de6032eea1e17f6ec66a93c
author: sirjofri <sirjofri@sirjofri.de>
date: Sun Feb 21 16:27:24 EST 2021
adds max number of posts
--- a/news2atom
+++ b/news2atom
@@ -20,9 +20,9 @@
rfork e
-flagfmt='d:domain domain, u:self selfurl, n:newspath newspath, t:title title, s:stylesheet stylesheet'
+flagfmt='d:domain domain, u:self selfurl, n:newspath newspath, t:title title, s:stylesheet stylesheet, m:max maxentries'
if(! ifs=() eval `{aux/getflags $*}){
- echo 'usage: news2atom -d domain -u selfurl -t title [ -n newspath ] [ -s stylesheet ]' >[1=2]
+ echo 'usage: news2atom -d domain -u selfurl -t title [ -n newspath ] [ -s stylesheet ] [ -m maxentries ]' >[1=2]
exit usage
}
@@ -29,10 +29,12 @@
~ $#title 0 && { echo missing arg: title; exit usage }
~ $#self 0 && { echo missing arg: selfurl; exit usage }
~ $#newspath 0 && newspath=/lib/news
+~ $#max 0 && max=30
mdate=`{date -ut}
nl='
'
+n=()
echo '<?xml version="1.0" encoding="utf-8"?>'
~ $#stylesheet 0 || echo '<?xml-stylesheet type="text/xsl" href="'$"stylesheet'"?>'
@@ -43,6 +45,11 @@
<link rel="self" href="'$"self'"/>'
for(f in `{ls -t $newspath}){
+ if(~ $#n $max){
+ echo '</feed>'
+ exit
+ }
+ n=($n 1)
fname=`{basename $f}
author=`{ls -l $f}
author=$author(4)