- added doctype to html

- added encoding to html
- changed <br /> to <br>
- removed obsolete language attribute
This commit is contained in:
Andreas Preikschat 2011-07-16 11:00:30 +02:00
parent 69b0f264d0
commit 47e43404aa
7 changed files with 44 additions and 23 deletions

View File

@ -202,7 +202,7 @@ def clean_tags(text):
""" """
Remove Tags from text for display Remove Tags from text for display
""" """
text = text.replace(u'<br />', u'\n') text = text.replace(u'<br>', u'\n')
text = text.replace(u'{br}', u'\n') text = text.replace(u'{br}', u'\n')
text = text.replace(u'&nbsp;', u' ') text = text.replace(u'&nbsp;', u' ')
for tag in DisplayTags.get_html_tags(): for tag in DisplayTags.get_html_tags():

View File

@ -111,7 +111,7 @@ class DisplayTags(object):
u'start html': u'<span style="text-decoration: underline;">', u'start html': u'<span style="text-decoration: underline;">',
u'end tag': u'{/u}', u'end html': u'</span>', u'protected': True}) u'end tag': u'{/u}', u'end html': u'</span>', u'protected': True})
base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Break'), base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Break'),
u'start tag': u'{br}', u'start html': u'<br />', u'end tag': u'', u'start tag': u'{br}', u'start html': u'<br>', u'end tag': u'',
u'end html': u'', u'protected': True}) u'end html': u'', u'protected': True})
DisplayTags.add_html_tags(base_tags) DisplayTags.add_html_tags(base_tags)

View File

