09-18-2014, 10:30 PM | #571 | |
Connoisseur
Posts: 77
Karma: 3090
Join Date: Apr 2013
Location: California
Device: Kobo Aura One, Kobo Aura H20,Kindle PW1
|
Quote:
Also the regex was exactly what I was looking for which just proves I was correct in asking in the first place. I originally thought it was an un-modifiable field other then manually entering in something or downloading the data. I am very grateful for all your help, a couple of days ago my laptop died and then by backup was corrupted, so I lost everything I had with the exception to what I had stored in the cloud and felt that this was the best time to recreate stuff that I have been wanting to solve for a little while. So new Laptop and backup drive and calibre is at the point to where I can just sit back and enjoy it. I do have one small thing that is eluding if you wouldn't mind once again helping me with. In Metadata Plugboards I have template set up for: Epub and Any Device Source template: {title} - {series}{series_index:0>3s| [|] Destination Field: title When dealing with series it works perfectly, but when dealing with a book that is not part of a series I have a dash leftover Example: Ken Follets Book: Edge of Eternity becomes: Edge of Eternity - The Century Trilogy [03] Cottam, F. G. Book: The Lazarus Prophecy becomes: The Lazarus Prophecy - How can I get it to drop the "-" at the end of the title on a book with no series? Yet keep it for series? Thank you very much eschwartz! |
|
09-18-2014, 10:43 PM | #572 |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Use:
Code:
{title}{series:| - |}{series_index:0>3s| [|]} Everything after the ":" is a modifier. The "|stuff|stuff" are prefixes and suffixes for the parent template (in this case, series) -- as you can see, you already have one for series_index. This allows for making stuff dependent on the parent template existing. So. I simply moved the space and dash to be dependent on the series field not being empty. Last edited by eschwartz; 09-18-2014 at 10:45 PM. |
Advert | |
|
09-18-2014, 10:45 PM | #573 | ||
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
Quote:
|
||
09-19-2014, 02:11 AM | #574 | |
Grand Sorcerer
Posts: 11,747
Karma: 6997673
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
s_index = finish_formatting(field('series_index'), '.2f', ' [', ']')) |
|
09-19-2014, 06:32 AM | #575 |
null operator (he/him)
Posts: 20,598
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
If I want
Code:
if (tags:count(,) > 5) return "too many" else return "" endif Code:
{cmp(tags:count(','), 5, "", "", "too many")} |
Advert | |
|
09-19-2014, 06:36 AM | #576 | |
Zealot
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
|
Quote:
I changed formulas to stripped = re(field('series'), '^(A|The|An)\s+', ''); shortened = shorten(stripped, 8, '-' ,6); initials = re(stripped, '[\s]?([^\s]{1,3})[^\s]+(\s|$)', '\1'); But summats wrong Worlds Without End becomes WorWitEn Missing "d"? Also is it poss to have it as Wor-Wit-End Also, is it feasible to add in the code we rejigged when doing series with fractions? you had a prog to decide which formula to use to reformat the series link properly depending on size of highest number and presence of fractions :-) |
|
09-19-2014, 07:17 AM | #577 | |
Grand Sorcerer
Posts: 11,747
Karma: 6997673
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
{ fieldKey : format/function | prefix | suffix } The second is template program mode (TPM), and has the approximate syntax Code:
{ field name :'possibly nested functions'} The third is general program mode (GPM). This mode has a more "classic" program style. It is considered as one template, where the other two can be chains of templates. GPM has no restrictions on characters used. It is the most expressive of all the three. Unfortunately your example uses nested functions but does not use TPM syntax. It also uses attribute-like referencing (tags:count) which doesn't exist in the language. The equivalent in TPM is Code:
{tags:'cmp(count($, ','), 5, "", "", "too many")'} Code:
program: cmp( count( field('tags'), ','), 5, "", "", "too many") |
|
09-19-2014, 09:36 AM | #578 |
Zealot
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
|
Whilst I am asking - how would I get a column of the length of the title - I have some that have ended up massively long and I want to quickly find them and edit them :-)
|
09-19-2014, 09:50 AM | #579 |
Zealot
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
|
Actually its not handling and words 3 or less properly - loses last letter??
|
09-19-2014, 10:38 AM | #580 | ||
Grand Sorcerer
Posts: 11,747
Karma: 6997673
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
{title:strlen()} Quote:
Code:
initials = re(stripped, '[\s]?([^\s]{1,3})[^\s]*(\s|$)', '\1'); Code:
initials = re(list_re(stripped, ' ', '[\s]?([^\s]{1,3})[^\s]*(\s|$)', '\1'), ' ', '-'); |
||
09-19-2014, 11:35 AM | #581 | |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
I already know about it, though. I do use it when in general program mode. EDIT: It came true sooner than I thought. Look at the recycled s_index below. Last edited by eschwartz; 09-19-2014 at 11:54 AM. |
|
09-19-2014, 11:52 AM | #582 | |||
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
The previous template assumed only the first letter would be captured, and matched the following letters outside the capture. But it required there to be letters outside, under the assumption that any word would have at least two letters. So at least one letter at the end would not be included. hence chaley's fix. Quote:
Thanks, and thank you for all these recent extensions to template programming! They will no doubt make things easier as soon as I get the hang of them. Quote:
PHP Code:
Ah, it's easy. Just replace s_index. PHP Code:
Using the second fix, to get "Wor-Wit-End" style. Last edited by eschwartz; 09-19-2014 at 12:07 PM. Reason: remembered to use chaley's fix. |
|||
09-19-2014, 01:16 PM | #583 |
Zealot
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
|
Nearly there - somethings wrong with
#complex_series If I cange it to series_index it works, but seems to return __01.00 for even simple 1,2,3 series numbers also shows as [ [__01.00] ] Can we replace _ with space as its in program mode? |
09-19-2014, 01:30 PM | #584 | ||
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
What exactly is wrong with it? I cannot think why it wouldn't work, especially as it seemed to work before?
Quote:
Quote:
|
||
09-19-2014, 01:36 PM | #585 |
Zealot
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
|
My bad re comples_series - I had forgotten we went for a manual Y/N re complex series
I was thinking of the code https://www.mobileread.com/forums/sho...&postcount=552 To set the correct format. I thought the code before the latest tweak took care of leading spaces later on - yours adds brackets and then original adds 2 more brackets later on :-) |
Tags |
custom column, tag, tags |
|
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 |