View Single Post
Old 03-23-2023, 02:07 PM   #8
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,465
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Prototype

I have a prototype with two new calibre: url endpoints:
  • calibre://book-details/library/book_id
  • calibre://book-details-search/library?q=search-query

Using either of these URLs will open a book details window getting the information from the named library, which doesn't need to be the current one. The current library isn't closed or changed, nor is the selection changed. In the first case, it gets the details for the book in the "other" library with the specified book id. In the second case it does a search on the other library and picks the first (one hopes the only) answer. A error is shown if either the book_id doesn't exist or the query matches no books.

The second form is useful for fields other than authors that don't support native links. See below.

Some examples:

Here is a "books" library. It makes reference to another library. Note the library name.
Click image for larger version

Name:	Clipboard01.jpg
Views:	196
Size:	48.2 KB
ID:	200572

Here are the links in book details:
Click image for larger version

Name:	Clipboard02.jpg
Views:	159
Size:	8.7 KB
ID:	200573

Clicking on the Publisher: Baen link opens a book details window with data from the other library. Again, note the library name.
Click image for larger version

Name:	Clipboard03.jpg
Views:	188
Size:	42.6 KB
ID:	200574

Because only the authors field has native links I added a new formatter function to generate links to other libraries. This is the template that generated the links shown above:
Code:
program:
	make_book_details_search_links(
		'authors:Library.test_virtlib, publisher:Library.test_virtlib,', '<br>')
The first argument is a list of columns and associated libraries for which we want links. This example uses authors and publishers, both using the same target "other" library "Library.test_virtlib". For each column the function generates a comma-separated list of links. Each link is a book-details-query link looking for the value of the field in the other library. Each list is separated from the other by the second parameter, in this case '<br>'. As long as you accept the formatting, this function makes it very easy to generate links for any column, custom or standard.

While there I added the ability to have multiple book details windows. One window will move with book list changes. Other windows will keep their contents, regardless of source library. This image shows one example.
Click image for larger version

Name:	Clipboard04.jpg
Views:	185
Size:	251.8 KB
ID:	200575

And yes, I know that at least some of you will ask for native links for all columns. I am thinking about this, but it introduces a *lot* of work for what seems to me to be minimal gain. It would require database changes, calibre API changes, and a UI to manage them. The click behavior of items in book details would change, I think for the worse. This is why I built the new template function, so a person can get interlibrary links while keeping the current click semantics.
chaley is offline   Reply With Quote