mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 10:13:42 +02:00
IGN: Use unicode templates in Genshi
This commit is contained in:
parent
44e35caa00
commit
2f553604ab
1 changed files with 12 additions and 5 deletions
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
class Template(MarkupTemplate):
|
||||
|
||||
STYLE = '''\
|
||||
STYLE = u'''\
|
||||
.article_date {
|
||||
font-size: x-small; color: gray; font-family: monospace;
|
||||
}
|
||||
|
|
@ -29,12 +29,19 @@ class Template(MarkupTemplate):
|
|||
def generate(self, *args, **kwargs):
|
||||
if not kwargs.has_key('style'):
|
||||
kwargs['style'] = self.STYLE
|
||||
for key in kwargs.keys():
|
||||
if isinstance(kwargs[key], basestring) and not isinstance(kwargs[key], unicode):
|
||||
kwargs[key] = unicode(kwargs[key], 'utf-8', 'replace')
|
||||
for arg in args:
|
||||
if isinstance(arg, basestring) and not isinstance(arg, unicode):
|
||||
arg = unicode(arg, 'utf-8', 'replace')
|
||||
|
||||
return MarkupTemplate.generate(self, *args, **kwargs)
|
||||
|
||||
class NavBarTemplate(Template):
|
||||
|
||||
def __init__(self):
|
||||
Template.__init__(self, '''\
|
||||
Template.__init__(self, u'''\
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
|
|
@ -83,7 +90,7 @@ def generate(self, bottom, feed, art, number_of_articles_in_feed,
|
|||
class IndexTemplate(Template):
|
||||
|
||||
def __init__(self):
|
||||
Template.__init__(self, '''\
|
||||
Template.__init__(self, u'''\
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
|
|
@ -123,7 +130,7 @@ def generate(self, title, datefmt, feeds):
|
|||
class FeedTemplate(Template):
|
||||
|
||||
def __init__(self):
|
||||
Template.__init__(self, '''\
|
||||
Template.__init__(self, u'''\
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
|
|
@ -173,7 +180,7 @@ def generate(self, feed, cutoff):
|
|||
class EmbeddedContent(Template):
|
||||
|
||||
def __init__(self):
|
||||
Template.__init__(self, '''\
|
||||
Template.__init__(self, u'''\
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
|
|
|
|||
Loading…
Reference in a new issue