@ -35,8 +35,10 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, \
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
HTMLSRC = u""" HTMLSRC = u"""
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8">
<title>OpenLP Display</title> <title>OpenLP Display</title>
<style> <style>
*{ *{
@ -93,7 +95,7 @@ sup {
top:-0.3em; top:-0.3em;
} }
</style> </style>
<script language="javascript"> <script>
var timer = null; var timer = null;
var video_timer = null; var video_timer = null;
var current_video = '1'; var current_video = '1';
@ -317,10 +319,10 @@ sup {
%s %s
<div id="footer" class="footer"></div> <div id="footer" class="footer"></div>
<div id="black" class="size"></div> <div id="black" class="size"></div>
<div id="alert" style="visibility:hidden;"></div> <div id="alert" style="visibility:hidden"></div>
</body> </body>
</html> </html>
""" """
def build_html(item, screen, alert, islive, background, image=None): def build_html(item, screen, alert, islive, background, image=None):
""" """

View File

@ -46,6 +46,28 @@ VERSE = u'The Lord said to {r}Noah{/r}: \n' \
'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n' 'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n'
FOOTER = [u'Arky Arky (Unknown)', u'Public Domain', u'CCLI 123456'] FOOTER = [u'Arky Arky (Unknown)', u'Public Domain', u'CCLI 123456']
HTML_START = u"""
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
*{
margin: 0;
padding: 0;
border: 0;
}
#main {
position: absolute;
top: 0px;
%s %s
}
</style>
</head>
<body>
<div id="main">
"""
HTML_END = u'</div></body></html>' HTML_END = u'</div></body></html>'
class Renderer(object): class Renderer(object):
@ -219,7 +241,7 @@ class Renderer(object):
""" """
log.debug(u'format slide') log.debug(u'format slide')
# Add line endings after each line of text used for bibles. # Add line endings after each line of text used for bibles.
line_end = u'<br />' line_end = u'<br>'
if item.is_capable(ItemCapabilities.NoLineBreaks): if item.is_capable(ItemCapabilities.NoLineBreaks):
line_end = u' ' line_end = u' '
# Bibles # Bibles
@ -240,8 +262,8 @@ class Renderer(object):
pages.extend(self._paginate_slide(lines, line_end)) pages.extend(self._paginate_slide(lines, line_end))
new_pages = [] new_pages = []
for page in pages: for page in pages:
while page.endswith(u'<br />'): while page.endswith(u'<br>'):
page = page[:-6] page = page[:-4]
new_pages.append(page) new_pages.append(page)
return new_pages return new_pages
@ -310,10 +332,7 @@ class Renderer(object):
self.web.resize(self.page_width, self.page_height) self.web.resize(self.page_width, self.page_height)
self.web_frame = self.web.page().mainFrame() self.web_frame = self.web.page().mainFrame()
# Adjust width and height to account for shadow. outline done in css # Adjust width and height to account for shadow. outline done in css
self.page_shell = u'<html><head><style>' \ self.page_shell = HTML_START % \
u'*{margin: 0; padding: 0; border: 0;} '\
u'#main {position:absolute; top:0px; %s %s}</style></head><body>' \
u'<div id="main">' % \
(build_lyrics_format_css(self.theme_data, self.page_width, (build_lyrics_format_css(self.theme_data, self.page_width,
self.page_height), build_lyrics_outline_css(self.theme_data)) self.page_height), build_lyrics_outline_css(self.theme_data))
@ -326,13 +345,13 @@ class Renderer(object):
The text to be fitted on the slide split into lines. The text to be fitted on the slide split into lines.
``line_end`` ``line_end``
The text added after each line. Either ``u' '`` or ``u'<br />``. The text added after each line. Either ``u' '`` or ``u'<br>``.
""" """
log.debug(u'_paginate_slide - Start') log.debug(u'_paginate_slide - Start')
formatted = [] formatted = []
previous_html = u'' previous_html = u''
previous_raw = u'' previous_raw = u''
separator = u'<br />' separator = u'<br>'
html_lines = map(expand_tags, lines) html_lines = map(expand_tags, lines)
html = self.page_shell + separator.join(html_lines) + HTML_END html = self.page_shell + separator.join(html_lines) + HTML_END
self.web.setHtml(html) self.web.setHtml(html)
@ -357,7 +376,7 @@ class Renderer(object):
The words to be fitted on the slide split into lines. The words to be fitted on the slide split into lines.
``line_end`` ``line_end``
The text added after each line. Either ``u' '`` or ``u'<br />``. The text added after each line. Either ``u' '`` or ``u'<br>``.
This is needed for bibles. This is needed for bibles.
""" """
log.debug(u'_paginate_slide_words - Start') log.debug(u'_paginate_slide_words - Start')
@ -434,12 +453,12 @@ class Renderer(object):
using the binary chop. The elements can contain display tags. using the binary chop. The elements can contain display tags.
``separator`` ``separator``
The separator for the elements. For lines this is ``u'<br />'`` and The separator for the elements. For lines this is ``u'<br>'`` and
for words this is ``u' '``. for words this is ``u' '``.
``line_end`` ``line_end``
The text added after each "element line". Either ``u' '`` or The text added after each "element line". Either ``u' '`` or
``u'<br />``. This is needed for bibles. ``u'<br>``. This is needed for bibles.
""" """
smallest_index = 0 smallest_index = 0
highest_index = len(html_list) - 1 highest_index = len(html_list) - 1
@ -459,7 +478,7 @@ class Renderer(object):
# We found the number of words which will fit. # We found the number of words which will fit.
if smallest_index == index or highest_index == index: if smallest_index == index or highest_index == index:
index = smallest_index index = smallest_index
formatted.append(previous_raw.rstrip(u'<br />') + formatted.append(previous_raw.rstrip(u'<br>') +
separator.join(raw_list[:index + 1])) separator.join(raw_list[:index + 1]))
previous_html = u'' previous_html = u''
previous_raw = u'' previous_raw = u''

View File

@ -174,7 +174,7 @@ class ServiceItem(object):
for slide in self._raw_frames: for slide in self._raw_frames:
pages = self.renderer.format_slide(slide[u'raw_slide'], self) pages = self.renderer.format_slide(slide[u'raw_slide'], self)
for page in pages: for page in pages:
page = page.replace(u'<br />', u'{br}') page = page.replace(u'<br>', u'{br}')
html = expand_tags(cgi.escape(page.rstrip())) html = expand_tags(cgi.escape(page.rstrip()))
self._display_frames.append({ self._display_frames.append({
u'title': clean_tags(page), u'title': clean_tags(page),
@ -194,7 +194,7 @@ class ServiceItem(object):
if self.raw_footer is None: if self.raw_footer is None:
self.raw_footer = [] self.raw_footer = []
self.foot_text = \ self.foot_text = \
u'<br />'.join([footer for footer in self.raw_footer if footer]) u'<br>'.join([footer for footer in self.raw_footer if footer])
def add_from_image(self, path, title): def add_from_image(self, path, title):
""" """
@ -462,7 +462,7 @@ class ServiceItem(object):
elif not start and end: elif not start and end:
return end return end
else: else:
return u'%s <br />%s' % (start, end) return u'%s <br>%s' % (start, end)
def update_theme(self, theme): def update_theme(self, theme):
""" """

View File

@ -240,7 +240,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
translate('OpenLP.ServiceManager', 'Notes: '), p, translate('OpenLP.ServiceManager', 'Notes: '), p,
classId=u'itemNotesTitle') classId=u'itemNotesTitle')
notes = self._addElement(u'span', notes = self._addElement(u'span',
item.notes.replace(u'\n', u'<br />'), p, item.notes.replace(u'\n', u'<br>'), p,
classId=u'itemNotesText') classId=u'itemNotesText')
# Add play length of media files. # Add play length of media files.
if item.is_media() and self.metaDataCheckBox.isChecked(): if item.is_media() and self.metaDataCheckBox.isChecked():

View File

@ -968,7 +968,7 @@ class ServiceManager(QtGui.QWidget):
if item[u'service_item'] \ if item[u'service_item'] \
.is_capable(ItemCapabilities.AllowsVariableStartTime): .is_capable(ItemCapabilities.AllowsVariableStartTime):
tips.append(item[u'service_item'].get_media_time()) tips.append(item[u'service_item'].get_media_time())
treewidgetitem.setToolTip(0, u'<br />'.join(tips)) treewidgetitem.setToolTip(0, u'<br>'.join(tips))
treewidgetitem.setData(0, QtCore.Qt.UserRole, treewidgetitem.setData(0, QtCore.Qt.UserRole,
QtCore.QVariant(item[u'order'])) QtCore.QVariant(item[u'order']))
treewidgetitem.setSelected(item[u'selected']) treewidgetitem.setSelected(item[u'selected'])