From 5fe54b59075c2b9da658e0ee0a14cac38c2b697a Mon Sep 17 00:00:00 2001 From: Ken Roberts Date: Tue, 7 Jun 2016 06:12:22 -0700 Subject: [PATCH] Beauty spa for the htmlbuilder --- openlp/core/lib/htmlbuilder.py | 361 +++++++++--------- .../openlp_core_lib/test_htmlbuilder.py | 361 +++++++++--------- 2 files changed, 361 insertions(+), 361 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 28976b68c..6f2fee68c 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -398,200 +398,199 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, Vertic log = logging.getLogger(__name__) HTML_SRC = Template(""" - - - -OpenLP Display - - - - - - -${html_additions} -
- -
- - -""") + function show_text_completed(){ + return (timer == null); + } + + + + + + ${html_additions} +
+ +
+ + + """) LYRICS_SRC = Template(""" -.lyricstable { - z-index: 5; - position: absolute; - display: table; - ${stable} -} -.lyricscell { - display: table-cell; - word-wrap: break-word; - -webkit-transition: opacity 0.4s ease; - ${lyrics} -} -.lyricsmain { - ${main} -} -""") + .lyricstable { + z-index: 5; + position: absolute; + display: table; + ${stable} + } + .lyricscell { + display: table-cell; + word-wrap: break-word; + -webkit-transition: opacity 0.4s ease; + ${lyrics} + } + .lyricsmain { + ${main} + } + """) FOOTER_SRC = Template(""" -left: ${left}px; -bottom: ${bottom}px; -width: ${width}px; -font-family: ${family}; -font-size: ${size}pt; -color: ${color}; -text-align: left; -white-space: ${space}; -""") + left: ${left}px; + bottom: ${bottom}px; + width: ${width}px; + font-family: ${family}; + font-size: ${size}pt; + color: ${color}; + text-align: left; + white-space: ${space}; + """) LYRICS_FORMAT_SRC = Template(""" -${justify}word-wrap: break-word; -text-align: ${align}; -vertical-align: ${valign}; -font-family: ${font}; -font-size: ${size}pt; -color: ${color}; -line-height: ${line}%; -margin: 0; -padding: 0; -padding-bottom: ${bottom}; -padding-left: ${left}px; -width: ${width}px; -height: ${height}px;${font_style}${font_weight} -""") + ${justify}word-wrap: break-word; + text-align: ${align}; + vertical-align: ${valign}; + font-family: ${font}; + font-size: ${size}pt; + color: ${color}; + line-height: ${line}%; + margin: 0; + padding: 0; + padding-bottom: ${bottom}; + padding-left: ${left}px; + width: ${width}px; + height: ${height}px;${font_style}${font_weight} + """) def build_html(item, screen, is_live, background, image=None, plugins=None): @@ -737,7 +736,7 @@ def build_lyrics_format_css(theme_data, width, height): valign = VerticalType.Names[theme_data.display_vertical_align] left_margin = (int(theme_data.font_main_outline_size) * 2) if theme_data.font_main_outline else 0 # fix tag incompatibilities - justify = '' if (theme_data.display_horizontal_align == HorizontalType.Justify) else 'white-space:pre-wrap;\n' + justify = '' if (theme_data.display_horizontal_align == HorizontalType.Justify) else ' white-space: pre-wrap;\n' padding_bottom = '0.5em' if (theme_data.display_vertical_align == VerticalType.Bottom) else '0' return LYRICS_FORMAT_SRC.substitute(justify=justify, align=align, @@ -750,8 +749,8 @@ def build_lyrics_format_css(theme_data, width, height): left=left_margin, width=width, height=height, - font_style='\nfont-style:italic;' if theme_data.font_main_italics else '', - font_weight='\nfont-weight:bold;' if theme_data.font_main_bold else '') + font_style='\n font-style: italic;' if theme_data.font_main_italics else '', + font_weight='\n font-weight: bold;' if theme_data.font_main_bold else '') def build_footer_css(item, height): diff --git a/tests/functional/openlp_core_lib/test_htmlbuilder.py b/tests/functional/openlp_core_lib/test_htmlbuilder.py index 5f385e3eb..e76faa311 100644 --- a/tests/functional/openlp_core_lib/test_htmlbuilder.py +++ b/tests/functional/openlp_core_lib/test_htmlbuilder.py @@ -14,201 +14,200 @@ from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin HTML = """ - - - -OpenLP Display - - - - - - -plugin HTML -
- -
- - -""" + function show_text_completed(){ + return (timer == null); + } + + + + + + plugin HTML +
+ +
+ + + """ BACKGROUND_CSS_RADIAL = 'background: -webkit-gradient(radial, 5 50%, 100, 5 50%, 5, from(#000000), to(#FFFFFF)) fixed' LYRICS_CSS = """ -.lyricstable { - z-index: 5; - position: absolute; - display: table; - left: 10px; top: 20px; -} -.lyricscell { - display: table-cell; - word-wrap: break-word; - -webkit-transition: opacity 0.4s ease; - lyrics_format_css -} -.lyricsmain { - text-shadow: #000000 5px 5px; -} -""" + .lyricstable { + z-index: 5; + position: absolute; + display: table; + left: 10px; top: 20px; + } + .lyricscell { + display: table-cell; + word-wrap: break-word; + -webkit-transition: opacity 0.4s ease; + lyrics_format_css + } + .lyricsmain { + text-shadow: #000000 5px 5px; + } + """ LYRICS_OUTLINE_CSS = ' -webkit-text-stroke: 0.125em #000000; -webkit-text-fill-color: #FFFFFF; ' LYRICS_FORMAT_CSS = """ -word-wrap: break-word; -text-align: justify; -vertical-align: bottom; -font-family: Arial; -font-size: 40pt; -color: #FFFFFF; -line-height: 108%; -margin: 0; -padding: 0; -padding-bottom: 0.5em; -padding-left: 2px; -width: 1580px; -height: 810px; -font-style:italic; -font-weight:bold; -""" + word-wrap: break-word; + text-align: justify; + vertical-align: bottom; + font-family: Arial; + font-size: 40pt; + color: #FFFFFF; + line-height: 108%; + margin: 0; + padding: 0; + padding-bottom: 0.5em; + padding-left: 2px; + width: 1580px; + height: 810px; + font-style: italic; + font-weight: bold; + """ FOOTER_CSS_BASE = """ -left: 10px; -bottom: 0px; -width: 1260px; -font-family: Arial; -font-size: 12pt; -color: #FFFFFF; -text-align: left; -white-space: %s; -""" + left: 10px; + bottom: 0px; + width: 1260px; + font-family: Arial; + font-size: 12pt; + color: #FFFFFF; + text-align: left; + white-space: %s; + """ FOOTER_CSS = FOOTER_CSS_BASE % ('nowrap') FOOTER_CSS_WRAP = FOOTER_CSS_BASE % ('normal') FOOTER_CSS_INVALID = '' @@ -257,6 +256,8 @@ class Htmbuilder(TestCase, TestMixin): # WHEN: Create the html. html = build_html(item, screen, is_live, background, plugins=plugins) + self.maxDiff = None + # THEN: The returned html should match. self.assertEqual(html, HTML, 'The returned html should match')