mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: Add favicon to OPDS feeds. Fixes #934731 ([Enhancement] Provide a catalog icon in OPDS feed)
This commit is contained in:
parent
5659bbf406
commit
60c97aec90
@ -44,6 +44,8 @@ class ContentServer(object):
|
|||||||
conditions=dict(method=["GET", "HEAD"]))
|
conditions=dict(method=["GET", "HEAD"]))
|
||||||
connect('static', '/static/{name:.*?}', self.static,
|
connect('static', '/static/{name:.*?}', self.static,
|
||||||
conditions=dict(method=["GET", "HEAD"]))
|
conditions=dict(method=["GET", "HEAD"]))
|
||||||
|
connect('favicon', '/favicon.png', self.favicon,
|
||||||
|
conditions=dict(method=["GET", "HEAD"]))
|
||||||
|
|
||||||
# Utility methods {{{
|
# Utility methods {{{
|
||||||
def last_modified(self, updated):
|
def last_modified(self, updated):
|
||||||
@ -127,6 +129,13 @@ class ContentServer(object):
|
|||||||
ans = ans.replace('/static/', self.opts.url_prefix + '/static/')
|
ans = ans.replace('/static/', self.opts.url_prefix + '/static/')
|
||||||
return ans
|
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):
|
def index(self, **kwargs):
|
||||||
'The / URL'
|
'The / URL'
|
||||||
ua = cherrypy.request.headers.get('User-Agent', '').strip()
|
ua = cherrypy.request.headers.get('User-Agent', '').strip()
|
||||||
|
@ -55,6 +55,7 @@ E = ElementMaker(namespace='http://www.w3.org/2005/Atom',
|
|||||||
FEED = E.feed
|
FEED = E.feed
|
||||||
TITLE = E.title
|
TITLE = E.title
|
||||||
ID = E.id
|
ID = E.id
|
||||||
|
ICON = E.icon
|
||||||
|
|
||||||
def UPDATED(dt, *args, **kwargs):
|
def UPDATED(dt, *args, **kwargs):
|
||||||
return E.updated(dt.strftime('%Y-%m-%dT%H:%M:%S+00:00'), *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),
|
TITLE(title),
|
||||||
AUTHOR(__appname__, uri='http://calibre-ebook.com'),
|
AUTHOR(__appname__, uri='http://calibre-ebook.com'),
|
||||||
ID(id_),
|
ID(id_),
|
||||||
|
ICON('/favicon.png'),
|
||||||
UPDATED(updated),
|
UPDATED(updated),
|
||||||
SEARCH_LINK(self.base_href),
|
SEARCH_LINK(self.base_href),
|
||||||
START_LINK(href=self.base_href)
|
START_LINK(href=self.base_href)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user