summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.c2
-rw-r--r--sfeed_html.c5
-rw-r--r--sfeed_plain.c5
-rwxr-xr-xsfeed_update8
-rw-r--r--sfeed_update.13
-rw-r--r--sfeedrc.example10
6 files changed, 21 insertions, 12 deletions
diff --git a/common.c b/common.c
index 91ac9ca..552e9af 100644
--- a/common.c
+++ b/common.c
@@ -6,7 +6,7 @@
enum { FieldUnixTimestamp = 0, FieldTimeFormatted, FieldTitle, FieldLink,
FieldContent, FieldContentType, FieldId, FieldAuthor, FieldFeedType,
- FieldFeedName, FieldFeedUrl, FieldLast };
+ FieldFeedName, FieldFeedUrl, FieldBaseSiteUrl, FieldLast };
const int FieldSeparator = '\t';
diff --git a/sfeed_html.c b/sfeed_html.c
index c195c86..532a0d0 100644
--- a/sfeed_html.c
+++ b/sfeed_html.c
@@ -183,7 +183,10 @@ main(void) {
fputs("<b><u>", stdout);
if(islink) {
fputs("<a href=\"", stdout);
- printlink(fields[FieldLink], fields[FieldFeedUrl]);
+ if(fields[FieldBaseSiteUrl][0] != '\0')
+ printlink(fields[FieldLink], fields[FieldBaseSiteUrl]);
+ else
+ printlink(fields[FieldLink], fields[FieldFeedUrl]);
fputs("\">", stdout);
}
printhtmlencoded(fields[FieldTitle]);
diff --git a/sfeed_plain.c b/sfeed_plain.c
index d4045c9..8eebd10 100644
--- a/sfeed_plain.c
+++ b/sfeed_plain.c
@@ -34,7 +34,10 @@ main(void) {
fputs(" ", stdout);
printutf8padded(fields[FieldTitle], 70);
fputs(" ", stdout);
- printlink(fields[FieldLink], fields[FieldFeedUrl]);
+ if(fields[FieldBaseSiteUrl][0] != '\0')
+ printlink(fields[FieldLink], fields[FieldBaseSiteUrl]);
+ else
+ printlink(fields[FieldLink], fields[FieldFeedUrl]);
putchar('\n');
}
free(line);
diff --git a/sfeed_update b/sfeed_update
index 52b9728..de47ed9 100755
--- a/sfeed_update
+++ b/sfeed_update
@@ -65,15 +65,15 @@ addfield() {
}
# fetch and parse feed.
-# feed(name, url, encoding)
+# feed(name, feedurl, basesiteurl, [encoding])
feed() {
tmpfile=$(mktemp -p "$TMPDIR")
- (if [ "$3" = "" ]; then
+ (if [ "$4" = "" ]; then
# don't use iconv if encoding not set in config.
- fetchfeed "$2" "$1" | sfeed | addfield "$1 $2"
+ fetchfeed "$2" "$1" | sfeed | addfield "$1 $2 $3"
else
# use iconv to convert encoding to UTF-8.
- fetchfeed "$2" "$1" | iconv -cs -f "$3" -t "utf-8" | sfeed | addfield "$1 $2"
+ fetchfeed "$2" "$1" | iconv -cs -f "$4" -t "utf-8" | sfeed | addfield "$1 $2 $3"
fi) > "$tmpfile"
}
diff --git a/sfeed_update.1 b/sfeed_update.1
index e9cffc1..9af753f 100644
--- a/sfeed_update.1
+++ b/sfeed_update.1
@@ -48,6 +48,9 @@ string (extra field added by sfeed_update)
.TP
.B feed url
string (extra field added by sfeed_update)
+.TP
+.B item baseurl site
+string (extra field added by sfeed_update)
.SH FILES READ
.TP
.B sfeedrc
diff --git a/sfeedrc.example b/sfeedrc.example
index d25777a..2ad860a 100644
--- a/sfeedrc.example
+++ b/sfeedrc.example
@@ -6,12 +6,12 @@
# list of feeds to fetch:
feeds() {
- # feed <name> <url> [encoding]
+ # feed <name> <feedurl> <basesiteurl> [encoding]
feed "codemadness" "http://www.codemadness.nl/blog/rss.xml"
feed "explosm" "http://feeds.feedburner.com/Explosm"
- feed "linux kernel" "http://kernel.org/kdist/rss.xml" "iso-8859-1"
+ feed "linux kernel" "http://kernel.org/kdist/rss.xml" "http://kernel.org" "iso-8859-1"
feed "phoronix" "http://feeds.feedburner.com/Phoronix"
- feed "slashdot" "http://rss.slashdot.org/Slashdot/slashdot"
- feed "tweakers" "http://feeds.feedburner.com/tweakers/mixed" "iso-8859-1"
- feed "xkcd" "http://xkcd.com/atom.xml"
+ feed "slashdot" "http://rss.slashdot.org/Slashdot/slashdot" "http://slashdot.org"
+ feed "tweakers" "http://feeds.feedburner.com/tweakers/mixed" "http://tweakers.net" "iso-8859-1"
+ feed "xkcd" "http://xkcd.com/atom.xml" "http://xkcd.com"
}