36 Commits

Author SHA1 Message Date
Charles Haley
cd66ed4bc6 Fix problem with local variable assignment and typo in function name 2011-01-13 17:58:25 +00:00
Charles Haley
969965f7c1 New plugin architecture for formatter 2011-01-13 12:42:11 +00:00
Charles Haley
ccc0c02c67 Add arbitrary python function evaluation to formatter 2011-01-12 16:43:47 +00:00
Charles Haley
6871651ff1 Fix bug in formatter where parse errors at end of file threw an exception instead of providing the message. 2011-01-09 16:41:54 +00:00
Charles Haley
910a3f1acc Add the list_item function to the template processor, to avoid using complicated regexp to carve them out. Add it to the documentation. 2011-01-07 13:22:58 +00:00
Charles Haley
9e82bd6f23 Fix problem with formatter intepreting a missing format letter as ERROR instead of 's'. 2011-01-07 08:25:21 +00:00
Charles Haley
ae759ebd10 Fix ticket #8214 (Detect 'senseless' user input) 2011-01-06 19:35:04 +00:00
Kovid Goyal
7918f0c075 Template language: Make all column names case insensitive 2011-01-04 08:57:20 -07:00
Kovid Goyal
c483d01b45 Fix bug where composite custom columns using general_program_mode fields are not evaluated correctly when used in a template. 2011-01-03 17:27:37 -07:00
Charles Haley
fb76838874 Fix display of names in partition mode 2010-12-31 06:48:44 +00:00
Charles Haley
efd609d81e Improvements to the template processor. Document new features. 2010-12-26 12:34:52 +00:00
Kovid Goyal
ef45d613b2 ... 2010-12-25 18:18:31 -07:00
Charles Haley
e770af4d47 New formatter function, fix problems with strcat and math results, define basic formatter for usbms and formatter 2010-12-25 18:08:11 +00:00
Charles Haley
fa8aae5fc7 Add the 'template' function to the formatter. 2010-12-21 08:41:39 +00:00
Charles Haley
617fb186d2 Implement template program mode. Includes changes to the gui to make it easier to edit larger templates. 2010-12-10 12:46:12 +00:00
Charles Haley
1034e9a73d Make template formatting support numeric format specifications 2010-12-07 10:25:46 +00:00
Charles Haley
a423062483 1) Add icu capitalize
2) Fix strcmp to use icu lower
3) Add capitalize to tests
4) change formatter & title_case to use icu capitalize
5) add capitalize as a function to bulk metadata edit
6) get rid of redundant lower()s in models
2010-12-06 06:52:08 +00:00
Charles Haley
da750b1410 Some random changes:
1) added a 'count' function to the template language
2) changed the template language faq
3) made author_sort searchable
4) improved the help in calibredb create_custom_column
2010-12-02 14:07:39 +00:00
Charles Haley
8ad31bbf08 Change bulk edit and the template function titlecase to use utils.titlecase instead of str.title() 2010-10-22 12:31:56 +01:00
Charles Haley
d4f409646a 1) change author_sort tweak documentation to note that the values must be recomputed
2) change 'lookup' documentation in the template faq
2010-10-17 05:36:10 +01:00
Charles Haley
9c0ac34187 Extend functionality of template function 'lookup' 2010-10-17 05:30:09 +01:00
Charles Haley
a9e01673fd Fix template 'shorten' function to permit 0-length trailers. 2010-10-07 16:01:33 +01:00
Charles Haley
7b1df14c36 Remove escaping backslash in replacement string in formatter. 2010-10-04 08:20:34 +01:00
Charles Haley
50aae924fc Make template processing more robust (I hope) 2010-10-03 09:21:08 +01:00
Charles Haley
deddac1fdc 1) allow commas inside arguments
2) add the 'switch' function
3) update the FAQ
2010-10-02 10:48:45 +01:00
Charles Haley
dfd5048322 1) change the author sep character in plugboards to '&', because the '|' conflicts with template fields
2) permit both functions and format strings
3) Updates to the FAQ
2010-09-30 12:14:20 +01:00
Charles Haley
5aadbb2dcd 1) change plugboards to templates (pass one)
2) fix recursion detection in base.py
3) fix lack of refresh in model when editing custom fields on the GUI
4) change the name of the plugboard eval function in base.py
5) move recursion detection base code to formatter
2010-09-29 14:33:11 +01:00
Charles Haley
1cd78a56f2 Fix problem where :0>3s produced a string of all zeros for null fields.
Add a confirmation dialog to the backup pushbutton
2010-09-26 17:31:39 +01:00
Charles Haley
a11ccd8598 Added 'contains' function to templates 2010-09-24 17:20:26 +01:00
Charles Haley
25905a349c Test the 'test' function. Add 're' function and test it. 2010-09-24 13:20:26 +01:00
Charles Haley
ad69ef985a Add a 'test' function to templates. Analogous to lookup, but inserts plain text instead of a template. 2010-09-24 12:27:39 +01:00
Charles Haley
992e5c3c08 Repair damage during conflict resolution 2010-09-24 08:21:10 +01:00
Charles Haley
197e16e62a Merge from trunk 2010-09-24 08:18:20 +01:00
Kovid Goyal
91313ff3a7 Make templating language more capable 2010-09-23 20:51:05 -06:00
Charles Haley
1a782eb0ff - Some cleanups on templates.
- Make save_to_disk templates sanitize all fields except composites
2010-09-23 20:36:52 +01:00
Charles Haley
ea29f4b683 Changes:
1) complete rewrite of composite field processing
-- creation of of formatter class in utils
-- change template validator (prefs/save_template.py) to use new formatting class
-- change save_to_disk to use new formatting class
-- change Metadata class to use new formatting class
-- Check for mutually recursive composite fields
-- change caches.py to use the 'get' interface (now the right one) for composites

