05-24-2022, 07:43 PM | #1 |
Custom User Title
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. |
05-25-2022, 06:19 AM | #2 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
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 |
|
Advert | |
|
05-25-2022, 11:14 AM | #3 |
Custom User Title
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Thanks.
|
05-25-2022, 11:24 AM | #4 |
Grand Sorcerer
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.
|
05-25-2022, 11:33 AM | #5 |
Custom User Title
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') ) Last edited by ownedbycats; 05-25-2022 at 11:47 AM. |
Advert | |
|
05-25-2022, 11:49 AM | #6 |
Grand Sorcerer
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. |
05-25-2022, 12:53 PM | #7 |
Custom User Title
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 |
05-25-2022, 02:15 PM | #8 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Some problems:
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. |
|
05-26-2022, 06:15 AM | #9 |
Grand Sorcerer
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. |
05-26-2022, 06:36 AM | #10 |
Custom User Title
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
|
05-26-2022, 11:29 AM | #11 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
05-26-2022, 02:06 PM | #12 |
Custom User Title
Posts: 8,631
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Did I misunderstand the syntax here?
|
05-26-2022, 02:08 PM | #13 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
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. |
05-26-2022, 02:25 PM | #14 |
Custom User Title
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, Code:
<a href="https://archiveofourown.org/works/id" title="ao3:id">Archive of Our Own</a> |
05-26-2022, 02:29 PM | #15 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
urls_from_identifiers('ao3:' & id, 1) Code:
urls_from_identifiers(strcat('ao3:', id), 1) |
|
|
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 |