mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
Fixes #2003712 [Enhancement Request: URL scheme: 'virtual_library' for show-book](https://bugs.launchpad.net/calibre/+bug/2003712)
This commit is contained in:
commit
ea64f851ef
@ -56,6 +56,18 @@ brackets at the end of the path to the book folder.
|
|||||||
You can copy a link to the current book displayed in calibre by right clicking
|
You can copy a link to the current book displayed in calibre by right clicking
|
||||||
the :guilabel:`Book details` panel and choosing :guilabel:`Copy link to book`.
|
the :guilabel:`Book details` panel and choosing :guilabel:`Copy link to book`.
|
||||||
|
|
||||||
|
If a Virtual library is selected, calibre will use it when showing the book. If
|
||||||
|
the book isn't found in that virtual library then the virtual library is cleared.
|
||||||
|
|
||||||
|
If you want to switch to a particular Virtual library when showing the book, use::
|
||||||
|
|
||||||
|
calibre://show-book/Library_Name/book_id?virtual_library=Library%20Name
|
||||||
|
or
|
||||||
|
calibre://show-book/Library_Name/book_id?encoded_virtual_library=hex_encoded_virtual_library_name
|
||||||
|
|
||||||
|
replacing spaces in the Virtual library name by ``%20``. If the book isn't in that
|
||||||
|
virtual library then it is ignored.
|
||||||
|
|
||||||
|
|
||||||
Open a specific book in the E-book viewer at a specific position
|
Open a specific book in the E-book viewer at a specific position
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
|
@ -675,6 +675,16 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
return bytes.fromhex(x[6:]).decode('utf-8')
|
return bytes.fromhex(x[6:]).decode('utf-8')
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
def get_virtual_library(query):
|
||||||
|
vl = None
|
||||||
|
if query.get('encoded_virtual_library'):
|
||||||
|
vl = bytes.fromhex(query.get('encoded_virtual_library')[0]).decode('utf-8')
|
||||||
|
elif query.get('virtual_library'):
|
||||||
|
vl = query.get('virtual_library')[0]
|
||||||
|
if vl == '-':
|
||||||
|
vl = None
|
||||||
|
return vl
|
||||||
|
|
||||||
if action == 'switch-library':
|
if action == 'switch-library':
|
||||||
library_id = decode_library_id(posixpath.basename(path))
|
library_id = decode_library_id(posixpath.basename(path))
|
||||||
library_path = self.library_broker.path_for_library_id(library_id)
|
library_path = self.library_broker.path_for_library_id(library_id)
|
||||||
@ -694,8 +704,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
library_path = self.library_broker.path_for_library_id(library_id)
|
library_path = self.library_broker.path_for_library_id(library_id)
|
||||||
if library_path is None:
|
if library_path is None:
|
||||||
return
|
return
|
||||||
|
vl = get_virtual_library(query)
|
||||||
|
|
||||||
def doit():
|
def doit():
|
||||||
|
# To maintain compatibility, don't change the VL if it isn't specified.
|
||||||
|
if vl is not None and vl != '_':
|
||||||
|
self.apply_virtual_library(vl)
|
||||||
rows = self.library_view.select_rows((book_id,))
|
rows = self.library_view.select_rows((book_id,))
|
||||||
db = self.current_db
|
db = self.current_db
|
||||||
if not rows and (db.data.get_base_restriction_name() or db.data.get_search_restriction_name()):
|
if not rows and (db.data.get_base_restriction_name() or db.data.get_search_restriction_name()):
|
||||||
@ -743,13 +757,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
if sq:
|
if sq:
|
||||||
sq = sq[0]
|
sq = sq[0]
|
||||||
sq = sq or ''
|
sq = sq or ''
|
||||||
vl = None
|
vl = get_virtual_library(query)
|
||||||
if query.get('encoded_virtual_library'):
|
|
||||||
vl = bytes.fromhex(query.get('encoded_virtual_library')[0]).decode('utf-8')
|
|
||||||
elif query.get('virtual_library'):
|
|
||||||
vl = query.get('virtual_library')[0]
|
|
||||||
if vl == '-':
|
|
||||||
vl = None
|
|
||||||
|
|
||||||
def doit():
|
def doit():
|
||||||
if vl != '_':
|
if vl != '_':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user