summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-06-21 00:25:45 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-06-21 00:25:45 +0200
commit7bd3894befb8033ebdc252103fd0d689e655f127 (patch)
tree749e36f19cd200f48d1dd62fb2a1708ed3e904ae
parent7e575e13c0cdcc4341fa2f0b6dcb90cb4bd3cd71 (diff)
improvements
-rw-r--r--sfeed.116
-rw-r--r--sfeed_web.c12
-rw-r--r--sfeedrc.example3
3 files changed, 19 insertions, 12 deletions
diff --git a/sfeed.1 b/sfeed.1
index 0a8db56..77e2682 100644
--- a/sfeed.1
+++ b/sfeed.1
@@ -6,16 +6,15 @@
.Nd simple RSS and Atom parser
.Sh SYNOPSIS
.Nm
-.Op Ar suffix string | Fl Ar v
+.Op Ar baseurl
.Sh DESCRIPTION
.Nm
reads RSS or Atom feed data (XML) from stdin. It writes the feed data in a
-tab-separated format to stdout.
-.Sh OPTIONS
-.Bl -tag -width 17n
-.It Fl v
-show program version
-.El
+tab-separated format to stdout. A
+.Ar baseurl
+can be specified if the links in the feed are relative urls and the baseurl of
+the content differs from the feed. It is generally recommended to always have
+absolute urls in your feeds, but the web sucks.
.Sh TAB-SEPARATED FORMAT FIELDS
The items are saved in a TSV-like format except newlines, tabs and
backslash are escaped with \\ (\\n, \\t and \\\\). Carriage returns (\\r) are
@@ -30,7 +29,7 @@ string, date and time in the format: YYYY-mm-dd HH:MM:SS tzname[[+-][HHMM]]
.It Ar item title
string
.It Ar item link
-string
+string, made to absolute url, unsafe characters are encoded
.It Ar item content
string
.It Ar item content\-type
@@ -43,6 +42,7 @@ string
string, "rss" or "atom"
.El
.Sh SEE ALSO
+.Xr sfeed_plain 1 ,
.Xr sfeed_update 1 ,
.Xr sh 1
.Sh AUTHORS
diff --git a/sfeed_web.c b/sfeed_web.c
index 2824ab6..9a96959 100644
--- a/sfeed_web.c
+++ b/sfeed_web.c
@@ -11,6 +11,15 @@ static unsigned int isbase = 0, islink = 0, isfeedlink = 0, found = 0;
static char feedlink[4096] = "", basehref[4096] = "", feedtype[256] = "";
static void
+printfeedtype(const char *s, FILE *fp)
+{
+ for(; *s; s++) {
+ if(!isspace((int)*s))
+ fputc(*s, fp);
+ }
+}
+
+static void
xmltagstart(XMLParser *p, const char *tag, size_t taglen)
{
(void)p;
@@ -34,7 +43,7 @@ xmltagstartparsed(XMLParser *p, const char *tag, size_t taglen, int isshort)
if(isfeedlink) {
if(*feedtype) {
- printfeednameid(feedtype, stdout);
+ printfeedtype(feedtype, stdout);
putchar(' ');
}
printlink(feedlink, basehref, stdout);
@@ -75,7 +84,6 @@ main(int argc, char *argv[])
{
XMLParser parser;
- /* base href */
if(argc > 1)
strlcpy(basehref, argv[1], sizeof(basehref));
diff --git a/sfeedrc.example b/sfeedrc.example
index 32272f3..f56b3be 100644
--- a/sfeedrc.example
+++ b/sfeedrc.example
@@ -1,8 +1,7 @@
# paths
# NOTE: make sure to uncomment all these if you change it.
#sfeedpath="$HOME/.sfeed"
-#sfeedfile="$sfeedpath/feeds"
-#sfeedfilenew="$sfeedfile.new"
+#sfeeddir="${sfeedpath}/feeds"
# list of feeds to fetch:
feeds() {