|
|
#91 | |||
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,746
Karma: 21843110
Join Date: Dec 2008
Location: Krewerd
Device: HTC Flyer; BBMini; Sony PRS650
|
Quote:
![]() I figured (but I might have overlooked something!) Quote:
__________________
Quote:
|
|||
|
|
|
|
|
#92 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Would an enumeration type that forces inclusion of the empty string be useful? In other words, would having a column that allows [one, two, three] and the empty string be of use?
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
Enthusiast
|
|
|
|
#93 | ||
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,746
Karma: 21843110
Join Date: Dec 2008
Location: Krewerd
Device: HTC Flyer; BBMini; Sony PRS650
|
Quote:
I tried the two-column layout. It works, but it's not practical. So, I'll mis-use the boolean till there's a true enumeration field
__________________
Quote:
|
||
|
|
|
|
|
#94 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Quote:
When you create the column, you specify the comma-separated list of valid values. The true list of valid values is None + the supplied list, and for this reason you cannot provide an empty value in the list. The default value for the column is None.
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre Last edited by chaley; 12-02-2010 at 11:00 PM. Reason: I had to put None back in to make lots of things work |
|
|
|
|
|
|
#95 | ||
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,746
Karma: 21843110
Join Date: Dec 2008
Location: Krewerd
Device: HTC Flyer; BBMini; Sony PRS650
|
Quote:
__________________
Quote:
|
||
|
|
|
|
|
#96 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Question for you template-language users ...
I have a partial implementation of an 'advanced' template language. Before I submit it to kovid for review, I want a sanity check. I might be making something that no one else can use.
The overarching goal is to make the template language into a 'real' programming language, at least up to a point. In the current language, all items are constants. For example, the replacement in a switch statement is a constant; you can't replace the source with something computed, such as another field. Subgoals: 1) use as much of the existing template stuff as I can 2) make it easy to parse (efficiency) 3) support sequences of expressions (aka statements) What I have is a language where everything is a function. A constant is a function that returns itself. A name not followed by a '(' is a reference to a local variable, otherwise it is a call of a function. An example might make the above clearer. Consider the following (which actually works but is rather silly): Code:
{#enum:0>15s:'
assign(a, field('title'));
assign(b, switch(a, '[DE]', lowercase(a), $));
b
'}
The second line assigns the value of the metadata field 'title' to the local variable 'a'. The call to 'switch' in the third line shows one difference. The first variable in a function call specifies the value that the function is to operate upon. The special local variable '$' means the initial field, in this case #enum. The second parameter is the regexp that switch is to apply. The third parameter is the value that switch will return if the regexp matches. This third parameter is a call of the function lowercase(a). The default value of the switch (no regexps match) is $ (#enum). The result of the switch will be the lowercase value in the variable 'a' if it contains either a D or an E, otherwise the value in $ (#enum). The result of switch is assigned to the variable b. The last line simply names 'b', so that is its value. As it is the last line in the program, that is also the value of the program. Had this line been left out, the value of the assign (value of b) would be the result of the template. Note the trailing single quote before the } character. This quote is required as a check that the expression is in the new template language. As you can see in the example, constant strings are entered in quotes. Either single or double quotes can be used. Constants can also be numbers. In addition to the standard functions, the extended language has:
I know that I don't have looping constructs, but I don't see any need for them. Have I missed something important? Any comments?
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
#97 |
|
Creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,659
Karma: 3473290
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It would be nice to support negative indices for substr for "length from the end"
__________________
Get calibre Notice to all: I can not provide assistance with DRM removal, for legal reasons, so please do not contact me about it. |
|
|
|
|
|
#98 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Quote:
![]() The result is x[start:end]. As it makes no sense for end to be zero, I used zero to indicate x[start:]. There is no ambiguity with the start field, so no hack was required.
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
|
#99 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
The new language will be available in the next release.
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
#100 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,994
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
|
|
|
|
|
|
#101 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Example of use of the new language
As an example and a test of the new language, I have implemented the last recipe in the first post in the new template language. Results are under the spoiler.
In the process I 'improved' the language a bit. The possibility to add comments, the 'program:' keyword, use of '=' for assignment, and the print function will be available in the next release (0.7.36) Metadata: Put series into the title, using either initials or a shortened form. Strip leading articles from the series name (any) (inspired by Gary_M_Mugford) Spoiler:
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
#102 |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2594
Join Date: May 2009
Device: Kindle PW,Sony 700, Sony 950 (Daily Edition),Nook Color,iPad
|
[QUOTE=chaley;1141585]Several people are doing interesting and useful things with templates, plugboards, and composite fields. This thread is both a request that they share what they have done and a place to put the information.
Suggestions/recipes are summarized below. Don't hesitate to post corrections and useful variants. Sorry if this has been covered, I take it you would use plugboards to write the title of the book to device (sony in my case) where would you enter this information to say add series number to begining of book title? Thanks |
|
|
|
|
|
#103 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Quote:
Metadata: Show series - series index - title, with series as initials (Sony) (inspired by speakingtohe) If you want the full series name instead of the series as initials, then use the following in the template: Code:
{series}{series_index:0>2s| - | - }{title}
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
|
#104 | |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 141
Karma: 2594
Join Date: May 2009
Device: Kindle PW,Sony 700, Sony 950 (Daily Edition),Nook Color,iPad
|
Quote:
thanks |
|
|
|
|
|
|
#105 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Quote:
![]() You need to set up a plugboard (preferences -> metadata plugboards). Choose the format 'device_db', then choose the device 'PRS505' (which covers all sonys). Fill in one of the template boxes with either the line from the original recipe or the line from my post. Set the destination field to 'title'. Save the plugboard. If metadata management is set to automatic (preferences, send to device, metadata management), then the titles will be updated the next time you connect your Sony. If metadata management is set to something else, then you must resend your books.
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
![]() |
| Tags |
| custom column |
| Thread Tools | Search this Thread |
|
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 |