- improved render performance for service items with the CanSoftBreak capability

- added HTML5 doctype

bzr-revno: 1763
This commit is contained in:
Andreas Preikschat 2011-09-26 20:28:23 +02:00
commit d27a75287f
2 changed files with 17 additions and 24 deletions

View File

@ -34,8 +34,8 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, \
log = logging.getLogger(__name__)
# FIXME: Add html5 doctype. However, do not break theme gradients.
HTMLSRC = u"""
<!DOCTYPE html>
<html>
<head>
<title>OpenLP Display</title>
@ -404,7 +404,7 @@ def build_background_css(item, width, height):
background = \
u'background: ' \
u'-webkit-gradient(linear, left top, left bottom, ' \
'from(%s), to(%s))' % (theme.background_start_color,
'from(%s), to(%s)) fixed' % (theme.background_start_color,
theme.background_end_color)
elif theme.background_direction == \
BackgroundGradientType.to_string( \
@ -412,7 +412,7 @@ def build_background_css(item, width, height):
background = \
u'background: ' \
u'-webkit-gradient(linear, left top, right bottom, ' \
'from(%s), to(%s))' % (theme.background_start_color,
'from(%s), to(%s)) fixed' % (theme.background_start_color,
theme.background_end_color)
elif theme.background_direction == \
BackgroundGradientType.to_string \
@ -420,20 +420,21 @@ def build_background_css(item, width, height):
background = \
u'background: ' \
u'-webkit-gradient(linear, left bottom, right top, ' \
'from(%s), to(%s))' % (theme.background_start_color,
'from(%s), to(%s)) fixed' % (theme.background_start_color,
theme.background_end_color)
elif theme.background_direction == \
BackgroundGradientType.to_string \
(BackgroundGradientType.Vertical):
background = \
u'background: -webkit-gradient(linear, left top, ' \
u'right top, from(%s), to(%s))' % \
u'right top, from(%s), to(%s)) fixed' % \
(theme.background_start_color, theme.background_end_color)
else:
background = \
u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \
u'50%%, %s, from(%s), to(%s))' % (width, width, width,
theme.background_start_color, theme.background_end_color)
u'50%%, %s, from(%s), to(%s)) fixed' % (width, width,
width, theme.background_start_color,
theme.background_end_color)
return background
def build_lyrics_css(item, webkitvers):

View File

@ -224,14 +224,10 @@ class Renderer(object):
# Bibles
if item.is_capable(ItemCapabilities.CanWordSplit):
pages = self._paginate_slide_words(text.split(u'\n'), line_end)
else:
# Clean up line endings.
lines = self._lines_split(text)
pages = self._paginate_slide(lines, line_end)
# Songs and Custom
if item.is_capable(ItemCapabilities.CanSoftBreak) and \
len(pages) > 1 and u'[---]' in text:
pages = []
# Songs and Custom
elif item.is_capable(ItemCapabilities.CanSoftBreak):
pages = []
if u'[---]' in text:
while True:
slides = text.split(u'\n[---]\n', 2)
# If there are (at least) two occurrences of [---] we use
@ -272,6 +268,11 @@ class Renderer(object):
lines = text.strip(u'\n').split(u'\n')
pages.extend(self._paginate_slide(lines, line_end))
break
else:
# Clean up line endings.
pages = self._paginate_slide(text.split(u'\n'), line_end)
else:
pages = self._paginate_slide(text.split(u'\n'), line_end)
new_pages = []
for page in pages:
while page.endswith(u'<br>'):
@ -585,12 +586,3 @@ class Renderer(object):
# this parse we are to be wordy
line = line.replace(u'\n', u' ')
return line.split(u' ')
def _lines_split(self, text):
"""
Split the slide up by physical line
"""
# this parse we do not want to use this so remove it
text = text.replace(u'\n[---]', u'')
text = text.replace(u'[---]', u'')
return text.split(u'\n')