Activity threshold and http status messages
This commit is contained in:
parent
c71a974928
commit
5d7bd64342
@ -1,6 +1,4 @@
|
|||||||
# Planet configuration file
|
# Planet configuration file
|
||||||
#
|
|
||||||
# This illustrates some of Planet's fancier features with example.
|
|
||||||
|
|
||||||
# Every planet needs a [Planet] section
|
# Every planet needs a [Planet] section
|
||||||
[Planet]
|
[Planet]
|
||||||
@ -26,13 +24,18 @@ output_theme = mobile
|
|||||||
output_dir = /home/rubys/public_html/top100
|
output_dir = /home/rubys/public_html/top100
|
||||||
items_per_page = 60
|
items_per_page = 60
|
||||||
|
|
||||||
|
# If non-zero, all feeds which have not been updated in the indicated
|
||||||
|
# number of days will be marked as inactive
|
||||||
activity_threshold = 90
|
activity_threshold = 90
|
||||||
|
|
||||||
|
# filters to be run
|
||||||
filters = excerpt.py
|
filters = excerpt.py
|
||||||
|
|
||||||
|
# filter parameters
|
||||||
[excerpt.py]
|
[excerpt.py]
|
||||||
omit = img p br
|
omit = img p br
|
||||||
width = 500
|
width = 500
|
||||||
|
|
||||||
|
# subscription list
|
||||||
[http://share.opml.org/opml/top100.opml]
|
[http://share.opml.org/opml/top100.opml]
|
||||||
content_type = opml
|
content_type = opml
|
||||||
|
@ -107,6 +107,7 @@ def __init__():
|
|||||||
# template options
|
# template options
|
||||||
define_tmpl_int('days_per_page', 0)
|
define_tmpl_int('days_per_page', 0)
|
||||||
define_tmpl_int('items_per_page', 60)
|
define_tmpl_int('items_per_page', 60)
|
||||||
|
define_tmpl_int('activity_threshold', 0)
|
||||||
define_tmpl('encoding', 'utf-8')
|
define_tmpl('encoding', 'utf-8')
|
||||||
define_tmpl('content_type', 'utf-8')
|
define_tmpl('content_type', 'utf-8')
|
||||||
|
|
||||||
|
@ -110,6 +110,32 @@ def spiderFeed(feed):
|
|||||||
for name, value in config.feed_options(feed).items():
|
for name, value in config.feed_options(feed).items():
|
||||||
data.feed['planet_'+name] = value
|
data.feed['planet_'+name] = value
|
||||||
|
|
||||||
|
# identify inactive feeds
|
||||||
|
if config.activity_threshold(feed):
|
||||||
|
activity_horizon = \
|
||||||
|
time.gmtime(time.time()-86400*config.activity_threshold(feed))
|
||||||
|
updated = [entry.updated_parsed for entry in data.entries
|
||||||
|
if entry.has_key('updated_parsed')]
|
||||||
|
updated.sort()
|
||||||
|
if not updated or updated[-1] < activity_horizon:
|
||||||
|
msg = "no activity in %d days" % config.activity_threshold(feed)
|
||||||
|
log.info(msg)
|
||||||
|
data.feed['planet_message'] = msg
|
||||||
|
|
||||||
|
# report channel level errors
|
||||||
|
if data.status == 403:
|
||||||
|
data.feed['planet_message'] = "403: forbidden"
|
||||||
|
elif data.status == 404:
|
||||||
|
data.feed['planet_message'] = "404: not found"
|
||||||
|
elif data.status == 408:
|
||||||
|
data.feed['planet_message'] = "408: request timeout"
|
||||||
|
elif data.status == 410:
|
||||||
|
data.feed['planet_message'] = "410: gone"
|
||||||
|
elif data.status == 500:
|
||||||
|
data.feed['planet_message'] = "internal server error"
|
||||||
|
elif data.status >= 400:
|
||||||
|
data.feed['planet_message'] = "http status %s" % status
|
||||||
|
|
||||||
# write the feed info to the cache
|
# write the feed info to the cache
|
||||||
if not os.path.exists(sources): os.makedirs(sources)
|
if not os.path.exists(sources): os.makedirs(sources)
|
||||||
xdoc=minidom.parseString('''<feed xmlns:planet="%s"
|
xdoc=minidom.parseString('''<feed xmlns:planet="%s"
|
||||||
|
16
tests/data/filter/tmpl/source_planet_message.xml
Normal file
16
tests/data/filter/tmpl/source_planet_message.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!--
|
||||||
|
Description: message
|
||||||
|
Expect: Channels[0]['message'] == 'foo' and Items[0]['channel_message'] == 'foo'
|
||||||
|
-->
|
||||||
|
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
|
<entry>
|
||||||
|
<source>
|
||||||
|
<planet:message>foo</planet:message>
|
||||||
|
</source>
|
||||||
|
</entry>
|
||||||
|
<planet:source xmlns:planet='http://planet.intertwingly.net/'>
|
||||||
|
<planet:message>foo</planet:message>
|
||||||
|
</planet:source>
|
||||||
|
</feed>
|
||||||
|
|
@ -41,6 +41,19 @@
|
|||||||
<img src="images/feed-icon-10x10.png" alt="(feed)"/>
|
<img src="images/feed-icon-10x10.png" alt="(feed)"/>
|
||||||
</a>
|
</a>
|
||||||
<a href="{atom:link[@rel='alternate']/@href}">
|
<a href="{atom:link[@rel='alternate']/@href}">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="planet:message">
|
||||||
|
<xsl:attribute name="class">message</xsl:attribute>
|
||||||
|
<xsl:attribute name="title">
|
||||||
|
<xsl:value-of select="planet:message"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:when test="atom:title">
|
||||||
|
<xsl:attribute name="title">
|
||||||
|
<xsl:value-of select="atom:title"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
<xsl:value-of select="planet:name"/>
|
<xsl:value-of select="planet:name"/>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user