Thread: Custom Coloring
View Single Post
Old 07-02-2011, 06:18 AM   #84
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,461
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Followup: thinking about the 'cover' issue, I realized that I can add new code to calibre to indicate presence or absence of a cover, with no performance impact. What I cannot do is provide the path to the cover file.

I added a new template function, has_cover() that returns 'Yes' if the book has a cover, otherwise '', making it ideal for a 'test' condition. I have submitted the code for inclusion in the next release (0.8.9). Once that function is available, then the coloring code will look like
Code:
program:
first_non_empty(
	cmp(field('rating'), 5, '', 'silver', ''),
	test(field('formats'), '', 'red'),
	test(field('comments'), '', 'fuchsia'),
	test(has_cover(), '', 'fuchsia'),
	'black'
)
Also, should someone want to make a yes/no column that indicates whether or not a book has a cover, create a column made from other columns (a composite column), check the 'use checkmarks' box, then enter the following as the template.
Code:
program: ifempty(has_cover(), 'No')
chaley is offline   Reply With Quote