Content server fixes

This commit is contained in:
Charles Haley 2010-09-12 20:52:26 +01:00
parent c525112a9d
commit ea3719c773
3 changed files with 18 additions and 7 deletions

View File

@ -124,6 +124,7 @@ def build_index(books, num, search, sort, order, start, total, url_base, CKEYS):
series = u'[%s - %s]'%(book['series'], book['series_index']) \
if book['series'] else ''
tags = u'Tags=[%s]'%book['tags'] if book['tags'] else ''
print tags
ctext = ''
for key in CKEYS:
@ -217,7 +218,8 @@ class MobileServer(object):
book['authors'] = authors
book['series_index'] = fmt_sidx(float(record[FM['series_index']]))
book['series'] = record[FM['series']]
book['tags'] = format_tag_string(record[FM['tags']], ',')
book['tags'] = format_tag_string(record[FM['tags']], ',',
no_tag_count=True)
book['title'] = record[FM['title']]
for x in ('timestamp', 'pubdate'):
book[x] = strftime('%Y/%m/%d %H:%M:%S', record[FM[x]])
@ -233,7 +235,9 @@ class MobileServer(object):
continue
name = CFM[key]['name']
if datatype == 'text' and CFM[key]['is_multiple']:
book[key] = concat(name, format_tag_string(val, '|'))
book[key] = concat(name,
format_tag_string(val, '|',
no_tag_count=True))
elif datatype == 'series':
book[key] = concat(name, '%s [%s]'%(val,
fmt_sidx(record[CFM.cc_series_index_column_for(key)])))

View File

@ -17,6 +17,7 @@ import routes
from calibre.constants import __appname__
from calibre.ebooks.metadata import fmt_sidx
from calibre.library.comments import comments_to_html
from calibre.library.server.utils import format_tag_string
from calibre import guess_type
from calibre.utils.ordered_dict import OrderedDict
from calibre.utils.date import format_date
@ -147,8 +148,9 @@ def ACQUISITION_ENTRY(item, version, FM, updated, CFM, CKEYS):
extra.append(_('RATING: %s<br />')%rating)
tags = item[FM['tags']]
if tags:
extra.append(_('TAGS: %s<br />')%\
', '.join(tags.split(',')))
extra.append(_('TAGS: %s<br />')%format_tag_string(tags, ',',
ignore_max=True,
no_tag_count=True))
series = item[FM['series']]
if series:
extra.append(_('SERIES: %s [%s]<br />')%\
@ -160,7 +162,9 @@ def ACQUISITION_ENTRY(item, version, FM, updated, CFM, CKEYS):
name = CFM[key]['name']
datatype = CFM[key]['datatype']
if datatype == 'text' and CFM[key]['is_multiple']:
extra.append('%s: %s<br />'%(name, ', '.join(val.split('|'))))
extra.append('%s: %s<br />'%(name, format_tag_string(val, '|',
ignore_max=True,
no_tag_count=True)))
elif datatype == 'series':
extra.append('%s: %s [%s]<br />'%(name, val,
fmt_sidx(item[CFM.cc_series_index_column_for(key)])))

View File

@ -44,7 +44,7 @@ def strftime(fmt='%Y/%m/%d %H:%M:%S', dt=None):
except:
return _strftime(fmt, nowf().timetuple())
def format_tag_string(tags, sep, ignore_max=False):
def format_tag_string(tags, sep, ignore_max=False, no_tag_count=False):
MAX = sys.maxint if ignore_max else tweaks['max_content_server_tags_shown']
if tags:
tlist = [t.strip() for t in tags.split(sep)]
@ -53,6 +53,9 @@ def format_tag_string(tags, sep, ignore_max=False):
tlist.sort(cmp=lambda x,y:cmp(x.lower(), y.lower()))
if len(tlist) > MAX:
tlist = tlist[:MAX]+['...']
return u'%s:&:%s'%(tweaks['max_content_server_tags_shown'],
if no_tag_count:
return ', '.join(tlist) if tlist else ''
else:
return u'%s:&:%s'%(tweaks['max_content_server_tags_shown'],
', '.join(tlist)) if tlist else ''