Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-23-2021, 07:33 AM   #1
chaley
Grumpy old git
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: 9,554
Karma: 3125810
Join Date: Jan 2010
Location: UK
Device: Reader
Template language changes

23 Feb 2021:
  • New template function list_count_matching(v, pattern, sep)
    Spoiler:
    list_count_matching(list, pattern, separator) -- interprets 'list' as a list of items separated by 'separator', returning the number of items in the list that match the regular expression 'pattern'. Aliases: list_count_matching(), count_matching()
  • New infix compare operator 'in'.
    Spoiler:
    Usage:
    Code:
    pattern_expression in value_expression
    Example:
    Code:
    program:
        if '(dragon|lizard)' in field('series') then
            'yes'
        else
            'no'
        fi
    The 'in' operator is equivalent to
    Code:
    contains(value_expression, pattern_expression, '1', '')
    The above 'if', written with 'contains', would be
    Code:
    program:
        if contains(field('series'), '(dragon|lizard)' , '1', '') then
            'yes'
        else
            'no'
        fi

22 Feb 2021
  • Add the possibility of specifying a separator in 'for' statements, used to break the string into list items.
    Spoiler:
    Syntax:
    Code:
    for <<id>> in <<value_expression>> separator <<expression>>:
    The keyword 'separator' and its associated expression are optional. Example:
    Code:
    for a in some_authors separator '&':
  • New function list_remove_duplicates()
    Spoiler:
    list_remove_duplicates(list, separator) -- return a list made by removing duplicate items in the source list. If items differ only in case, the last of them is returned. The items in source list are separated by separator, as are the items in the returned list.

20 Feb 2021
  • Fix subitems() sometimes returning empty list items.

19 Feb 2021
  • Fix 'for' not stripping leading and trailing blanks from the value assigned to the loop variable.

18 Feb 2021
  • New function set_globals()
    Spoiler:
    set_globals(id[=expression] [, id[=expression]]*) -- Sets the value of "global variables" that can be passed into the formatter. If 'id' is not defined then set the global to the value of expression if supplied, otherwise ''. See the globals() function for more information.

17 Feb 2021:
  • New function is_marked()
    Spoiler:
    is_marked() -- check whether the book is `marked` in calibre. If it is then return the value of the mark: either `true` (lower case) or the comma-separated list of named marks. Returns '' (the empty string) if the book is not marked. This function works only in the GUI.

17 Jan 2021:
  • The functions add() and multiply() can now take more than 2 arguments.
  • New function field_exists()
    Spoiler:
    field_exists(field_name) -- checks if a field (column) named field_name exists, returning '1' if so and '' if not.

3 Jan 2021:
  • New function list_split()
    Spoiler:
    list_split(list_val, sep, id_prefix) -- splits the list_val into separate values using 'sep', then assigns the values to variables named 'id_prefix_N' where N is the position of the value in the list. The first item has position 0 (zero). The function returns the last element in the list.

    Example: list_split('one, two, foo', ',', 'var') is equivalent to
    var_0 = 'one'; var_1 = 'two'; var_3 = 'foo'.

    Example: break apart and reformat a date expressed as a format and a list of values:
    Code:
    program:
    # date_string would normally be field() to fetch the value from the book
    # A 'date string' is a list with the first the desired format and the rest the values
    	date_string = 'YMD,1984,12, 01';
    	list_split(date_string, ',', 'li');
    	if li_0 == 'YMD' then
    		strcat(li_1, '-', li_2, '-', li_3)
    	elif li_0 == 'YM'  then
    		strcat(li_1, '-', li_2)
    	elif li_0 == 'Y'  then
    		li_1
    	else
    		'Invalid Format'
    	fi

22 Dec 2020
  • New function connected_device_uuid(storage_location)
    Spoiler:
    connected_device_uuid(storage_location) -- if a device is connected then return the device uuid (unique id), otherwise return the empty string. Each storage location on a device has a different uuid. The location names are 'main', 'carda' and 'cardb'. This function works only in the GUI.

