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-29-2014, 06:05 PM   #1
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,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Lightbulb Template Generation

It would be quite useful if there were 'some things' that would generate the equivalent template code from 1) a search term and 2) a user category.

My preference would be a context menu item for Generate Template for Current Search and a Generate Template button on the User Category Editor window alongside Category Filter.

I envisage the code being presented in a text box so the user could copy to clipboard and paste into say a column icon rule or a custom column definition.

Is such a thing possible, does anyone else think it would be useful, and is anyone interested in doing it

BR
BetterRed is online now   Reply With Quote
Old 09-30-2014, 03:03 AM   #2
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Sorry, but I don't know what it is you want to do. Templates can't do searches. What is the template supposed to return?

As for user categories, templates can't use them at all. They are not part of the metadata for a book.
chaley is offline   Reply With Quote
Advert
Old 09-30-2014, 04:32 AM   #3
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,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@chaley - Imagine I do this search
Code:
pubdate:<=1922-1-1 and formats:"=PDF" and tags:"=Historical"
What I'd like to do is to give the books that meet that criteria a persistent mark using an icon. I want an icon rather than a VL or Saved Search because I want to see it in the context of all books. Also I can hide/show the icon column as and when it suits me.

I could 'invent' a tag such as 'pre1922-PDF-Historical' and apply it to all books satisfying the search, and make the icon conditional on that tag. But if I subsequently find a better format for one of the books, then I will probably delete PDF. But that wont get rid of the 'pre1922-PDF-Historical' tag so I'd still see the associated icon.

So the solution is to write a template that effectively does the search dynamically when building the book list. Then when I remove the PDF the icon will be gone immediately.

I struggle with writing templates. These days I find it really hard to wrap my head around the syntax and semantics of unfamiliar programming languages*, I lost the motivation to 'program' some years ago. Today I prefer to parse political speech, derive cliché indices, and ensure they're all singing from the same hymn sheet etc

The User Category is not dissimilar. I play around to get something I want then I say to myself but what I really want is indication in the book list that tells me a book falls within this user category. It could be an icon, or a column colour or a list of user category values. And it too would be dynamic, so if I changed the underlying data that qualified a book to appear in a given category then the book list would change accordingly. A VL or Saved Search won't suit because I want to see that a book is in a given user category within the context of seeing books that are not.

BR

*Actually I now find it hard to wrap my head around all 'programming languages', familiar or otherwise. English, Mandarin and French are far more interesting

Last edited by BetterRed; 09-30-2014 at 05:05 AM.
BetterRed is online now   Reply With Quote
Old 09-30-2014, 06:09 AM   #4
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
OK, I understand. You want a template that returns something like "yes" (or in your case an icon file name) for a book if that book would match a particular search expression.

Although this is possible to do and probably isn't intellectually difficult, it would be very tedious. It would need to understand the search syntax in all its glory (regexps, ranges, etc) and be able to translate these into an equivalent template expression. As this isn't something I would ever use, I don't want to spend the many days to build it.

FYI and to give some idea of the complexity: the template for your example would be something like
Code:
program:
# pubdate:<=1922-1-1 and formats:"=PDF" and tags:"=Historical"
test(
	and(
		strcmp(
			format_date(raw_field('pubdate'), 'yyyy-MM-dd'), 
			'1922-01-01', 
			'y', 'y', ''),
		in_list(approximate_formats(), ',', 'pdf', 'y', ''),
		in_list(field('tags'), ',', '^Historical$', 'y', '')
	),
	'yes',
	'no')
This isn't hard for a human to work out, but the translating program would need to know things like when to use field lookup vs raw_field vs like approximate_formats, how to deal with dates, and when to use anchors on the match patterns.
chaley is offline   Reply With Quote
Old 10-02-2014, 06:40 AM   #5
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
@BetterRed: out of curiosity, why not do this with the standard mechanism? It is very easy to set up a rule that implements your example, without using any template stuff at all.

Example:
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	253
Size:	46.3 KB
ID:	129165  
chaley is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Firmware Update Which generation PW do I have? freewheeling Amazon Kindle 5 12-01-2013 03:26 AM
creating template EricAriens Library Management 1 08-31-2013 02:39 PM
Help with template KALKITO Library Management 1 07-02-2012 02:54 PM
Changes in template evaluation in V0.8.43 chaley Library Management 1 03-16-2012 03:12 PM
iPod Which generation? lene1949 Apple Devices 5 10-19-2011 08:02 PM


All times are GMT -4. The time now is 02:51 AM.


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