Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 09-29-2014, 01:05 AM   #1
icarine
Member
icarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheese
 
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>}
But I either get this error:
Code:
calibre, version 2.2.0
ERROR: Unhandled exception: <b>TypeError</b>:Non-hexadecimal digit found
Or this error:
Code:
calibre, version 2.2.0
ERROR: Unhandled exception: <b>TypeError</b>:Odd-length string
Even if I do something simple like
Code:
<a href="search:test">test</a>
I get the same error. Is there a way to do this? What's the right URL pattern?
icarine is offline   Reply With Quote
Old 09-29-2014, 01:13 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Advert
Old 09-29-2014, 01:39 AM   #3
icarine
Member
icarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheeseicarine can extract oil from cheese
 
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')
icarine is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 01:24 PM.


MobileRead.com is a privately owned, operated and funded community.