diff --git a/docs/config.html b/docs/config.html index 0a4af83..0e5d00c 100644 --- a/docs/config.html +++ b/docs/config.html @@ -126,6 +126,9 @@ hub when feeds are published, speeding delivery of updates to subscribers. See the PubSubHubbub home page for more information. +
atom.xml rss10.xml
+rss20.xml
.Additional options can be found in normalization level overrides.
diff --git a/planet/config.py b/planet/config.py index 1ee50fc..176ee9d 100644 --- a/planet/config.py +++ b/planet/config.py @@ -106,6 +106,7 @@ def __init__(): define_planet('output_dir', 'output') define_planet('spider_threads', 0) define_planet('pubsubhubbub_hub', '') + define_planet_list('pubsubhubbub_feeds', 'atom.xml rss10.xml rss20.xml') define_planet_int('new_feed_items', 0) define_planet_int('feed_timeout', 20) diff --git a/planet/publish.py b/planet/publish.py index e7dde32..36df866 100644 --- a/planet/publish.py +++ b/planet/publish.py @@ -1,15 +1,26 @@ import os, sys import urlparse +import planet import pubsubhubbub_publisher as PuSH def publish(config): + log = planet.logger hub = config.pubsubhubbub_hub() link = config.link() + + # identify feeds + feeds = [] if hub and link: for root, dirs, files in os.walk(config.output_dir()): - xmlfiles = [urlparse.urljoin(link, f) for f in files if f in ['atom.xml', 'rss10.xml', 'rss20.xml']] - try: - PuSH.publish(hub, xmlfiles) - except PuSH.PublishError, e: - sys.stderr.write("PubSubHubbub publishing error: %s\n" % e) - break + for file in files: + if file in config.pubsubhubbub_feeds(): + feeds.append(urlparse.urljoin(link, file)) + + # publish feeds + if feeds: + try: + PuSH.publish(hub, feeds) + for feed in feeds: + log.info("Published %s to %s\n" % (feed, hub)) + except PuSH.PublishError, e: + log.error("PubSubHubbub publishing error: %s\n" % e) diff --git a/publish.py b/publish.py new file mode 100755 index 0000000..fbbfd07 --- /dev/null +++ b/publish.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +""" +Main program to run just the splice portion of planet +""" + +import os.path +import sys +from planet import publish, config + +if __name__ == '__main__': + + if len(sys.argv) == 2 and os.path.isfile(sys.argv[1]): + config.load(sys.argv[1]) + publish.publish(config) + else: + print "Usage:" + print " python %s config.ini" % sys.argv[0]