19 Dec 2020
  • Added a 'for' template language statement. See also 22 Feb 2021 above.
    Spoiler:

    Code:
        for <<id>> in <<expression>>:
            <<expression_list>>
        rof
    The expression must evaluate to either a metadata field lookup key, for example 'tags or '#genre', or a comma-separated list of values. If the result is a valid lookup name then the field's value is fetched, otherwise the list is broken into its individual values. Each resulting value in the list is assigned to the variable 'id'' then the 'expression_list' is evaluated.

    Example: This template removes the first hierarchical name for each value in Genre ('#genre'), constructing a list with the new names.
    Code:
            program:
                new_tags = '';
                for i in '#genre':
                    j = re(i, '^.*?\.(.*)$', '\1');
                    new_tags = list_union(new_tags, j, ',')
                rof;
                new_tags
    If the original Genre is 'History.Military, Science Fiction.Alternate History, ReadMe' then the template returns 'Military, Alternate History, ReadMe'.

    You could use this template in calibre's 'Edit metadata in bulk -> Search & replace with 'Search for' set to 'template' to strip off the first level of the hierarchy and assign the resulting value to Genre.

    Note: the last line in the template, 'new_tags', isn't necessary in this case because 'for' returns the value of the last 'expression' in the 'expression list'.

    For completeness, note that the entire template can be replaced by the subitems() function, as in
    Code:
    program: subitems(field('#genre'), 1, 0)
    and
    Code:
    {#genre:subitems(1, 0)}

Last edited by chaley; Yesterday at 06:18 AM.
chaley is offline   Reply With Quote
Old 02-23-2021, 07:34 AM   #2
chaley
Grumpy old git
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: 9,554
Karma: 3125810
Join Date: Jan 2010
Location: UK
Device: Reader
Reserved
chaley is offline   Reply With Quote
Advert
Old 02-23-2021, 03:12 PM   #3
ownedbycats
Wizard
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.
 
Posts: 1,861
Karma: 5140624
Join Date: Oct 2018
Device: Kobo Aura HD
Perhaps this thread should be stickied?
ownedbycats is offline   Reply With Quote
Old 02-23-2021, 06:32 PM   #4
chaley
Grumpy old git
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: 9,554
Karma: 3125810
Join Date: Jan 2010
Location: UK
Device: Reader
Looks like "someone" did it.

I am not yet convinced that this thread should take up sticky space but we will see.
chaley is offline   Reply With Quote
Old 02-23-2021, 08:31 PM   #5
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 26,015
Karma: 39102633
Join Date: Aug 2009
Location: The Central Coast of California
Device: K4NT(Fixed,New Bat.), Galaxy Tab A, Kobo Aura2
Quote:
Originally Posted by chaley View Post
Looks like "someone" did it. .
Peter T did it
I think <=6 should be the Max # of stickies per forum.
theducks is offline   Reply With Quote
Advert
Old Yesterday, 04:03 AM   #6
capink
Addict
capink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipediacapink knows more than wikipedia
 
Posts: 344
Karma: 47130
Join Date: Aug 2015
Device: Kindle
I suggest removing the "Search is showing all books with some highlighted! How do I fix this?" thread from the stickies. I think/hope the issue causing this (in the Find Duplicates plugin) is fixed now. Also there is a similar thread in the main forum.
capink is offline   Reply With Quote
Old Yesterday, 04:08 AM   #7
ownedbycats
Wizard
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.
 
Posts: 1,861
Karma: 5140624
Join Date: Oct 2018
Device: Kobo Aura HD
Quote:
Originally Posted by capink View Post
I suggest removing the "Search is showing all books with some highlighted! How do I fix this?" thread from the stickies. I think/hope the issue causing this (in the Find Duplicates plugin) is fixed now. Also there is a similar thread in the main forum.
And nobody pays attention to either of them, considering the amount of threads about it...
ownedbycats is offline   Reply With Quote
Old Yesterday, 04:58 AM   #8
BetterRed
null operator
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: 16,983
Karma: 19749604
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by theducks View Post
Peter T did it
I think <=6 should be the Max # of stickies per forum.
Agreed

Quote:
Originally Posted by capink View Post
I suggest removing the "Search is showing all books with some highlighted! How do I fix this?" thread from the stickies. I think/hope the issue causing this (in the Find Duplicates plugin) is fixed now. Also there is a similar thread in the main forum.
Done

BR
BetterRed is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:03 AM.


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