09-29-2014, 01:05 AM | #1 |
Member
Posts: 13
Karma: 1034
Join Date: Mar 2010
Location: NC
Device: PB 360
|
Create link that searches in Calibre
I love how you can click on a tag in book details and search Calibre for that tag. I'm trying to create a column template that does the same thing for a custom column.
I tried a column template like: Code:
{#genre:|<a href='search:#genre:"=|"'>}{#genre:||</a>} Code:
calibre, version 2.2.0 ERROR: Unhandled exception: <b>TypeError</b>:Non-hexadecimal digit found Code:
calibre, version 2.2.0 ERROR: Unhandled exception: <b>TypeError</b>:Odd-length string Code:
<a href="search:test">test</a> |
09-29-2014, 01:13 AM | #2 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The part after search: has to be hex-encoded. So if you want the search to be:
search:tags:text it becomes: search:746167733a74657874 I dont think the template language has a utility function to hex-encode strings, you could ask chaley if he is willing to add one or you could create your own in general program mode. |
Advert | |
|
09-29-2014, 01:39 AM | #3 |
Member
Posts: 13
Karma: 1034
Join Date: Mar 2010
Location: NC
Device: PB 360
|
Thanks for your help! I got this working by adding a custom template function:
Code:
def evaluate(self, formatter, kwargs, mi, locals, value, search_term): search = '%s:"=%s"' % (search_term, value.replace('"', '\\"')) return search.encode('hex') |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre Content Server Searches Page | r_sauve | Recipes | 7 | 08-08-2016 01:27 PM |
Create Link to External Files | RKEP71 | Sigil | 8 | 09-26-2014 11:36 PM |
Glo How to create Shelves with Calibre | leftright | Kobo Reader | 2 | 10-06-2013 05:38 AM |
ERROR: Failed to create library: Failed to create calibre library at: u'F:\\Calibre B | feenix1363 | Calibre | 1 | 05-10-2012 05:45 PM |
Sigil: how to create a link? | robblanken | Sigil | 2 | 09-02-2011 06:18 PM |