2) Add template validation to the base deviceconfig plugin. It checks if the display widget has a 'validate' method, and if so, it calls it.

3) Change models.py so that composite templates can be edited on the library display.
-- back out the changes that set 'editable = False'

4) Fix problem in models.py where book info view was not being updated when a field is changed on library display

5) Changed save_to_disk to permit slashes in field specifications. Did this by splitting the template after template processing. This gives us basic variable folder structures
Example: Simple example: we want the folder structure series/series_index - title. If series does not exist, then the title should be in the top folder.
Template: {series:||/}{series_index:|| - }{title}

6) Change syntax for extended templates
-- prefixes and suffixes have moved to the end of the field specification. 
Syntax: {series:|prefix value|suffix value}
You can put a standard python format specification between the : and the first |.
Either zero or two bars must be present.

7) Addition of some built-in functions to template processing. These appear in the format part.
Syntax: {title:uppercase()|prefix value|suffix value}
Functions apply to the value of the field in the format specification.
The functions available are:
-- uppercase(), lowercase(), titlecase(), capitalise()

-- ifempty(text)
If the field is empty, replace it with text.

-- shorten(from start, center string, from end)
Replace the field with a shortened version. The shortened version is found by joining the field's first 'from start' characters, the center string, and the field's last 'from end' characters.
Example: assume that the title is 'Values of beta will give rise to dom'. The field specification
{title:shorten(6,---,6)} will produce the result 'Values---to dom'

-- lookup(key if field not empty, key if field empty)
Replace the value of 'field' with the value of another field. The first field key (lookup name) is used if 'field' is not empty. The second field key is used if field is empty. This, coupled with composite fields and the change to save_to_disk above, facilitates complex variable folder trees on devices.
Example: If a book has a series, then we want the folder structure series/series index - title.fmt. If the book does not have a series, then we want the folder structure genre/author_sort/title.fmt. If the book has no genre, use 'Unknown'. To accomplish this, we:
1) create a composite field named AA containing '{series:||}/{series_index} - {title'.
2) create a composite field named BB containing '{#genre:ifempty(Unknown)}/{author_sort}/{title}
3) set the save template to '{series:lookup(AA,BB)}
2010-09-23 14:36:47 +01:00