![]() |
#31 |
Plugin Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,976
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
|
|
![]() |
![]() |
![]() |
#32 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
The idea, inspired by compurandom's query, is that some custom columns exist only for searching. These can go away, replaced by a search that uses a template to compute the value. Also, searches can now also use non-metadata template functions such as formats_sizes(), booksize(), connected_device_name(), current_library_name(), etc. I am also working on "stored templates", which are basically template subprograms. These will interact well with template searches, permitting one to build a complex template to compute a value then "call" that template, with parameters if desired, from a search. Last edited by chaley; 10-03-2020 at 03:23 AM. |
|
![]() |
![]() |
Advert | |
|
![]() |
#33 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Stored templates are now in calibre source and in the 5.1.1 beta.
|
![]() |
![]() |
![]() |
#34 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,012
Karma: 500000
Join Date: Jun 2015
Device: Rocketbook, kobo aura h2o, kobo forma, kobo libra color
|
Quote:
Also, I've noticed that I can't sort one of my columns built from other columns, which makes me doubt how much caching is going on. |
|
![]() |
![]() |
![]() |
#35 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
EDIT: What I said above is misleading. The cache is initialized for a book the first time that book is referenced, either in a search or by being displayed. It is cleared when data changes for a book. Thus repeated searches using non-template field references will use the cache. Quote:
Last edited by chaley; 10-03-2020 at 11:18 AM. |
||
![]() |
![]() |
Advert | |
|
![]() |
#36 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,012
Karma: 500000
Join Date: Jun 2015
Device: Rocketbook, kobo aura h2o, kobo forma, kobo libra color
|
Ah ha! That's been irritating me ever since I changed the column template! Thanks for the hint, fixing that is a huge relief!
|
![]() |
![]() |
![]() |
#37 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,012
Karma: 500000
Join Date: Jun 2015
Device: Rocketbook, kobo aura h2o, kobo forma, kobo libra color
|
Ok, I just can't seem to get this to work in 5.2.
Quote:
Code:
{:connected_device_name()} Code:
EXCEPTION: connected_device_name: invalid storage location "" Code:
EXCEPTION: evaluate() takes 5 positional arguments but 7 were given What am I missing? |
|
![]() |
![]() |
![]() |
#38 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,012
Karma: 500000
Join Date: Jun 2015
Device: Rocketbook, kobo aura h2o, kobo forma, kobo libra color
|
Oh, and thanks very very very much for the template in search... I just saved a search that finds books with the wrong number of tags, something I've wanted for a very long time.
|
![]() |
![]() |
![]() |
#39 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Before we get into the specific questions, it is worth talking a bit about the three template program modes: Single Function Mode (SFM), Template Program Mode (TPM), and General Program Mode (GPM).
SFM was intended to be 'simple', so it hides a lot of programming language bits. For example, the value of the column is always passed as the first argument to a function included in the template. It also doesn't support the difference between variables and strings; all values are strings. Example, the following SFM template returns either the series name of the string "no series" Code:
{series:ifempty(no series)} Code:
program: ifempty(field('series'), 'no series') TPM is very close to GPM, but with oddities related to processing of {} characters and strings. Personally, I use GPM unless the template is trivial, in which case I might use TPM. I never use SFM. In fact, if I could redo the template language development I would not build SFM. Quote:
Because of the invisible argument, connected_device_name must be used in TPM or GPM templates. TPM: Code:
{:'connected_device_name('main')'} Code:
program: connected_device_name('main') Quote:
TPM: Code:
{:'booksize()'} Code:
program: booksize()
You are welcome. I imagined that given their complexity, template searches would be saved and I ensured that worked. I also think that stored templates will be used (called) from template searches, making the search easier to read and debug, and facilitating searches with small variations. |
||
![]() |
![]() |
![]() |
#40 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,012
Karma: 500000
Join Date: Jun 2015
Device: Rocketbook, kobo aura h2o, kobo forma, kobo libra color
|
Ok, that was extremely helpful. Looking at https://manual.calibre-ebook.com/template_lang.html I coudln't figure it out, because that whole page is written for SFM and I've had a hard time finding any documentation of the other two other than a few lines of examples that I coudln't make sense of.
I feel like the above page should have most of your above message either inserted at the top or right after the "advanced formatting" heading. |
![]() |
![]() |
![]() |
#41 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,012
Karma: 500000
Join Date: Jun 2015
Device: Rocketbook, kobo aura h2o, kobo forma, kobo libra color
|
And I do think SFM is useful -- it's significantly shorter in the context of just pulling tags and doing minor changes to format them, like in plugboard. But now that the other two are more clear to me, I'll probably use them for everything else.
|
![]() |
![]() |
![]() |
#42 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Some benefits: it would get rid of the confusion around nested functions. It would normalize specifying arguments to functions. It would remove the restriction on zero-parameter functions. It would make escaping commas and quotes more rational. It would make much more of the template language available by default. The cost: adding '$' almost everywhere and adding quotes in some places. I have looked at whether I could automatically convert SFM templates to TPM templates. I think I could, but it is certain that in some cases the conversion would fail. Then what? Confusing millions of users is seldom a good idea so (for the moment at least) I am not going there. Another example: we just went through this calculation with the soon-to-be-released feature combining small tag browser groups together when using grouping by first letter. My initial take was "Oh no, we can't set a default that changes calibre's behavior." My second take was "If we set a default that might change behavior then a) people will know about the feature (discoverability), and b) it is easy to revert in Preferences." Kovid asked about and I ended up choosing the second, setting the threshold to 5, hoping that we won't see too many knives. |
|
![]() |
![]() |
![]() |
#43 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,012
Karma: 500000
Join Date: Jun 2015
Device: Rocketbook, kobo aura h2o, kobo forma, kobo libra color
|
Quote:
I wish I could set the subcategorization scheme differently on, say, tags vs. saved searches. Finding a threshold number that is a good compromise between all of them is hard. |
|
![]() |
![]() |
![]() |
#44 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
In Preferences / Look & feel / Tag browser you can choose not to categorize some items. If that isn't sufficient, what are you suggesting? Are you looking to "partition" some and use "first letter" on others?
|
![]() |
![]() |
![]() |
#45 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,012
Karma: 500000
Join Date: Jun 2015
Device: Rocketbook, kobo aura h2o, kobo forma, kobo libra color
|
Quote:
Yes, maybe? I don't remember seeing the "dont parittion" setting before, maybe that helps. It's one of those things where I can't say, but I know it when I see it. More playing needed in time. And it sounds like there's a new setting where I'll play with it more. Actually, some categories I'd like to partition into roughly 30 partitions, and others I'd like to partition by first letter (which gives about 30 partitions anyway). And one or two are already heirarchal and small and don't need to be partitioned at all. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple same book on device: which search expression? | un_pogaz | Library Management | 3 | 12-29-2018 11:50 AM |
Aura Can't search bookstore on my device | MV89 | Kobo Reader | 9 | 11-29-2013 05:21 PM |
Search for Books on Device | random43743 | Calibre | 3 | 04-23-2011 10:44 AM |
search for books not on device | alansplace | Calibre | 2 | 01-05-2011 01:07 PM |
Search restriction bug when device is plugged in | Manichean | Calibre | 6 | 09-11-2010 04:52 PM |