mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add available libraries to interface data
This commit is contained in:
parent
f2c01547f8
commit
f4a63c9c29
@ -571,6 +571,7 @@ def interface_data(ctx, rd, library_id):
|
||||
'''
|
||||
session = rd.session
|
||||
ans = {'session_data': {k:session[k] for k in defaults.iterkeys()}}
|
||||
ans['library_map'], ans['default_library'] = ctx.library_map
|
||||
sorts, orders = [], []
|
||||
for x in ans['session_data']['sort'].split(','):
|
||||
s, o = x.partition(':')[::2]
|
||||
|
@ -66,6 +66,14 @@ class LibraryBroker(object):
|
||||
getattr(db, 'close', lambda : None)()
|
||||
self.lmap = {}
|
||||
|
||||
@property
|
||||
def library_map(self):
|
||||
def lpath(x):
|
||||
if hasattr(x, 'rpartition'):
|
||||
return x
|
||||
return x.backend.library_path
|
||||
return {k:os.path.basename(lpath(v)) for k, v in self.lmap.iteritems()}
|
||||
|
||||
class Context(object):
|
||||
|
||||
log = None
|
||||
@ -91,6 +99,10 @@ class Context(object):
|
||||
def get_library(self, library_id=None):
|
||||
return self.library_broker.get(library_id)
|
||||
|
||||
@property
|
||||
def library_map(self):
|
||||
return self.library_broker.library_map, self.library_broker.default_library
|
||||
|
||||
def allowed_book_ids(self, data, db):
|
||||
# TODO: Implement this based on data.username for per-user
|
||||
# restrictions. Cache result on the data object
|
||||
|
@ -86,10 +86,6 @@ not specify any paths, the library last opened (if any) in the main calibre
|
||||
program will be used.
|
||||
'''
|
||||
))
|
||||
parser.add_option(
|
||||
'-l', '--library', dest='libraries', action='append', default=[],
|
||||
help=_('Path to a calibre library folder. Can be specified multiple'
|
||||
' times to serve multiple libraries'))
|
||||
parser.add_option(
|
||||
'--log', default=None,
|
||||
help=_('Path to log file for server log'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user