mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Use the template from the device driver specified by the client, if any.
This commit is contained in:
parent
30fa640e24
commit
d22c409669
@ -572,14 +572,3 @@ restrict_output_formats = None
|
|||||||
# numbers.
|
# numbers.
|
||||||
# The value can be between 50 and 99
|
# The value can be between 50 and 99
|
||||||
content_server_thumbnail_compression_quality = 75
|
content_server_thumbnail_compression_quality = 75
|
||||||
|
|
||||||
#: Set the template for the file name supplied by the content server
|
|
||||||
# Setting this tweak will make the content server supply the template's value
|
|
||||||
# when a book's metadata is requested in "device compatible" mode. The client
|
|
||||||
# can use this value as part of the path for the book when downloaded. Note
|
|
||||||
# that the save_template_title_series_sorting tweak is used to control title
|
|
||||||
# and series values.
|
|
||||||
# Examples:
|
|
||||||
# content_server_path_for_client = "{title}-{author}"
|
|
||||||
# content_server_path_for_client = "{title_sort}-{:'series_sort()'||-}{author_sort}"
|
|
||||||
content_server_path_for_client = ''
|
|
||||||
|
@ -119,7 +119,7 @@ class AjaxServer(object):
|
|||||||
|
|
||||||
# Get book metadata {{{
|
# Get book metadata {{{
|
||||||
def ajax_book_to_json(self, book_id, get_category_urls=True,
|
def ajax_book_to_json(self, book_id, get_category_urls=True,
|
||||||
device_compatible=False):
|
device_compatible=False, device_for_template=None):
|
||||||
mi = self.db.get_metadata(book_id, index_is_id=True)
|
mi = self.db.get_metadata(book_id, index_is_id=True)
|
||||||
|
|
||||||
if not device_compatible:
|
if not device_compatible:
|
||||||
@ -191,18 +191,24 @@ class AjaxServer(object):
|
|||||||
else:
|
else:
|
||||||
series = ''
|
series = ''
|
||||||
data['_series_sort_'] = series
|
data['_series_sort_'] = series
|
||||||
if tweaks['content_server_path_for_client']:
|
if device_for_template:
|
||||||
import posixpath
|
import posixpath
|
||||||
from calibre.devices.utils import create_upload_path
|
from calibre.devices.utils import create_upload_path
|
||||||
from calibre.utils.filenames import ascii_filename as sanitize
|
from calibre.utils.filenames import ascii_filename as sanitize
|
||||||
data['_filename_'] = create_upload_path(mi, '',
|
from calibre.customize.ui import device_plugins
|
||||||
tweaks['content_server_path_for_client'],
|
|
||||||
sanitize, path_type=posixpath)
|
for device_class in device_plugins():
|
||||||
|
if device_class.__class__.__name__ == device_for_template:
|
||||||
|
template = device_class.save_template()
|
||||||
|
data['_filename_'] = create_upload_path(mi, book_id,
|
||||||
|
template, sanitize, path_type=posixpath)
|
||||||
|
break;
|
||||||
|
|
||||||
return data, mi.last_modified
|
return data, mi.last_modified
|
||||||
|
|
||||||
@Endpoint(set_last_modified=False)
|
@Endpoint(set_last_modified=False)
|
||||||
def ajax_book(self, book_id, category_urls='true', id_is_uuid='false',
|
def ajax_book(self, book_id, category_urls='true', id_is_uuid='false',
|
||||||
device_compatible='false'):
|
device_compatible='false', device_for_template=None):
|
||||||
'''
|
'''
|
||||||
Return the metadata of the book as a JSON dictionary.
|
Return the metadata of the book as a JSON dictionary.
|
||||||
|
|
||||||
@ -219,7 +225,8 @@ class AjaxServer(object):
|
|||||||
book_id = int(book_id)
|
book_id = int(book_id)
|
||||||
data, last_modified = self.ajax_book_to_json(book_id,
|
data, last_modified = self.ajax_book_to_json(book_id,
|
||||||
get_category_urls=category_urls.lower()=='true',
|
get_category_urls=category_urls.lower()=='true',
|
||||||
device_compatible=device_compatible.lower()=='true')
|
device_compatible=device_compatible.lower()=='true',
|
||||||
|
device_for_template=device_for_template)
|
||||||
except:
|
except:
|
||||||
raise cherrypy.HTTPError(404, 'No book with id: %r'%book_id)
|
raise cherrypy.HTTPError(404, 'No book with id: %r'%book_id)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user