Content server: Add favicon to OPDS feeds. Fixes #934731 ([Enhancement] Provide a catalog icon in OPDS feed)

This commit is contained in:
Kovid Goyal 2012-02-18 11:23:25 +05:30
parent 5659bbf406
commit 60c97aec90
2 changed files with 11 additions and 0 deletions

View File

@ -44,6 +44,8 @@ class ContentServer(object):
conditions=dict(method=["GET", "HEAD"]))
connect('static', '/static/{name:.*?}', self.static,
conditions=dict(method=["GET", "HEAD"]))
connect('favicon', '/favicon.png', self.favicon,
conditions=dict(method=["GET", "HEAD"]))
# Utility methods {{{
def last_modified(self, updated):
@ -127,6 +129,13 @@ class ContentServer(object):
ans = ans.replace('/static/', self.opts.url_prefix + '/static/')
return ans
def favicon(self):
data = I('lt.png', data=True)
cherrypy.response.headers['Content-Type'] = 'image/png'
cherrypy.response.headers['Last-Modified'] = self.last_modified(
self.build_time)
return data
def index(self, **kwargs):
'The / URL'
ua = cherrypy.request.headers.get('User-Agent', '').strip()

View File

@ -55,6 +55,7 @@ E = ElementMaker(namespace='http://www.w3.org/2005/Atom',
FEED = E.feed
TITLE = E.title
ID = E.id
ICON = E.icon
def UPDATED(dt, *args, **kwargs):
return E.updated(dt.strftime('%Y-%m-%dT%H:%M:%S+00:00'), *args, **kwargs)
@ -239,6 +240,7 @@ class Feed(object): # {{{
TITLE(title),
AUTHOR(__appname__, uri='http://calibre-ebook.com'),
ID(id_),
ICON('/favicon.png'),
UPDATED(updated),
SEARCH_LINK(self.base_href),
START_LINK(href=self.base_href)