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 11-05-2017, 06:54 PM   #1
kaoruAngel
Junior Member
kaoruAngel began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Nov 2017
Device: Android
Question Showing template-computed columns as [rating] stars isn't possible?

The Context (if you must know)
Spoiler:
I've created some custom fields, in order to be able to distinguish between the three different classes of rating judgements that matter.

For my Calibre usage, the standard `rating` field isn't worthwhile to store one's own personal ratings in, since it will also inevitably serve as the intermingled, standard dumping ground for any other rating source; so I keep that as is.

For my personally assigned ratings, I have two concrete rating fields created:
  • one for premature ratings, that, at worst, I might even dole out after a mere skimming, or based on the reputation the text already holds personally within my mind (before I've gotten to read it)
  • another for final ratings (those that I've assigned only after having read the parts of the text that I was interested in).

For some common simple display and sorting purposes, however, I use a pseudo-field: a simple template program that surfaces either the final rating (if one has been given), or the possibly void premature rating otherwise.
Code:
program: first_non_empty( field('#theFinalRatingFieldNameHere'), field('#thePrematureRatingFieldNameHere') )


The Question
Calibre seemingly doesn't try to recognize if the source of a pseudo-field's output has a special display mode already designated; and alternatively, I can't find a way to explicitly specify that this pseudo-field's column is a rating (the column type is either "ratings, shown with stars", which doesn't allow inputting a template but shows as a rating, or it's a "column built from other columns", which does allow inputting a template but doesn't get interpreted as a rating and appropriately shown with rating stars).

Am I missing something?
Attached Thumbnails
Click image for larger version

Name:	rating_field_screenshot.PNG
Views:	168
Size:	12.3 KB
ID:	159835  

Last edited by kaoruAngel; 11-05-2017 at 06:55 PM. Reason: Wrong thread icon
kaoruAngel is offline   Reply With Quote
Old 11-06-2017, 08:29 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,853
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
i dont think there is UI for it but you could probably insert it into the column definition by hand in the database, admittedly not for the faint of heart
kovidgoyal is offline   Reply With Quote
Advert
Old 11-06-2017, 08:49 AM   #3
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: 11,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
If you want to format a composite column (a computed column) then you must do the formatting yourself in the template. I see three ways to do what you want.
  1. Use column icons to show an image of stars based on the value. This would be the way to go if you want half-star images.
  2. Use something like the following:
    Code:
    program:
    # the variable 'v' contains the computed rating
    	v = 3.5;
    # verify that the value <= 5
    	v = cmp(v, 5, v, v, 5);
    # Check if the value is a fraction
    	halfstar = contains(v, '\.', 'y', '');
    # Make the value into an integer (floor)
    	v = re(v, '\..*', '');
    # Get the string with the right number of stars
    	r = cmp(v, 0, '', '', substr('★★★★★', 0, v));
    # Add the 'half' if needed
    	test(halfstar, strcat(r, '½'), r)
    The value 3.5 produces ★★★½
  3. Use a custom formatter function to compute a string containing whatever you want.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rating view number instead of stars? peekpoke Library Management 12 01-13-2018 02:19 PM
Well Everyone has on opinion and stars rating even Mrs. Bezos kennyc Reading Recommendations 6 12-21-2013 08:48 AM
Rating stars in calibre v0.8.42 atjnjk Calibre 9 03-14-2012 10:01 PM
Rating stars in the gallery view look like boxes Rheingold Calibre 3 11-21-2011 09:41 PM
Bulk edit - how to set the rating to 0 stars? highwaykind Calibre 3 02-01-2010 01:17 PM


All times are GMT -4. The time now is 06:21 AM.


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