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 09-20-2020, 08:03 PM   #886
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,016
Karma: 62040591
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I have a date column, #fanficupdated. Is it possible for a template rule to compare that to the date of a matched book currently on the device and return a bool?

I'd like to display a column icon if the version of a fanfic in my library is newer than the one on the device (to remind me to re-upload it). Making a hidden composite column to tie the icon to seems best idea.

Last edited by ownedbycats; 09-23-2020 at 08:05 PM.
ownedbycats is online now   Reply With Quote
Old 10-13-2020, 07:15 PM   #887
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,016
Karma: 62040591
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
For a format_date, how would I make it return the first three numbers of the year?

Code:
{pubdate:'test($,
strcat(format_date($,'yyyy')),
'Unknown')'}
I'm trying to get this to return, for instance, 1970.1973 if the pubdate year is 1973.
ownedbycats is online now   Reply With Quote
Advert
Old 10-13-2020, 07:39 PM   #888
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,858
Karma: 7036057
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
For a format_date, how would I make it return the first three numbers of the year?

Code:
{pubdate:'test($,
strcat(format_date($,'yyyy')),
'Unknown')'}
I'm trying to get this to return, for instance, 1970.1973 if the pubdate year is 1973.
See https://www.mobileread.com/forums/sh...29#post4046729.

It seems that adding substr to the template functions might be a good idea.
chaley is offline   Reply With Quote
Old 10-29-2020, 07:54 PM   #889
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,016
Karma: 62040591
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Is there a template function that can test for "does this book have an annotation/bookmark"?
ownedbycats is online now   Reply With Quote
Old 10-30-2020, 03:33 AM   #890
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,858
Karma: 7036057
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Is there a template function that can test for "does this book have an annotation/bookmark"?
No, and I don't know whether such a thing is possible. I will look once I am able to do development again.
chaley is offline   Reply With Quote
Advert
Old 10-30-2020, 04:14 AM   #891
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,016
Karma: 62040591
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thank you. For context, I was hoping to make a psuedobool composite column.

Last edited by ownedbycats; 10-30-2020 at 04:19 AM.
ownedbycats is online now   Reply With Quote
Old 10-30-2020, 05:14 PM   #892
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,858
Karma: 7036057
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Is there a template function that can test for "does this book have an annotation/bookmark"?
Quote:
Originally Posted by chaley View Post
No, and I don't know whether such a thing is possible. I will look once I am able to do development again.
It is possible but it would be very slow requiring fetching all annotations from the database. I am not going to add it until/if/when that changes.
chaley is offline   Reply With Quote
Old 10-30-2020, 05:16 PM   #893
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,016
Karma: 62040591
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Understandable. I might make an enhancement request for some option to mark all the books with annotations.
ownedbycats is online now   Reply With Quote
Old 10-31-2020, 10:44 AM   #894
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,858
Karma: 7036057
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by chaley View Post
It is possible but it would be very slow requiring fetching all annotations from the database. I am not going to add it until/if/when that changes.
Quote:
Originally Posted by ownedbycats View Post
Understandable. I might make an enhancement request for some option to mark all the books with annotations.
After discussions with Kovid I will add a new database method to calibre that returns the number of annotations of all kinds and on all formats attached to the book. This method runs without needing to read the database tables so it is as fast as we can make it, one hopes fast enough.

I also added a template function annotation_count() that returns the count if it is > 0 else the empty string. This will work with template functions like "isempty()", "test()", "first_non_empty", etc. It will also work with numeric relationals such as "if annotation_count() ># 0 then 'foo' else 'bar' fi"
chaley is offline   Reply With Quote
Old 10-31-2020, 02:20 PM   #895
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,016
Karma: 62040591
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thank you
ownedbycats is online now   Reply With Quote
Old 11-05-2020, 01:04 PM   #896
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,016
Karma: 62040591
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:
	p = identifier_in_field(id:isbn)
	g = identifier_in_field(id:goodreads)

  if p then strcat(p)
  else 
  if g then strcat(g)
 fi
I was trying to make it show Goodreads only if the ISBN didn't exist. It didn't quite work as expected.

Click image for larger version

Name:	Oops.png
Views:	406
Size:	4.4 KB
ID:	183232

I'm still trying to figure these out.
ownedbycats is online now   Reply With Quote
Old 11-05-2020, 02:12 PM   #897
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,310
Karma: 12116851
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
	p = identifier_in_field(id:isbn)
	g = identifier_in_field(id:goodreads)

  if p then strcat(p)
  else 
  if g then strcat(g)
 fi
I was trying to make it show Goodreads only if the ISBN didn't exist. It didn't quite work as expected.

Attachment 183232

I'm still trying to figure these out.
Code:
program:
	p = identifier_in_field(id:isbn)
	g = identifier_in_field(id:goodreads)

        if p then strcat(p)
        else 
           if g then strcat(g)
           fi
        fi
At least a fi is missing
Terisa de morgan is offline   Reply With Quote
Old 11-05-2020, 02:16 PM   #898
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,858
Karma: 7036057
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
	p = identifier_in_field(id:isbn)
	g = identifier_in_field(id:goodreads)

  if p then strcat(p)
  else 
  if g then strcat(g)
 fi
I was trying to make it show Goodreads only if the ISBN didn't exist. It didn't quite work as expected.

Attachment 183232

I'm still trying to figure these out.
There are several errors in this template.
  • You need semicolons between the statements.
  • There is no function identifier_in_field. I think you mean identifier_in_list, but regardless you don't want to use it. Instead use 'select'.
  • You are missing a second fi (as Terisa de morgan said
That said, if I understand what you want to do then this template is does the job.
Code:
program:
	i = field('identifiers');
	ifempty(select(i, 'isbn'), select(i, 'goodreads'))
If you really want to use an if statement then this works.
Code:
program:
	i = field('identifiers');
	p = select(i, 'isbn');
	if p then p else select(i, 'goodreads') fi
chaley is offline   Reply With Quote
Old 11-05-2020, 07:18 PM   #899
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,016
Karma: 62040591
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
That works. I was just starting out with the two identifiers as a a test case. Eventually I want to encompass more identifiers in descending priority (e.g. if isbn or goodreads doesn't exist, check asin, then google, then url, etc...).
ownedbycats is online now   Reply With Quote
Old 11-06-2020, 06:14 AM   #900
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,858
Karma: 7036057
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
That works. I was just starting out with the two identifiers as a a test case. Eventually I want to encompass more identifiers in descending priority (e.g. if isbn or goodreads doesn't exist, check asin, then google, then url, etc...).
Then you want to use first_non_empty, in which you can list the order by priority. Example:
Code:
program:
	i = field('identifiers');
	first_non_empty(
		select(i, 'isbn'),
		select(i, 'goodreads')
# more as desired
	)
chaley is offline   Reply With Quote
Reply

Tags
custom column, tag, tags


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
custom column i need a little help shinken Calibre 3 09-15-2010 03:41 AM
Using Custom Metadata in Save Template EJvdH Calibre 1 07-02-2010 06:06 AM
Accessories Decalgirl Kindle 2 custom skin template srmalloy Amazon Kindle 6 04-09-2010 09:55 PM
Donations for Custom Recipes ddavtian Calibre 5 01-23-2010 04:54 PM
Help understanding custom recipes andersent Calibre 0 12-17-2009 02:37 PM


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


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