diff --git a/src/calibre/srv/ajax.py b/src/calibre/srv/ajax.py index 638765b5b5..2062891078 100644 --- a/src/calibre/srv/ajax.py +++ b/src/calibre/srv/ajax.py @@ -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] diff --git a/src/calibre/srv/handler.py b/src/calibre/srv/handler.py index 6ace5810c7..5ad89d5e69 100644 --- a/src/calibre/srv/handler.py +++ b/src/calibre/srv/handler.py @@ -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 diff --git a/src/calibre/srv/standalone.py b/src/calibre/srv/standalone.py index e351b16248..d19ed0a12e 100644 --- a/src/calibre/srv/standalone.py +++ b/src/calibre/srv/standalone.py @@ -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'))