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-10-2023, 07:57 AM   #121
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Changed template function

10 May 2023 (in calibre 6.18)

Changed template function
  • identifier_in_list()
    Code:
    identifier_in_list(val, id_name [, found_val, not_found_val])
    treat val as a list of identifiers separated by commas. An identifier has the format id_name:value. The id_name parameter is the id_name text to search for, either id_name or id_name:regexp. The first case matches if there is any identifier matching that id_name. The second case matches if id_name matches an identifier and the regexp matches the identifier's value. If found_val and not_found_val are provided then if there is a match then return found_val, otherwise return not_found_val. If found_val and not_found_val are not provided then if there is a match then return the indentfier:value pair, otherwise the empty string ('').

Last edited by chaley; 06-21-2023 at 04:43 PM.
chaley is offline   Reply With Quote
Old 05-10-2023, 08:16 AM   #122
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: 9,521
Karma: 64500175
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Will need to change existing ones?
ownedbycats is offline   Reply With Quote
Advert
Old 05-10-2023, 08:28 AM   #123
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Will need to change existing ones?
No.
Quote:
If found_val and not_found_val are provided then if there is a match then return found_val, otherwise return not_found_val.
This is the previous behavior.

You use the new behavior if you want "id:value" when you test for an identifier's existence.

Last edited by chaley; 05-11-2023 at 06:12 AM.
chaley is offline   Reply With Quote
Old 09-17-2023, 06:19 AM   #124
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
17 Sep 2023 (in calibre 6.27)

New template function
  • format_date_field()
    Code:
    format_date_field(field_name, format_string)
    format the value in the field field_name, which must be the lookup name of date field, either standard or custom. See format_date() for the formatting codes. This function is much faster than format_date and should be used when you are formatting the value in a field (column). It can't be used for computed dates or dates in string variables. Examples::
    Code:
       format_date_field('pubdate', 'yyyy.MM.dd')
       format_date_field('#date_read', 'MMM dd, yyyy')

Last edited by chaley; 09-22-2023 at 06:31 AM.
chaley is offline   Reply With Quote
Old 10-26-2023, 10:59 AM   #125
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
26 Oct 2023 (in calibre beta 6.99)

New template functions for notes:
  • get_note()
    Code:
    get_note(field_name, field_value, plain_text)
    Fetch the note for field 'field_name' with value 'field_value'. If 'plain_text' is empty, return the note's HTML. If 'plain_text' is non-empty, return the note's plain text. If the note doesn't exist, return '' in both cases.
    Example: get_note('tags', 'Fiction', '') returns the HTML of the note attached to the tag 'Fiction'.
  • has_note()
    Code:
    has_note(field_name, field_value)
    Return '1' if the value 'field_value' in the field 'field_name' has an attached note, otherwise return ''.
    Example: has_note('tags', 'Fiction') returns '1' if the tag 'fiction' has an attached note, otherwise return ''.
chaley is offline   Reply With Quote
Advert
Old 11-13-2023, 08:18 AM   #126
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
13 Nov 2023: (in calibre 7.0)

New template function for links
  • get_link(field_name, field_value) -- fetch the link for field field_name with value field_value. If there is no attached link, return the empty string.

    Examples:
    The following returns the link attached to the tag Fiction:
    Code:
    get_link('tags', 'Fiction')
    This template makes a list of the links for all the tags associated with a book in the form value:link, ...:
    Code:
    program:
     ans = '';
     for t in $tags:
         l = get_link('tags', t);
         if l then
             ans = list_join(', ', ans, ',', t & ':' & get_link('tags', t), ',')
         fi
     rof;
     ans

Last edited by chaley; 11-29-2023 at 01:18 PM.
chaley is offline   Reply With Quote
Old 11-13-2023, 03:49 PM   #127
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: 9,521
Karma: 64500175
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thank you!
ownedbycats is offline   Reply With Quote
Old 11-19-2023, 10:50 PM   #128
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 773
Karma: 340954
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by chaley View Post
13 Nov 2023: (in calibre source)

New template function for links
  • get_link(field_name, field_value) -- fetch the link for field field_name with value field_value. If there is no attached link, return the empty string.

    Examples:
    The following returns the link attached to the tag Fiction:
    Code:
    get_link('tags', 'Fiction')
    This template makes a list of the links for all the tags associated with a book in the form value:link, ...:
    Code:
    program:
     ans = '';
     for t in $tags:
         l = get_link('tags', t);
         if l then
             ans = list_join(', ', ans, ',', t & ':' & get_link('tags', t), ',')
         fi
     rof;
     ans
