|
|
#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> |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,659
Karma: 28549046
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 | |
|
|
|
|
#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 |
| Create Link to External Files | RKEP71 | Sigil | 10 | 11-28-2024 07:41 PM |
| Calibre Content Server Searches Page | r_sauve | Recipes | 7 | 08-08-2016 02:27 PM |
| Glo How to create Shelves with Calibre | leftright | Kobo Reader | 2 | 10-06-2013 06:38 AM |
| ERROR: Failed to create library: Failed to create calibre library at: u'F:\\Calibre B | feenix1363 | Calibre | 1 | 05-10-2012 06:45 PM |
| Sigil: how to create a link? | robblanken | Sigil | 2 | 09-02-2011 07:18 PM |