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)}
1) make get_metadata return an unverified list of formats. Avoids a file system operation per format
2) enhancement request #2845
3) permit composite fields as search/replace source fields.