mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix regression causing content server to prefix tags with their count in /mobile and /opds views
This commit is contained in:
commit
afe8ab7c9e
@ -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']) \
|
series = u'[%s - %s]'%(book['series'], book['series_index']) \
|
||||||
if book['series'] else ''
|
if book['series'] else ''
|
||||||
tags = u'Tags=[%s]'%book['tags'] if book['tags'] else ''
|
tags = u'Tags=[%s]'%book['tags'] if book['tags'] else ''
|
||||||
|
print tags
|
||||||
|
|
||||||
ctext = ''
|
ctext = ''
|
||||||
for key in CKEYS:
|
for key in CKEYS:
|
||||||
@ -217,7 +218,8 @@ class MobileServer(object):
|
|||||||
book['authors'] = authors
|
book['authors'] = authors
|
||||||
book['series_index'] = fmt_sidx(float(record[FM['series_index']]))
|
book['series_index'] = fmt_sidx(float(record[FM['series_index']]))
|
||||||
book['series'] = record[FM['series']]
|
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']]
|
book['title'] = record[FM['title']]
|
||||||
for x in ('timestamp', 'pubdate'):
|
for x in ('timestamp', 'pubdate'):
|
||||||
book[x] = strftime('%Y/%m/%d %H:%M:%S', record[FM[x]])
|
book[x] = strftime('%Y/%m/%d %H:%M:%S', record[FM[x]])
|
||||||
@ -233,7 +235,9 @@ class MobileServer(object):
|
|||||||
continue
|
continue
|
||||||
name = CFM[key]['name']
|
name = CFM[key]['name']
|
||||||
if datatype == 'text' and CFM[key]['is_multiple']:
|
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':
|
elif datatype == 'series':
|
||||||
book[key] = concat(name, '%s [%s]'%(val,
|
book[key] = concat(name, '%s [%s]'%(val,
|
||||||
fmt_sidx(record[CFM.cc_series_index_column_for(key)])))
|
fmt_sidx(record[CFM.cc_series_index_column_for(key)])))
|
||||||
|
@ -17,6 +17,7 @@ import routes
|
|||||||
from calibre.constants import __appname__
|
from calibre.constants import __appname__
|
||||||
from calibre.ebooks.metadata import fmt_sidx
|
from calibre.ebooks.metadata import fmt_sidx
|
||||||
from calibre.library.comments import comments_to_html
|
from calibre.library.comments import comments_to_html
|
||||||
|
from calibre.library.server.utils import format_tag_string
|
||||||
from calibre import guess_type
|
from calibre import guess_type
|
||||||
from calibre.utils.ordered_dict import OrderedDict
|
from calibre.utils.ordered_dict import OrderedDict
|
||||||
from calibre.utils.date import format_date
|
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)
|
extra.append(_('RATING: %s<br />')%rating)
|
||||||
tags = item[FM['tags']]
|
tags = item[FM['tags']]
|
||||||
if tags:
|
if tags:
|
||||||
extra.append(_('TAGS: %s<br />')%\
|
extra.append(_('TAGS: %s<br />')%format_tag_string(tags, ',',
|
||||||
', '.join(tags.split(',')))
|
ignore_max=True,
|
||||||
|
no_tag_count=True))
|
||||||
series = item[FM['series']]
|
series = item[FM['series']]
|
||||||
if series:
|
if series:
|
||||||
extra.append(_('SERIES: %s [%s]<br />')%\
|
extra.append(_('SERIES: %s [%s]<br />')%\
|
||||||
@ -160,7 +162,9 @@ def ACQUISITION_ENTRY(item, version, FM, updated, CFM, CKEYS):
|
|||||||
name = CFM[key]['name']
|
name = CFM[key]['name']
|
||||||
datatype = CFM[key]['datatype']
|
datatype = CFM[key]['datatype']
|
||||||
if datatype == 'text' and CFM[key]['is_multiple']:
|
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':
|
elif datatype == 'series':
|
||||||
extra.append('%s: %s [%s]<br />'%(name, val,
|
extra.append('%s: %s [%s]<br />'%(name, val,
|
||||||
fmt_sidx(item[CFM.cc_series_index_column_for(key)])))
|
fmt_sidx(item[CFM.cc_series_index_column_for(key)])))
|
||||||
|
@ -44,7 +44,7 @@ def strftime(fmt='%Y/%m/%d %H:%M:%S', dt=None):
|
|||||||
except:
|
except:
|
||||||
return _strftime(fmt, nowf().timetuple())
|
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']
|
MAX = sys.maxint if ignore_max else tweaks['max_content_server_tags_shown']
|
||||||
if tags:
|
if tags:
|
||||||
tlist = [t.strip() for t in tags.split(sep)]
|
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()))
|
tlist.sort(cmp=lambda x,y:cmp(x.lower(), y.lower()))
|
||||||
if len(tlist) > MAX:
|
if len(tlist) > MAX:
|
||||||
tlist = tlist[:MAX]+['...']
|
tlist = tlist[:MAX]+['...']
|
||||||
|
if no_tag_count:
|
||||||
|
return ', '.join(tlist) if tlist else ''
|
||||||
|
else:
|
||||||
return u'%s:&:%s'%(tweaks['max_content_server_tags_shown'],
|
return u'%s:&:%s'%(tweaks['max_content_server_tags_shown'],
|
||||||
', '.join(tlist)) if tlist else ''
|
', '.join(tlist)) if tlist else ''
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user