mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Dont use a python file to store catalog section templates
This commit is contained in:
parent
7bd05cbfeb
commit
390b0d45c1
30
resources/catalog/section_list_templates.conf
Normal file
30
resources/catalog/section_list_templates.conf
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# These templates control the content of titles displayed in the various sections
|
||||||
|
|
||||||
|
# Available fields:
|
||||||
|
# Any column, custom or otherwise, defined for the book, plus
|
||||||
|
# {rating_parens} Rating, in parentheses
|
||||||
|
# {pubyear} Year the book was published
|
||||||
|
# {pubyear_parens} Year the book was published, in parentheses
|
||||||
|
|
||||||
|
# Books by Author
|
||||||
|
by_authors_normal_title_template {title} {pubyear_parens}
|
||||||
|
by_authors_series_title_template [{series_index}] {title} {pubyear_parens}
|
||||||
|
|
||||||
|
# Books by Title
|
||||||
|
by_titles_normal_title_template {title}
|
||||||
|
by_titles_series_title_template {title} ({series} [{series_index}])
|
||||||
|
|
||||||
|
# Books by Series
|
||||||
|
by_series_title_template [{series_index}] {title} {pubyear_parens}
|
||||||
|
|
||||||
|
# Books by Genre
|
||||||
|
by_genres_normal_title_template {title} {pubyear_parens}
|
||||||
|
by_genres_series_title_template {series_index}. {title} {pubyear_parens}
|
||||||
|
|
||||||
|
# Recently Added
|
||||||
|
by_recently_added_normal_title_template {title}
|
||||||
|
by_recently_added_series_title_template {title} ({series} [{series_index}])
|
||||||
|
|
||||||
|
# By Month added
|
||||||
|
by_month_added_normal_title_template {title} {pubyear_parens}
|
||||||
|
by_month_added_series_title_template [{series_index}] {title} {pubyear_parens}
|
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env python2
|
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
|
||||||
__docformat__ = 'restructuredtext en'
|
|
||||||
|
|
||||||
'''
|
|
||||||
These templates control the content of titles displayed in the various sections
|
|
||||||
|
|
||||||
Available fields:
|
|
||||||
Any column, custom or otherwise, defined for the book, plus
|
|
||||||
{rating_parens} Rating, in parentheses
|
|
||||||
{pubyear} Year the book was published
|
|
||||||
{pubyear_parens} Year the book was published, in parentheses
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
|
||||||
# Books by Author
|
|
||||||
by_authors_normal_title_template = '{title} {pubyear_parens}'
|
|
||||||
by_authors_series_title_template = '[{series_index}] {title} {pubyear_parens}'
|
|
||||||
|
|
||||||
# Books by Title
|
|
||||||
by_titles_normal_title_template = '{title}'
|
|
||||||
by_titles_series_title_template = '{title} ({series} [{series_index}])'
|
|
||||||
|
|
||||||
# Books by Series
|
|
||||||
by_series_title_template = '[{series_index}] {title} {pubyear_parens}'
|
|
||||||
|
|
||||||
# Books by Genre
|
|
||||||
by_genres_normal_title_template = '{title} {pubyear_parens}'
|
|
||||||
by_genres_series_title_template = '{series_index}. {title} {pubyear_parens}'
|
|
||||||
|
|
||||||
# Recently Added
|
|
||||||
by_recently_added_normal_title_template = '{title}'
|
|
||||||
by_recently_added_series_title_template = '{title} ({series} [{series_index}])'
|
|
||||||
|
|
||||||
# By Month added
|
|
||||||
by_month_added_normal_title_template = '{title} {pubyear_parens}'
|
|
||||||
by_month_added_series_title_template = '[{series_index}] {title} {pubyear_parens}'
|
|
@ -42,7 +42,7 @@ from calibre.utils.icu import capitalize, collation_order, sort_key
|
|||||||
from calibre.utils.img import scale_image
|
from calibre.utils.img import scale_image
|
||||||
from calibre.utils.localization import get_lang, lang_as_iso639_1
|
from calibre.utils.localization import get_lang, lang_as_iso639_1
|
||||||
from calibre.utils.zipfile import ZipFile
|
from calibre.utils.zipfile import ZipFile
|
||||||
from polyglot.builtins import unicode_type, iteritems, exec_path
|
from polyglot.builtins import unicode_type, iteritems
|
||||||
|
|
||||||
NBSP = u'\u00a0'
|
NBSP = u'\u00a0'
|
||||||
|
|
||||||
@ -4615,11 +4615,15 @@ class CatalogBuilder(object):
|
|||||||
(strs): section templates added to local namespace
|
(strs): section templates added to local namespace
|
||||||
"""
|
"""
|
||||||
|
|
||||||
templates = {}
|
for line in P('catalog/section_list_templates.conf', data=True).decode('utf-8').splitlines():
|
||||||
exec_path(P('catalog/section_list_templates.py'), templates)
|
line = line.lstrip()
|
||||||
for name, template in iteritems(templates):
|
if line.startswith('#'):
|
||||||
if name.startswith('by_') and name.endswith('_template'):
|
continue
|
||||||
setattr(self, name, force_unicode(template, 'utf-8'))
|
if line.startswith('by_'):
|
||||||
|
key, val = line.split(' ', 1)
|
||||||
|
key, val = key.strip(), val.strip()
|
||||||
|
if key.endswith('_template'):
|
||||||
|
setattr(self, key, val)
|
||||||
|
|
||||||
def merge_comments(self, record):
|
def merge_comments(self, record):
|
||||||
""" Merge comments with custom column content.
|
""" Merge comments with custom column content.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user