|  10-23-2024, 10:41 AM | #151 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | |
|   |   | 
|  10-23-2024, 11:48 AM | #152 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Quote: 
 Another example: Code: program: if '^science' inlist_field '#genre' then 'yes' else 'no' fi | |
|   |   | 
| Advert | |
|  | 
|  10-23-2024, 11:58 AM | #153 | 
| Custom User Title            Posts: 11,347 Karma: 79528341 Join Date: Oct 2018 Location: Canada Device: Kobo Libra H2O, formerly Aura HD | 
			
			Ah, I was looking in the function reference. It works when I tried it.
		 | 
|   |   | 
|  10-23-2024, 12:08 PM | #154 | 
| Custom User Title            Posts: 11,347 Karma: 79528341 Join Date: Oct 2018 Location: Canada Device: Kobo Libra H2O, formerly Aura HD | 
			
			Does inlist_field only work for strings? e.g.: Code: program:
	readgoal = strcat('readinggoal:', format_date(today(), 'yyyy'));
	if
		readgoal inlist_field '#admintags' | 
|   |   | 
|  10-23-2024, 12:12 PM | #155 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Quote: 
 EDIT 2: the changes to the syntax highlighter are now in calibre source. Last edited by chaley; 10-23-2024 at 05:46 PM. Reason: Removed edit 1 -- identifiers now works in the same way as inlist | |
|   |   | 
| Advert | |
|  | 
|  10-28-2024, 11:02 AM | #156 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | 
			
			28 Oct 2024 (in calibre 7.21) 
 Last edited by chaley; 11-21-2024 at 10:14 AM. | 
|   |   | 
|  10-28-2024, 01:06 PM | #157 | 
| Wizard            Posts: 1,291 Karma: 1428263 Join Date: Dec 2016 Location: Goiânia - Brazil Device: iPad, Kindle Paperwhite, Kindle Oasis | 
			
			Nice. Even simpler. Now I can find all authors without a note like this: Code: not template:"""program:
	if $authors in has_note('authors', '') then
		'1'
	else
		 ''
	fi;#@#:t:1""" | 
|   |   | 
|  10-28-2024, 03:11 PM | #158 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Quote: 
 It will also be at least 10 times slower than the template I posted in the other thread. Perhaps as much as 50 times slower. Of course, this only matters if you have lots of books. This template uses the new has_note() to find books where 1 or more authors don't have a note. It works by returning '1' if all authors for a book have notes, otherwise ''. It will be slightly faster than your template, but nowhere near as fast as the python template. Code: program:
	if list_count(has_note('authors', ''), '&') ==# list_count_field('authors') then
		return '1'
	fi;
	'' | |
|   |   | 
|  10-28-2024, 03:24 PM | #159 | 
| Wizard            Posts: 1,291 Karma: 1428263 Join Date: Dec 2016 Location: Goiânia - Brazil Device: iPad, Kindle Paperwhite, Kindle Oasis | 
			
			Oh, I see my mistake now. I'll leave the python template, then. When using my template, I do think the first time was slow, then other times were fast. I guess it's the work of the cache in action. ________________________ EDIT: I decided to check the difference between the two templates (mine and yours, but not the python one). It seems to find the same results, even if only one author has a note. Then, looking again at the code, I notice it does work: Example: If i have a book with two authors (AuthorA and AuthorB), and only have notes for AuthorA. $authors = 'AuthorA & AuthorB' has_note('authors', '') = 'AuthorA' Now, the comparison if $authors in has_note('authors', '') will return False, as intended. But I'm definitely staying with the python template.   Last edited by thiago.eec; 10-28-2024 at 04:11 PM. | 
|   |   | 
|  02-12-2025, 12:33 PM | #160 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | 
				
				New template functions
			 
			
			12 Feb 2025 - (in calibre 7.26) 
 Last edited by chaley; 02-16-2025 at 06:56 AM. | 
|   |   | 
|  02-12-2025, 02:41 PM | #161 | 
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | 
			
			Interesting updates, thank you! I noticed that running: Code: program: make_url_extended('https', 'en.wikipedia.org', '/w/index.php', 'search', field('author'))on Template tester (good link): https://en.wikipedia.org/w/index.php...B2+Machiavelli on new Template dialog for custom search: https://en.wikipedia.org/w/index.php...%2BMachiavelli   | 
|   |   | 
|  02-12-2025, 03:25 PM | #162 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Quote: 
 The problem is that the L&F / Book details dialog *knows* it is for authors only, and in fact doesn't even have the rest of the metadata. Historically, because L&F / Book details knows it is for authors, to simplify things for the expected use case the author is URL-encoded before it gets to the template. Thas is why the template Code: https://www.wikipedia.org/w/index.php?search={author}If you want to use make_url_extended() there then you must use the variant where you control whether the query value is encoded (again) during URL construction. Code: program:
	qs = query_string('search', $author, 2);
	make_url_extended('https', 'wikepedia.com', '/w/index.php', qs)This discrepency is why the new custom column link generation feature offers the item value unencoded, URL-encoded with '+' for spaces, and URL-encoded with %20 for spaces. Bottom line: you can't use the same template in L&F/ BD as you use in the new custom column web link feature. | |
|   |   | 
|  02-12-2025, 03:26 PM | #163 | |
| Custom User Title            Posts: 11,347 Karma: 79528341 Join Date: Oct 2018 Location: Canada Device: Kobo Libra H2O, formerly Aura HD | Quote: EDIT: Explain above. | |
|   |   | 
|  02-12-2025, 03:28 PM | #164 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | |
|   |   | 
|  02-12-2025, 03:33 PM | #165 | 
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | 
			
			At the moment I'm trying to figure how a deepseek query could be made using just a url. Not sure it's possible. :\ This add-on works fine on browser context menu: https://addons.mozilla.org/en-US/fir.../ask-deepseek/ Spoiler: 
 Last edited by Comfy.n; 02-12-2025 at 03:36 PM. | 
|   |   | 
|  | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| A few questions... (template language, mainly) | Clem2605 | Library Management | 2 | 12-30-2020 03:25 AM | 
| Template Language | phossler | Calibre | 8 | 01-12-2016 04:37 PM | 
| Help needed with template language | Mamaijee | Devices | 12 | 02-19-2013 01:52 AM | 
| Help with template language | Pepin33 | Calibre | 8 | 11-11-2012 08:32 AM | 
| Template language question | BookJunkieLI | Library Management | 7 | 02-02-2012 06:55 PM |