Make the author_sort display tweak work in the content server

This commit is contained in:
Charles Haley 2010-12-18 18:14:40 +00:00
parent 65e1c1cd98
commit c68a36d3c1
4 changed files with 24 additions and 14 deletions

View File

@ -43,17 +43,17 @@ author_sort_copy_method = 'invert'
# Set which author field to display in the tags pane (the list of authors, # Set which author field to display in the tags pane (the list of authors,
# series, publishers etc on the left hand side). The choices are author and # series, publishers etc on the left hand side). The choices are author and
# author_sort. This tweak affects only the tags pane, and only what is displayed # author_sort. This tweak affects only what is displayed under the authors
# under the authors category. Please note that if you set this to author_sort, # category in the tags pane and content server. Please note that if you set this
# it is very possible to see duplicate names in the list becasue although it is # to author_sort, it is very possible to see duplicate names in the list because
# guaranteed that author names are unique, there is no such guarantee for # although it is guaranteed that author names are unique, there is no such
# author_sort values. Showing duplicates won't break anything, but it could # guarantee for author_sort values. Showing duplicates won't break anything, but
# lead to some confusion. When using 'author_sort', the tooltip will show the # it could lead to some confusion. When using 'author_sort', the tooltip will
# author's name. # show the author's name.
# Examples: # Examples:
# tags_pane_use_field_for_author_name = 'author' # categories_use_field_for_author_name = 'author'
# tags_pane_use_field_for_author_name = 'author_sort' # categories_use_field_for_author_name = 'author_sort'
tags_pane_use_field_for_author_name = 'author' categories_use_field_for_author_name = 'author'
# Set whether boolean custom columns are two- or three-valued. # Set whether boolean custom columns are two- or three-valued.

View File

@ -412,7 +412,7 @@ class TagTreeItem(object): # {{{
def tag_data(self, role): def tag_data(self, role):
tag = self.tag tag = self.tag
if tag.category == 'authors' and \ if tag.category == 'authors' and \
tweaks['tags_pane_use_field_for_author_name'] == 'author_sort': tweaks['categories_use_field_for_author_name'] == 'author_sort':
name = tag.sort name = tag.sort
tt_author = True tt_author = True
else: else:

View File

@ -15,7 +15,7 @@ from calibre import isbytestring, force_unicode, fit_image, \
prepare_string_for_xml as xml prepare_string_for_xml as xml
from calibre.utils.ordered_dict import OrderedDict from calibre.utils.ordered_dict import OrderedDict
from calibre.utils.filenames import ascii_filename from calibre.utils.filenames import ascii_filename
from calibre.utils.config import prefs from calibre.utils.config import prefs, tweaks
from calibre.utils.icu import sort_key from calibre.utils.icu import sort_key
from calibre.utils.magick import Image from calibre.utils.magick import Image
from calibre.library.comments import comments_to_html from calibre.library.comments import comments_to_html
@ -151,7 +151,11 @@ def get_category_items(category, items, restriction, datatype, prefix): # {{{
'<div>{1}</div>' '<div>{1}</div>'
'<div>{2}</div></div>') '<div>{2}</div></div>')
rating, rstring = render_rating(i.avg_rating, prefix) rating, rstring = render_rating(i.avg_rating, prefix)
name = xml(i.name) if i.category == 'authors' and \
tweaks['categories_use_field_for_author_name'] == 'author_sort':
name = xml(i.sort)
else:
name = xml(i.name)
if datatype == 'rating': if datatype == 'rating':
name = xml(_('%d stars')%int(i.avg_rating)) name = xml(_('%d stars')%int(i.avg_rating))
id_ = i.id id_ = i.id

View File

@ -22,6 +22,7 @@ from calibre.library.server.utils import format_tag_string, Offsets
from calibre import guess_type, prepare_string_for_xml as xml from calibre import guess_type, prepare_string_for_xml as xml
from calibre.utils.icu import sort_key from calibre.utils.icu import sort_key
from calibre.utils.ordered_dict import OrderedDict from calibre.utils.ordered_dict import OrderedDict
from calibre.utils.config import tweaks
BASE_HREFS = { BASE_HREFS = {
0 : '/stanza', 0 : '/stanza',
@ -113,8 +114,13 @@ def CATALOG_ENTRY(item, item_kind, base_href, version, updated,
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 = ''
if item.category == 'authors' and \
tweaks['categories_use_field_for_author_name'] == 'author_sort':
name = xml(item.sort)
else:
name = xml(item.name)
return E.entry( return E.entry(
TITLE(item.name + ('' if not add_kind else ' (%s)'%item_kind)), TITLE(name + ('' if not add_kind else ' (%s)'%item_kind)),
ID(id_), ID(id_),
UPDATED(updated), UPDATED(updated),
E.content(count, type='text'), E.content(count, type='text'),