Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 05-24-2022, 07:43 PM   #1
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Composite columns and identifiers

If you have an {identifiers:select(id)} composite column, it displays the id contents and clicking on it in book details returns the output as a Calibre search.

Instead, is it possible via a template (or custom function) to replicate the behaviour of the default Ids column where it displays the id name and opens the identifier url in the browser?

Last edited by ownedbycats; 05-24-2022 at 07:59 PM.
ownedbycats is online now   Reply With Quote
Old 05-25-2022, 06:19 AM   #2
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
If you have an {identifiers:select(id)} composite column, it displays the id contents and clicking on it in book details returns the output as a Calibre search.

Instead, is it possible via a template (or custom function) to replicate the behaviour of the default Ids column where it displays the id name and opens the identifier url in the browser?
Yes. You can mark the composite as "Contains HTML" then build the link you want in the composite.

Example for Google identifiers:
Code:
program:
	id = select($identifiers, 'google');
	if id then
		'<a href="https://books.google.co.uk/books?id=' & id & '&redir_esc=y' & '">Google:' & id & '</a>'
	fi
You must hard code the URL components into the template.
chaley is offline   Reply With Quote
Advert
Old 05-25-2022, 11:14 AM   #3
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thanks.
ownedbycats is online now   Reply With Quote
Old 05-25-2022, 11:24 AM   #4
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
What are you doing? I ask because it wouldn't be hard to add a subtype to composite columns "contains identifiers". Columns with that type would be automatically parsed like identifiers in book details, with the same linking. But I am not convinced the use case justifies the work and the inevitable user fallout.
chaley is offline   Reply With Quote
Old 05-25-2022, 11:33 AM   #5
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I wanted to display links the details pane depending on which ids were available. Here's the original template before I realized it didn't work as intended:

Code:
program:

	first_non_empty(
		if $publisher=='Fanfiction.net' then id = select($identifiers, 'ffnet') fi,
		if $publisher=='Archive of Our Own' then id = select($identifiers, 'ao3') fi,
		id = select($identifiers, 'goodreads'),
		id = select($identifiers, 'ff'),
		id = select($identifiers, 'google'),
		id = select($identifiers, 'url')
		)
Attached Thumbnails
Click image for larger version

Name:	2022-05-25 12_41_31-calibre — __ My Books __ Currently Reading __.png
Views:	78
Size:	316.8 KB
ID:	193972  

Last edited by ownedbycats; 05-25-2022 at 11:47 AM.
ownedbycats is online now   Reply With Quote
Advert
Old 05-25-2022, 11:49 AM   #6
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Said another way, you want a subset of identifiers based on some other metadata. That is one use case I thought of.

Another use case is constructing identifiers such as calibre custom urls links based on a book's metadata. This might be usable for cross linking books.

I don't know if either of these would be generally useful.
chaley is offline   Reply With Quote
Old 05-25-2022, 12:53 PM   #7
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Could it be possible to have a function (say, url_from_id:(id) that automatically generates the URL? It seems more feasible, though there would probably need to be a caveat that it only works with HTML enabled.

Last edited by chaley; 05-25-2022 at 02:16 PM. Reason: Disabled smileys
ownedbycats is online now   Reply With Quote
Old 05-25-2022, 02:15 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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Could it be possible to have a function (say, url_from_idid) that automatically generates the URL? It seems more feasible, though there would probably need to be a caveat that it only works with HTML enabled.
That is significantly harder than "contains identifiers" and I don't see any advantages.

Some problems:
  • It ties the formatter into the book details ecosystem, making maintenance more difficult.
  • Tool tips wouldn't work.
  • Dealing with multiple identifiers would be tricky.
  • URLs generated by plugins and "rules" would be tricky.

At this point I am putting the idea on hold. You have something that works, so my idea seems to be a solution in search of a problem. We can revisit it if needed.
chaley is offline   Reply With Quote
Old 05-26-2022, 06:15 AM   #9
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I looked further and found a calibre method that converts identifiers to URLs outside of the GUI and book details. It returns a list of comma-separated <A></A> tags. It also handles rules and plugins.

That deals with all my problems except tool tips. It would require the composite to be marked "contains html". I will test further when I get a moment.
chaley is offline   Reply With Quote
Old 05-26-2022, 06:36 AM   #10
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I'll be glad to test when it's in source
ownedbycats is online now   Reply With Quote
Old 05-26-2022, 11:29 AM   #11
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I'll be glad to test when it's in source
It is in source now.
chaley is offline   Reply With Quote
Old 05-26-2022, 02:06 PM   #12
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Did I misunderstand the syntax here?

Attached Thumbnails
Click image for larger version

Name:	2022-05-26 15_05_00-Edit template.png
Views:	131
Size:	54.9 KB
ID:	193979   Click image for larger version

Name:	2022-05-26 15_06_33-Edit template.png
Views:	58
Size:	59.3 KB
ID:	193980  
ownedbycats is online now   Reply With Quote
Old 05-26-2022, 02:08 PM   #13
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Did I misunderstand the syntax here?

Yes. The list is a string. The trailing quote goes after the value, as in 'google:12345', not 'google':12345. EDIT: Also, the first value is the identifier key, not its display name. Look at the contents of the identifier field to get the values.

Last edited by chaley; 05-26-2022 at 02:11 PM.
chaley is offline   Reply With Quote
Old 05-26-2022, 02:25 PM   #14
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
		if 
			$publisher=='Archive of Our Own' 
		then 		
			id = select($identifiers, 'ao3');
			urls_from_identifiers('ao3:id', 1)
		fi,
results in

Code:
<a href="https://archiveofourown.org/works/id" title="ao3:id">Archive of Our Own</a>
How do I get the results of id into the output, rather than literally 'id'?
ownedbycats is online now   Reply With Quote
Old 05-26-2022, 02:29 PM   #15
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
		if 
			$publisher=='Archive of Our Own' 
		then 		
			id = select($identifiers, 'ao3');
			urls_from_identifiers('ao3:id', 1)
		fi,
results in

Code:
<a href="https://archiveofourown.org/works/id" title="ao3:id">Archive of Our Own</a>
How do I get the results of id into the output, rather than literally 'id'?
Code:
urls_from_identifiers('ao3:' & id, 1)
or
Code:
urls_from_identifiers(strcat('ao3:',  id), 1)
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Undefined sorting in composite columns ownedbycats Library Management 2 01-27-2022 06:16 AM
Sorting of composite numerical columns with formatting ownedbycats Library Management 4 06-26-2021 03:45 PM
Should composite columns appear in Grouped Searches? ownedbycats Library Management 3 02-13-2021 03:43 PM
Quickview and composite columns ownedbycats Library Management 2 12-25-2020 04:43 PM
Composite Columns: Stripping HTML from a value M. Northstar Library Management 2 08-28-2019 05:39 PM


All times are GMT -4. The time now is 08:47 PM.


MobileRead.com is a privately owned, operated and funded community.