I'll be honest, I'm only looking at catalog as a crude possible replacement for Calibre Sync. (Look up story in catalog, note author & title, manually find in library dir.)
Given the limitations, and my more general lack of interest in catalog, I may never do anything with this. But here are a few notes of interest I've found:
First important note: Create Catalog's template does
not use Calibre's templating language. It uses Python's
string format system with a
fixed dictionary of possible values.
thiago.eec's changes allow for custom columns by adding the custom columns directly to that dictionary.
But, as Kovid pointed out, it's technically invalid to use '{#column}' replacements (in
format strings '#' is illegal in 'identifier'). But they work. For now. I'm sure the Python3 people will break it at some point.
Second important note: The catalog template.xhtml file is general to a Calibre install, while custom columns are library specific.
So code to allow custom columns in template.xhtml should allow for those columns to be missing in the current library.
I've identified a couple ways to do that:
- Suggested by this stackoverflow, add a 'cust' key to a defaultdict() of cust columns to use '{cust[#wordcount]}' instead of just '{#wordcount}'. Also solves '#' in identifier issue.
- Change args to defaultdict(str) and .format(**args) to .format_map(args). Still needs solution for '#' in identifier issue.