mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Book details: When creating rules to convert identifiers to URLs allow using {id_unquoted} to avoid quoting the identifier value. Fixes #1927520 [hashtag in identifier breaks url](https://bugs.launchpad.net/calibre/+bug/1927520)
This commit is contained in:
parent
3e1fff5fcf
commit
333f42945a
@ -553,7 +553,10 @@ def urls_from_identifiers(identifiers, sort_results=False): # {{{
|
||||
formatter = EvalFormatter()
|
||||
for k, val in iteritems(identifiers):
|
||||
val = val.replace('|', ',')
|
||||
vals = {'id':unicode_type(quote(val if isinstance(val, bytes) else val.encode('utf-8')))}
|
||||
vals = {
|
||||
'id':unicode_type(quote(val if isinstance(val, bytes) else val.encode('utf-8'))),
|
||||
'id_unquoted': str(val),
|
||||
}
|
||||
items = rules.get(k) or ()
|
||||
for name, template in items:
|
||||
try:
|
||||
|
@ -118,6 +118,8 @@ class IdLinksRuleEdit(Dialog):
|
||||
title = _('Edit rule') if key else _('Create a new rule')
|
||||
Dialog.__init__(self, title=title, name='id-links-rule-editor', parent=parent)
|
||||
self.key.setText(key), self.nw.setText(name), self.template.setText(template or 'https://example.com/{id}')
|
||||
if self.size().height() < self.sizeHint().height():
|
||||
self.resize(self.sizeHint())
|
||||
|
||||
@property
|
||||
def rule(self):
|
||||
@ -135,7 +137,10 @@ class IdLinksRuleEdit(Dialog):
|
||||
self.nw = n = QLineEdit(self)
|
||||
l.addRow(_('&Name:'), n)
|
||||
la = QLabel(_(
|
||||
'The template used to create the link. The placeholder {id} in the template will be replaced with the actual identifier value.'))
|
||||
'The template used to create the link.'
|
||||
' The placeholder {0} in the template will be replaced'
|
||||
' with the actual identifier value. Use {1} to avoid the value'
|
||||
' being quoted.').format('{id}', '{id_unquoted}'))
|
||||
la.setWordWrap(True)
|
||||
l.addRow(la)
|
||||
self.template = t = QLineEdit(self)
|
||||
|
Loading…
x
Reference in New Issue
Block a user