← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol/openlp/render into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol/openlp/render into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #856296 in OpenLP: "Improve performance of song loading for Preview/Live"
  https://bugs.launchpad.net/openlp/+bug/856296

For more details, see:
https://code.launchpad.net/~googol/openlp/render/+merge/77023

Hello,
1) Improved render performance for service items with the CanSoftBreak capability.
The code which took care about [---] is also able to process text without [---], thus we do not have to process the text (with removed [---]) and then process it again (when we need to break at [---]). Instead we just process the text (no matter if it contains [---] or not).

The improvement is small...

2) I added the HTML5 doctype, but I had to add the "fixed" to keep gradients working.
-- 
https://code.launchpad.net/~googol/openlp/render/+merge/77023
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/render into lp:openlp.
=== modified file 'openlp/core/lib/htmlbuilder.py'
--- openlp/core/lib/htmlbuilder.py	2011-09-16 17:23:39 +0000
+++ openlp/core/lib/htmlbuilder.py	2011-09-26 17:24:34 +0000
@@ -34,8 +34,8 @@
 
 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 @@
                 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 @@
                 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 @@
                 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):

=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py	2011-09-20 15:50:43 +0000
+++ openlp/core/lib/renderer.py	2011-09-26 17:24:34 +0000
@@ -224,14 +224,10 @@
         # 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 @@
                         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 @@
         # 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')


Follow ups