Thank you for all your templates and your work with Calibre
dunhill is offline   Reply With Quote
Old 03-03-2024, 08:41 AM   #129
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
3 March 2024: (in calibre 7.7)
  • Change to get_notes() template function

    I changed the get_notes() function to return HTML with all image URLs fully expanded to use src="data". This lets the result be used in contexts other than the current calibre library, for example book jackets and book details from a different library. They also now work in tooltips, showing the images, but that is less important because a composite column containing notes probably shouldn't be showing on the book list

Last edited by chaley; 07-31-2024 at 08:08 AM.
chaley is offline   Reply With Quote
Old 03-03-2024, 05:44 PM   #130
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,989
Karma: 27620706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by chaley View Post
…because a composite column containing notes probably shouldn't be showing on the book list
If the composite column is represented in the Book list by an icon without text will the template result (i.e. the image) show as a tooltip… assuming one hasn't turned book list tooltips off?

BR
BetterRed is online now   Reply With Quote
Old 03-03-2024, 06:08 PM   #131
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BetterRed View Post
If the composite column is represented in the Book list by an icon without text will the template result (i.e. the image) show as a tooltip… assuming one hasn't turned book list tooltips off?

BR
The tooltip will display the contents of the column that has the icon. Whether that is a note depends on the composite's template.

Example: a composite with the template
Code:
program: get_note('authors', $authors, '')
and this icon rule
Click image for larger version

Name:	Clipboard02.jpg
Views:	1501
Size:	44.7 KB
ID:	206676

produces this
Click image for larger version

Name:	Clipboard01.jpg
Views:	1486
Size:	77.8 KB
ID:	206675

NB: get_note() is rather slow, which is why I said you probably shouldn't show the column in the booklist. Showing it icon-only is still showing it, as the template will be evaluated.
chaley is offline   Reply With Quote
Old 03-03-2024, 06:55 PM   #132
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,989
Karma: 27620706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by chaley View Post
. . .

NB: get_note() is rather slow, which is why I said you probably shouldn't show the column in the booklist. Showing it icon-only is still showing it, as the template will be evaluated.


Is get_note() inherently rather slow, or only when it contains uuencoded images?

BR
BetterRed is online now   Reply With Quote
Old 03-03-2024, 07:34 PM   #133
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BetterRed View Post
Is get_note() inherently rather slow, or only when it contains uuencoded images?

BR
get_note() and has_note() must query the notes database to find if a note is associated with the field (column) and field value. How fast this is depends on how much caching sqlite does with the database, and to a minor extent how many notes exist.

If there are images in a note then they also must be fetched from the notes database and converted to base64. This of course adds to the running time.

If you sort or search on the note composite then the above will happen for every book in the library. I have no idea whether some plugins will evaluate the column for all books.

I haven't noticed any particular problem with get_notes() speed on my test library, but then I don't do anything that would require evaluating that column for every book.
chaley is offline   Reply With Quote
Old 07-31-2024, 08:14 AM   #134
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Enhancement to template tester

31 July 2024 (in calibre source)

I added a button to the template evaluation results list to open the Edit metadata (single) dialog on a given book. You can view or modify the book's metadata. Changes will be shown when you close the edit metadata dialog to return to the template tester.
chaley is offline   Reply With Quote
Old 09-15-2024, 11:04 AM   #135
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,027
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Performance improvements in notes and links functions

15 Sept 2024 (in calibre source)

The performance of the template functions get_note(), has_note(), and get_link() have been improved. The improvement is especially visible when using these functions in composite columns and template searches. The amount of improvement depends on the number of items in a column. For example, when using a library with more than 10,000 authors, performance of a template search looking for authors with links improved by 20 times.

The improvement is less visible with column icon rules because these are computed when visible on the screen rather than when used in some other operation.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A few questions... (template language, mainly) Clem2605 Library Management 2 12-30-2020 04:25 AM
Template Language phossler Calibre 8 01-12-2016 05:37 PM
Help needed with template language Mamaijee Devices 12 02-19-2013 02:52 AM
Help with template language Pepin33 Calibre 8 11-11-2012 09:32 AM
Template language question BookJunkieLI Library Management 7 02-02-2012 07:55 PM


All times are GMT -4. The time now is 12:43 PM.


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