Changes to save_to_disk to use title_sort instead of recomputing it.

This commit is contained in:
Charles Haley 2011-02-11 10:43:28 +00:00
parent 70636b42c4
commit 83cde4af65
2 changed files with 28 additions and 18 deletions

View File

@ -126,27 +126,31 @@ sort_columns_at_startup = None
gui_pubdate_display_format = 'MMM yyyy'
gui_timestamp_display_format = 'dd MMM yyyy'
#: Control how title and series names are formatted when saving to disk/sending
# to device. The behavior depends on the field being processed. If processing
# title, then if set to 'library_order', the title will be replaced with
# title_sort. If set to 'strictly_alphabetic', then the title is left unchanged.
# If processing series, then if set to 'library_order', articles such as 'The'
# and 'An' will be moved to the end. If set to 'strictly_alphabetic', the series
# will be sent without change. For example, with library_order, "The Lord of the
# Rings" will become "Lord of the Rings, The". With strictly_alphabetic, it
# would remain "The Lord of the Rings".
#: Control sorting of titles and series in the library display
# Control title and series sorting in the library view. If set to
# 'library_order', the title sort field will be used instead of the title.
# Unless you have manually edited the title sort field, leading articles such as
# The and A will be ignored. If set to 'strictly_alphabetic', the titles will be
# sorted as-is (sort by title instead of title sort). For example, with
# library_order, The Client will sort under 'C'. With strictly_alphabetic, the
# book will sort under 'T'.
# This flag affects Calibre's library display. It has no effect on devices. In
# addition, titles for books added before changing the flag will retain their
# order until the title is edited. Double-clicking on a title and hitting return
# without changing anything is sufficient to change the sort.
title_series_sorting = 'library_order'
#: Control formatting of title and series when used in templates
# Control how title and series names are formatted when saving to disk/sending
# to device. The behavior depends on the field being processed. If processing
# title, then if set to 'library_order', the title will be replaced with
# title_sort. If set to 'strictly_alphabetic', then the title is left unchanged.
# If processing series, then if set to 'library_order', articles such as 'The'
# and 'An' will be moved to the end. If set to 'strictly_alphabetic', the series
# will be sent without change. For example, with library_order, "The Lord of the
# Rings" will become "Lord of the Rings, The". With strictly_alphabetic, it
# would remain "The Lord of the Rings".
# title, then if this tweak is set to 'library_order', the title will be
# replaced with title_sort. If it is set to 'strictly_alphabetic', then the
# title will not be changed. If processing series, then if set to
# 'library_order', articles such as 'The' and 'An' will be moved to the end. If
# set to 'strictly_alphabetic', the series will be sent without change.
# For example, if the tweak is set to library_order, "The Lord of the Rings"
# will become "Lord of the Rings, The". If the tweak is set to
# strictly_alphabetic, it would remain "The Lord of the Rings".
save_template_title_series_sorting = 'library_order'
#: Set the list of words considered to be "articles" for sort strings

View File

@ -147,8 +147,14 @@ def get_components(template, mi, id, timefmt='%b %Y', length=250,
format_args = FORMAT_ARGS.copy()
format_args.update(mi.all_non_none_fields())
if mi.title:
format_args['title'] = mi.title if tsorder == 'strictly_alphabetic' \
else mi.get('title_sort', title_sort(mi.title, order='library_order'))
if tsorder == 'strictly_alphabetic':
v = mi.title
else:
# title_sort might be missing or empty. Check both conditions
v = mi.get('title_sort', None)
if not v:
v = title_sort(mi.title, order=tsorder)
format_args['title'] = v
if mi.authors:
format_args['authors'] = mi.format_authors()
format_args['author'] = format_args['authors']