This commit is contained in:
Andreas Preikschat 2011-05-26 09:10:02 +02:00
commit 6c1c4c91bb
6 changed files with 44 additions and 33 deletions

View File

@ -84,6 +84,9 @@ base_html_expands.append({u'desc': u'Italics', u'start tag': u'{it}',
base_html_expands.append({u'desc': u'Underline', u'start tag': u'{u}', base_html_expands.append({u'desc': u'Underline', u'start tag': u'{u}',
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_html_expands.append({u'desc': u'Break', u'start tag': u'{br}',
u'start html': u'<br>', u'end tag': u'', u'end html': u'',
u'protected': True})
def translate(context, text, comment=None, def translate(context, text, comment=None,
encoding=QtCore.QCoreApplication.CodecForTr, n=-1, encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
@ -245,6 +248,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'&nbsp;', u' ') text = text.replace(u'&nbsp;', u' ')
for tag in DisplayTags.get_html_tags(): for tag in DisplayTags.get_html_tags():
text = text.replace(tag[u'start tag'], u'') text = text.replace(tag[u'start tag'], u'')

View File

@ -29,6 +29,7 @@ The :mod:`serviceitem` provides the service item functionality including the
type and capability of an item. type and capability of an item.
""" """
import cgi
import datetime import datetime
import logging import logging
import os import os
@ -175,10 +176,11 @@ class ServiceItem(object):
formatted = self.renderer \ formatted = self.renderer \
.format_slide(slide[u'raw_slide'], line_break, self) .format_slide(slide[u'raw_slide'], line_break, self)
for page in formatted: for page in formatted:
page = page.replace(u'<br>', u'{br}')
self._display_frames.append({ self._display_frames.append({
u'title': clean_tags(page), u'title': clean_tags(page),
u'text': clean_tags(page.rstrip()), u'text': clean_tags(page.rstrip()),
u'html': expand_tags(page.rstrip()), u'html': expand_tags(cgi.escape(page.rstrip())),
u'verseTag': slide[u'verseTag'] u'verseTag': slide[u'verseTag']
}) })
elif self.service_item_type == ServiceItemType.Image or \ elif self.service_item_type == ServiceItemType.Image or \

View File

@ -29,6 +29,7 @@ import os
import zipfile import zipfile
import shutil import shutil
import logging import logging
import locale
from xml.etree.ElementTree import ElementTree, XML from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -462,7 +463,10 @@ class ThemeManager(QtGui.QWidget):
QtCore.QVariant(theme.theme_name)) QtCore.QVariant(theme.theme_name))
self.configUpdated() self.configUpdated()
files = SettingsManager.get_files(self.settingsSection, u'.png') files = SettingsManager.get_files(self.settingsSection, u'.png')
files.sort() # Sort the themes by its name considering language specific characters.
# lower() is needed for windows!
files.sort(key=lambda filename: unicode(filename).lower(),
cmp=locale.strcoll)
# now process the file list of png files # now process the file list of png files
for name in files: for name in files:
# check to see file is in theme root directory # check to see file is in theme root directory

View File

@ -31,6 +31,7 @@ import csv
import logging import logging
import os import os
import os.path import os.path
import locale
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -532,7 +533,7 @@ class BibleImportForm(OpenLPWizard):
""" """
self.webTranslationComboBox.clear() self.webTranslationComboBox.clear()
bibles = self.web_bible_list[index].keys() bibles = self.web_bible_list[index].keys()
bibles.sort() bibles.sort(cmp=locale.strcoll)
self.webTranslationComboBox.addItems(bibles) self.webTranslationComboBox.addItems(bibles)
def onOsisBrowseButtonClicked(self): def onOsisBrowseButtonClicked(self):
@ -767,4 +768,3 @@ class BibleImportForm(OpenLPWizard):
'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) 'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
del self.manager.db_cache[importer.name] del self.manager.db_cache[importer.name]
delete_database(self.plugin.settingsSection, importer.file) delete_database(self.plugin.settingsSection, importer.file)

View File

@ -26,6 +26,7 @@
############################################################################### ###############################################################################
import logging import logging
import locale
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -359,7 +360,7 @@ class BibleMediaItem(MediaManagerItem):
self.advancedSecondComboBox.addItem(u'') self.advancedSecondComboBox.addItem(u'')
# Get all bibles and sort the list. # Get all bibles and sort the list.
bibles = self.parent.manager.get_bibles().keys() bibles = self.parent.manager.get_bibles().keys()
bibles.sort() bibles.sort(cmp=locale.strcoll)
# Load the bibles into the combo boxes. # Load the bibles into the combo boxes.
for bible in bibles: for bible in bibles:
if bible: if bible:
@ -443,7 +444,7 @@ class BibleMediaItem(MediaManagerItem):
if bible: if bible:
book_data = bibles[bible].get_books() book_data = bibles[bible].get_books()
books = [book.name + u' ' for book in book_data] books = [book.name + u' ' for book in book_data]
books.sort() books.sort(cmp=locale.strcoll)
add_widget_completer(books, self.quickSearchEdit) add_widget_completer(books, self.quickSearchEdit)
def onImportClick(self): def onImportClick(self):

View File

@ -69,6 +69,30 @@ class SongBeamerImport(SongImport):
Song Beamer file format is text based Song Beamer file format is text based
in the beginning are one or more control tags written in the beginning are one or more control tags written
""" """
HTML_TAG_PAIRS = [
(re.compile(u'<b>'), u'{st}'),
(re.compile(u'</b>'), u'{/st}'),
(re.compile(u'<i>'), u'{it}'),
(re.compile(u'</i>'), u'{/it}'),
(re.compile(u'<u>'), u'{u}'),
(re.compile(u'</u>'), u'{/u}'),
(re.compile(u'<p>'), u'{p}'),
(re.compile(u'</p>'), u'{/p}'),
(re.compile(u'<super>'), u'{su}'),
(re.compile(u'</super>'), u'{/su}'),
(re.compile(u'<sub>'), u'{sb}'),
(re.compile(u'</sub>'), u'{/sb}'),
(re.compile(u'<br.*?>'), u'{br}'),
(re.compile(u'<[/]?wordwrap>'), u''),
(re.compile(u'<[/]?strike>'), u''),
(re.compile(u'<[/]?h.*?>'), u''),
(re.compile(u'<[/]?s.*?>'), u''),
(re.compile(u'<[/]?linespacing.*?>'), u''),
(re.compile(u'<[/]?c.*?>'), u''),
(re.compile(u'<align.*?>'), u''),
(re.compile(u'<valign.*?>'), u'')
]
def __init__(self, manager, **kwargs): def __init__(self, manager, **kwargs):
""" """
Initialise the Song Beamer importer. Initialise the Song Beamer importer.
@ -134,32 +158,8 @@ class SongBeamerImport(SongImport):
This can be called to replace SongBeamer's specific (html) tags with This can be called to replace SongBeamer's specific (html) tags with
OpenLP's specific (html) tags. OpenLP's specific (html) tags.
""" """
tag_pairs = [ for pair in SongBeamerImport.HTML_TAG_PAIRS:
(u'<b>', u'{st}'), self.current_verse = pair[0].sub(pair[1], self.current_verse)
(u'</b>', u'{/st}'),
(u'<i>', u'{it}'),
(u'</i>', u'{/it}'),
(u'<u>', u'{u}'),
(u'</u>', u'{/u}'),
(u'<p>', u'{p}'),
(u'</p>', u'{/p}'),
(u'<super>', u'{su}'),
(u'</super>', u'{/su}'),
(u'<sub>', u'{sb}'),
(u'</sub>', u'{/sb}'),
(u'<[/]?br.*?>', u'{st}'),
(u'<[/]?wordwrap>', u''),
(u'<[/]?strike>', u''),
(u'<[/]?h.*?>', u''),
(u'<[/]?s.*?>', u''),
(u'<[/]?linespacing.*?>', u''),
(u'<[/]?c.*?>', u''),
(u'<align.*?>', u''),
(u'<valign.*?>', u'')
]
for pair in tag_pairs:
self.current_verse = re.compile(pair[0]).sub(pair[1],
self.current_verse)
def parse_tags(self, line): def parse_tags(self, line):
""" """