This commit is contained in:
Kovid Goyal 2013-09-07 16:47:25 +05:30
parent 233395c0d4
commit 255fcce9e5

View File

@ -126,7 +126,7 @@ def CATALOG_ENTRY(item, item_kind, base_href, version, updated,
if item.id is not None: if item.id is not None:
iid = 'I' + str(item.id) iid = 'I' + str(item.id)
iid += ':'+item_kind iid += ':'+item_kind
link = NAVLINK(href = base_href + '/' + hexlify(iid)) link = NAVLINK(href=base_href + '/' + hexlify(iid))
count = (_('%d books') if item.count > 1 else _('%d book'))%item.count count = (_('%d books') if item.count > 1 else _('%d book'))%item.count
if ignore_count: if ignore_count:
count = '' count = ''
@ -145,7 +145,7 @@ def CATALOG_ENTRY(item, item_kind, base_href, version, updated,
def CATALOG_GROUP_ENTRY(item, category, base_href, version, updated): def CATALOG_GROUP_ENTRY(item, category, base_href, version, updated):
id_ = 'calibre:category-group:'+category+':'+item.text id_ = 'calibre:category-group:'+category+':'+item.text
iid = item.text iid = item.text
link = NAVLINK(href = base_href + '/' + hexlify(iid)) link = NAVLINK(href=base_href + '/' + hexlify(iid))
return E.entry( return E.entry(
TITLE(item.text), TITLE(item.text),
ID(id_), ID(id_),
@ -176,7 +176,7 @@ def ACQUISITION_ENTRY(item, version, db, updated, CFM, CKEYS, prefix):
no_tag_count=True))) no_tag_count=True)))
series = item[FM['series']] series = item[FM['series']]
if series: if series:
extra.append(_('SERIES: %(series)s [%(sidx)s]<br />')%\ extra.append(_('SERIES: %(series)s [%(sidx)s]<br />')%
dict(series=xml(series), dict(series=xml(series),
sidx=fmt_sidx(float(item[FM['series_index']])))) sidx=fmt_sidx(float(item[FM['series_index']]))))
for key in CKEYS: for key in CKEYS:
@ -231,7 +231,7 @@ def ACQUISITION_ENTRY(item, version, db, updated, CFM, CKEYS, prefix):
# }}} # }}}
class Feed(object): # {{{ class Feed(object): # {{{
def __init__(self, id_, updated, version, subtitle=None, def __init__(self, id_, updated, version, subtitle=None,
title=__appname__ + ' ' + _('Library'), title=__appname__ + ' ' + _('Library'),
@ -267,14 +267,14 @@ class Feed(object): # {{{
xml_declaration=True) xml_declaration=True)
# }}} # }}}
class TopLevel(Feed): # {{{ class TopLevel(Feed): # {{{
def __init__(self, def __init__(self,
updated, # datetime object in UTC updated, # datetime object in UTC
categories, categories,
version, version,
id_ = 'urn:calibre:main', id_='urn:calibre:main',
subtitle = _('Books in your library') subtitle=_('Books in your library')
): ):
Feed.__init__(self, id_, updated, version, subtitle=subtitle) Feed.__init__(self, id_, updated, version, subtitle=subtitle)
@ -335,7 +335,6 @@ class CategoryGroupFeed(NavFeed):
self.root.append(CATALOG_GROUP_ENTRY(item, which, base_href, version, updated)) self.root.append(CATALOG_GROUP_ENTRY(item, which, base_href, version, updated))
class OPDSServer(object): class OPDSServer(object):
def add_routes(self, connect): def add_routes(self, connect):
@ -452,7 +451,6 @@ class OPDSServer(object):
return str(CategoryFeed(items, category, id_, updated, version, offsets, return str(CategoryFeed(items, category, id_, updated, version, offsets,
page_url, up_url, self.db)) page_url, up_url, self.db))
def opds_navcatalog(self, which=None, version=0, offset=0): def opds_navcatalog(self, which=None, version=0, offset=0):
try: try:
offset = int(offset) offset = int(offset)
@ -563,7 +561,8 @@ class OPDSServer(object):
raise cherrypy.HTTPError(404, 'Non id categories not supported') raise cherrypy.HTTPError(404, 'Non id categories not supported')
q = category q = category
if q == 'news': q = 'tags' if q == 'news':
q = 'tags'
ids = self.db.get_books_for_category(q, which) ids = self.db.get_books_for_category(q, which)
sort_by = 'series' if category == 'series' else 'title' sort_by = 'series' if category == 'series' else 'title'
@ -573,7 +572,6 @@ class OPDSServer(object):
# }}} # }}}
def opds(self, version=0): def opds(self, version=0):
version = int(version) version = int(version)
if version not in BASE_HREFS: if version not in BASE_HREFS: