Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 03-17-2025, 12:06 PM   #16
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 1,006
Karma: 2003162
Join Date: Jun 2011
Device: PC, t1, t2, t3, Clara BW, Clara HD, Libra 2, Libra Color, Nxtpaper 11
Quote:
Originally Posted by Terisa de morgan View Post
YFor me, I'm using only title or author because they add an icon to the column.
No offense, but is there some reason why you do not use column coloring? It seems to me somehow easier.

Quote:
Originally Posted by Terisa de morgan View Post
You can add author For me, I'm using only title or author because they add an icon to the column. About nil variable... no idea.
I think only the true calibre gurus will be able to answer this (not for us mortals)
What I meant is this: when our template code is parsed and it evolves into a not-situation (no non-ASCII code, or no title present), then the remainder of the template code on the same code line is not further processed, and immediately the next line is processed. So when the IF statement is FALSE, any ELSE statement (when present) is executed.
I noticed this behavior when I made a mistake in the IF part and it was not noticed until I had a title which did happened to have a non-ASCII character and only then triggered the formatter on the error.

Last edited by DrChiper; 03-17-2025 at 12:10 PM.
DrChiper is offline   Reply With Quote
Old 03-17-2025, 12:38 PM   #17
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,592
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by DrChiper View Post
No offense, but is there some reason why you do not use column coloring? It seems to me somehow easier.
No offense taken. I have A LOT of column coloring, for different conditions, so the icons are more visible.


Quote:
Originally Posted by DrChiper View Post
I think only the true calibre gurus will be able to answer this (not for us mortals)
I agree

Quote:
Originally Posted by DrChiper View Post
What I meant is this: when our template code is parsed and it evolves into a not-situation (no non-ASCII code, or no title present), then the remainder of the template code on the same code line is not further processed, and immediately the next line is processed. So when the IF statement is FALSE, any ELSE statement (when present) is executed.

I noticed this behavior when I made a mistake in the IF part and it was not noticed until I had a title which did happened to have a non-ASCII character and only then triggered the formatter on the error.
So, the template language has a short-circuit evaluation. Glad to know (I declare myself guilty of assuming this behavior, and have coded based on that).
Terisa de morgan is offline   Reply With Quote
Old 03-17-2025, 12:50 PM   #18
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,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by DrChiper View Post
The reason I didn't use intermediate vars is because I noticed that the formatter stops processing/evaluating in case of a nil situation, so this seems to be fastest way to process. But as always, correct me if I'm wrong
This is called "shortcutting". If the formatter can determine that a "then" or "else" clause cannot be evaluated then it skips it. The same thing happens with "and" and "or" expressions. For example, given the expression
Code:
'1' || print('foo')
will never print 'foo' because the result of the || is true no matter what the right-hand side does. On the other hand
Code:
'1' && print('foo')
will always print 'foo' because both the left-hand and the right-hand must be true for the expression to be true.
Quote:
Code:
program:
	if (field('title')!=transliterate(field('title')))
	then
		if (field('#subtitle')!=transliterate(field('#subtitle')))
		then
			'true1, true2'
		else
			'true1'
		fi
	else
		if (field('#subtitle')!=transliterate(field('#subtitle')))
		then
			'true2'
		else
			'false'
		fi
	fi
It returns true1 for title, true2 for subtitle, or false when neither contains non-ASCII chars.
FWIW and perhaps doing premature optimization: this will be a bit faster because a) local variables are faster than field lookups, and b) switch_if is faster than a series of ifs.
Code:
program:
# These two lines depend on evaluation being left to right so the
# variable is set before use.
	title_neq = (t = $title) != transliterate(t);
	authors_neq = (a = $authors) != transliterate(a);

# This code works because given two booleans the "truth table" has four entries.
# The order of evaluation is important. As it is we can avoid extra tests because
# if the first test isn't true then one or both of title_neq and authors_neq 
# must be false. That is why the second and third line don't need to check the
# other variable. The switch_if function does shortcutting.

	switch_if(
		title_neq && authors_neq, 'true1, true2',
		title_neq, 'true1',
		authors_neq, 'true2',
		'false')
The switch_if's arguments can be reordered if one pathway, probably resulting in 'false', is the most common. For example:
Code:
program:
	title_neq = (t = $title) != transliterate(t);
	authors_neq = (a = $authors) != transliterate(a);

	switch_if(
# True if both are false
		!(title_neq || authors_neq), 'false',
# True if both are true
		title_neq && authors_neq, 'true1, true2',
# Here, one but not both of title_neq and authors_neq is true.
		title_neq, 'true1',
# title_neq was false so authors_neq must be true.
		'true2')
chaley is offline   Reply With Quote
Old 03-17-2025, 01:44 PM   #19
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 1,006
Karma: 2003162
Join Date: Jun 2011
Device: PC, t1, t2, t3, Clara BW, Clara HD, Libra 2, Libra Color, Nxtpaper 11
Quote:
Originally Posted by Terisa de morgan View Post
No offense taken. I have A LOT of column coloring, for different conditions, so the icons are more visible.
Must be a colorful experience. Now to remember what all those colors mean ...
(I only use 3 and have still problems to remember them...)
DrChiper is offline   Reply With Quote
Old 03-17-2025, 02:13 PM   #20
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 1,006
Karma: 2003162
Join Date: Jun 2011
Device: PC, t1, t2, t3, Clara BW, Clara HD, Libra 2, Libra Color, Nxtpaper 11
Quote:
Originally Posted by chaley View Post
This is called "shortcutting".
Right. I knew its behavior, but can't remember whether I have heard this name before.

Quote:
Originally Posted by chaley View Post
FWIW and perhaps doing premature optimization: this will be a bit faster because
  1. a) local variables are faster than field lookups, and
  2. b) switch_if is faster than a series of ifs.
Good to know. I used to use local variables but was not sure whether they were to be preferred within calibre or not.

Quote:
Originally Posted by chaley View Post
Code:
	switch_if(
		title_neq && authors_neq, 'true1, true2',
		title_neq, 'true1',
		authors_neq, 'true2',
		'false')
The good old "WITH" statement Yes, I was looking to something similar, but was to lazy to RTFM (I do just occasionally some small coding effort within calibre, when the need arises that is)

Well the Template Catalog Plugin seems interesting (I had indeed asked myself how to control all those templates defined at various places) but this might help a lot.

Perhaps now a description about the do's and don't's of template creation, anybody?
DrChiper is offline   Reply With Quote
Old 03-17-2025, 02:24 PM   #21
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,592
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by DrChiper View Post
Must be a colorful experience. Now to remember what all those colors mean ...
(I only use 3 and have still problems to remember them...)
Yeeees, you have nailed it....
Terisa de morgan is offline   Reply With Quote
Old 03-17-2025, 07:32 PM   #22
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,591
Karma: 7463599
Join Date: Sep 2020
Device: none
Quote:
Originally Posted by BetterRed View Post
If I export the icon rules from Look and Feel I can see the column to which the icon is attached e.g.



I cannot see that column name in Template Category list or in the Edit/Save dialogue.

Could the name if the column to which the icon is attached be incorporated into the Template Name e.g.… rather than "From column_icon_rules: Rule 1" something like this "authors: Rule 1".

And something similar for column colour templates.

BR
Thanks for your recommendation, BR. I have uploaded version 1.3 which hopefully meets your suggestion.

I have also adjusted some custom icons that were not properly referenced, hope you folks like it.
Comfy.n is online now   Reply With Quote
Old 03-18-2025, 04:49 AM   #23
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: 21,613
Karma: 29710338
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Comfy.n View Post
Thanks for your recommendation, BR.
I have uploaded version 1.3 which hopefully meets your suggestion.

I have also adjusted some custom icons that were not properly referenced, hope you folks like it.
You also clobbered many of my custom keyboard shortcuts - see attachment.

Plugin removed, they seem to be back.

Added: Manage Categories is a core calibre feature, IMO we don't need another one

Click image for larger version

Name:	Screenshot 2025-03-18 195652.jpg
Views:	75
Size:	15.2 KB
ID:	214421

BR
Attached Files
File Type: txt Template Cat - WTF.txt (6.4 KB, 26 views)

Last edited by BetterRed; 03-18-2025 at 05:00 AM. Reason: Added:
BetterRed is offline   Reply With Quote
Old 03-18-2025, 12:46 PM   #24
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,591
Karma: 7463599
Join Date: Sep 2020
Device: none
Quote:
Originally Posted by BetterRed View Post
You also clobbered many of my custom keyboard shortcuts - see attachment.

Plugin removed, they seem to be back.

Added: Manage Categories is a core calibre feature, IMO we don't need another one

Attachment 214421

BR
Fixed, sorry for that. Now I have set the plugin to register just one empty shortcut for main dialog that users may customize. Tab and space can be used to navigate through buttons as usual.
Comfy.n is online now   Reply With Quote
Old 03-18-2025, 05:39 PM   #25
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,592
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Is still necessary to uninstall the previous version or we can just add it now?
Terisa de morgan is offline   Reply With Quote
Old 03-18-2025, 05:48 PM   #26
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,591
Karma: 7463599
Join Date: Sep 2020
Device: none
Quote:
Originally Posted by Terisa de morgan View Post
Is still necessary to uninstall the previous version or we can just add it now?
On a quick test I made by installing the previous version, then installing the latest one, I saw the shortcut I had set manually for this new version take effect. So I think you may safely install over previous version without uninstalling it.
Comfy.n is online now   Reply With Quote
Old 03-18-2025, 11:16 PM   #27
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,591
Karma: 7463599
Join Date: Sep 2020
Device: none
Version 1.5 - fixes an issue where description info wouldn't refresh

Last edited by Comfy.n; 03-18-2025 at 11:18 PM.
Comfy.n is online now   Reply With Quote
Old 03-22-2025, 06:12 AM   #28
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,591
Karma: 7463599
Join Date: Sep 2020
Device: none
Uploaded version 2.0!
  • Catalog can be exported as .MD (Markdown format), which makes it easier to convert catalog to other formats using Calibre. I recommend .docx!
  • Five backup copies are kept. Details on first post, "Latest updates" section!
Comfy.n is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Noosfere_util, a companion plugin to noosfere DB lrpirlet Plugins 2 08-18-2022 03:15 PM
[GUI Plugin] Manga plugin mastertea Plugins 6 01-06-2022 02:43 AM
[GUI Plugin] Save Virtual Libraries To Column (GUI) chaley Plugins 14 04-04-2021 05:25 AM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 12:27 PM


All times are GMT -4. The time now is 09:19 AM.


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