From d05c349f41319dd483394297e0f04563e05bd63a Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Tue, 24 May 2011 16:41:14 -0400 Subject: [PATCH 01/21] Catch common errors during import and report to user --- openlp/plugins/songs/lib/oooimport.py | 23 ++++++++++++++++++----- openlp/plugins/songs/lib/sofimport.py | 26 ++++++++++++++++---------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index d43541bc7..1c5c7e1ef 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -40,6 +40,7 @@ if os.name == u'nt': PAGE_BOTH = 6 else: import uno + from com.sun.star.connection import NoConnectException from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH class OooImport(SongImport): @@ -56,7 +57,16 @@ class OooImport(SongImport): self.process_started = False def do_import(self): - self.start_ooo() + if not isinstance(self.import_source, list): + return + try: + self.start_ooo() + except NoConnectException as exc: + self.log_error( + self.import_source[0], + u'Unable to connect to OpenOffice.org or LibreOffice') + log.error(exc) + return self.import_wizard.progressBar.setMaximum(len(self.import_source)) for filename in self.import_source: if self.stop_import_flag: @@ -98,13 +108,16 @@ class OooImport(SongImport): while uno_instance is None and loop < 5: try: uno_instance = get_uno_instance(resolver) - except: + except NoConnectException: log.exception("Failed to resolve uno connection") self.start_ooo_process() loop += 1 - manager = uno_instance.ServiceManager - self.desktop = manager.createInstanceWithContext( - "com.sun.star.frame.Desktop", uno_instance) + else: + manager = uno_instance.ServiceManager + self.desktop = manager.createInstanceWithContext( + "com.sun.star.frame.Desktop", uno_instance) + return + raise def start_ooo_process(self): try: diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 7f9fa16bc..f35094a96 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -30,10 +30,14 @@ # http://www.oooforum.org/forum/viewtopic.phtml?t=14409 # http://wiki.services.openoffice.org/wiki/Python +import logging import os import re from oooimport import OooImport +from com.sun.star.uno import RuntimeException + +log = logging.getLogger(__name__) if os.name == u'nt': BOLD = 150.0 @@ -85,16 +89,18 @@ class SofImport(OooImport): """ self.blanklines = 0 self.new_song() - paragraphs = self.document.getText().createEnumeration() - while paragraphs.hasMoreElements(): - if self.stop_import_flag: - return - paragraph = paragraphs.nextElement() - if paragraph.supportsService("com.sun.star.text.Paragraph"): - self.process_paragraph(paragraph) - if self.song: - self.finish() - self.song = False + try: + paragraphs = self.document.getText().createEnumeration() + while paragraphs.hasMoreElements(): + if self.stop_import_flag: + return + paragraph = paragraphs.nextElement() + if paragraph.supportsService("com.sun.star.text.Paragraph"): + self.process_paragraph(paragraph) + except RuntimeException as exc: + log.exception(u'Error processing file: %s', exc) + if not self.finish(): + self.log_error(self.filepath) def process_paragraph(self, paragraph): """ From 4399fc108f18000715ec6ee8caa7b50f601ad21f Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Wed, 25 May 2011 17:38:32 -0400 Subject: [PATCH 02/21] Fixed a silent error when OpenOffice fails to open a file.\ Also, added the file name to the exception log and made the exception explicit --- openlp/plugins/songs/lib/oooimport.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index f570f33d3..a03a36121 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -80,6 +80,10 @@ class OooImport(SongImport): if self.document: self.process_ooo_document() self.close_ooo_file() + else: + self.log_error(self.filepath) + else: + self.log_error(self.filepath) self.close_ooo() def process_ooo_document(self): @@ -160,8 +164,8 @@ class OooImport(SongImport): else: self.import_wizard.incrementProgressBar( u'Processing file ' + filepath, 0) - except: - log.exception("open_ooo_file failed") + except AttributeError: + log.exception("open_ooo_file failed: %s", url) return def close_ooo_file(self): From e70ba41373abceb0a143e54e2135ae512cbbc52f Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Thu, 26 May 2011 09:35:01 -0400 Subject: [PATCH 03/21] Add specific error messages if OoO open fails. Use a lambda to avoid repetition --- openlp/plugins/songs/lib/oooimport.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index a03a36121..5e4cd25d4 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -71,6 +71,10 @@ class OooImport(SongImport): log.error(exc) return self.import_wizard.progressBar.setMaximum(len(self.import_source)) + error_msg = lambda: self.log_error( + self.filepath, + translate('SongsPlugin.SongImport', + u'Unable to open file')) for filename in self.import_source: if self.stop_import_flag: break @@ -81,9 +85,9 @@ class OooImport(SongImport): self.process_ooo_document() self.close_ooo_file() else: - self.log_error(self.filepath) + error_msg() else: - self.log_error(self.filepath) + error_msg() self.close_ooo() def process_ooo_document(self): From 74e47dcbc7fb8c948a6447915551e3984af36ea8 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Thu, 26 May 2011 14:20:14 -0400 Subject: [PATCH 04/21] Add specific error messages for file problems. Remove unicode strings in calls to translate() --- openlp/plugins/songs/lib/oooimport.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 5e4cd25d4..3cc61f4e3 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -67,14 +67,10 @@ class OooImport(SongImport): self.log_error( self.import_source[0], translate('SongsPlugin.SongImport', - u'Unable to open OpenOffice.org or LibreOffice')) + 'Unable to open OpenOffice.org or LibreOffice')) log.error(exc) return self.import_wizard.progressBar.setMaximum(len(self.import_source)) - error_msg = lambda: self.log_error( - self.filepath, - translate('SongsPlugin.SongImport', - u'Unable to open file')) for filename in self.import_source: if self.stop_import_flag: break @@ -85,9 +81,13 @@ class OooImport(SongImport): self.process_ooo_document() self.close_ooo_file() else: - error_msg() + self.log_error(self.filepath, + translate('SongsPlugin.SongImport', + 'Unable to open file')) else: - error_msg() + self.log_error(self.filepath, + translate('SongsPlugin.SongImport', + 'File not found')) self.close_ooo() def process_ooo_document(self): From caa6639c7b184d348c25099479a3cd66895550e5 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Sat, 28 May 2011 16:43:33 -0400 Subject: [PATCH 05/21] Uglification to conform to weird standards :) --- openlp/plugins/songs/lib/oooimport.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 45e85f64c..ddbab8b31 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -82,12 +82,11 @@ class OooImport(SongImport): self.close_ooo_file() else: self.log_error(self.filepath, - translate('SongsPlugin.SongImport', - 'Unable to open file')) + translate('SongsPlugin.SongImport', + 'Unable to open file')) else: self.log_error(self.filepath, - translate('SongsPlugin.SongImport', - 'File not found')) + translate('SongsPlugin.SongImport', 'File not found')) self.close_ooo() def process_ooo_document(self): From 68238f3c513c0289282d449ca6ed57a97812771d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 29 May 2011 08:25:31 +0200 Subject: [PATCH 06/21] r1590 From 22ad88d3ee36c284e67d0d9dd35729bd4a9606e4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 29 May 2011 08:26:14 +0200 Subject: [PATCH 07/21] fix for bug #789618 Fixes: https://launchpad.net/bugs/789618 --- openlp/core/ui/printserviceform.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 09ae8857f..b1147731b 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -56,7 +56,9 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties font-size:large; } -.itemText {} +.itemText { + margin-top:10px; +} .itemFooter { font-size:8px; @@ -85,7 +87,7 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties .imageList {} .customNotes { - margin-top: 10px; + margin-top:10px; } .customNotesTitle { @@ -212,11 +214,11 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): verse_def = None for slide in item.get_frames(): if not verse_def or verse_def != slide[u'verseTag']: - p = self._addElement(u'div', parent=div, + text_div = self._addElement(u'div', parent=div, classId=u'itemText') else: - self._addElement(u'br', parent=p) - self._addElement(u'p', slide[u'html'], p) + self._addElement(u'br', parent=text_div) + self._addElement(u'span', slide[u'html'], text_div) verse_def = slide[u'verseTag'] # Break the page before the div element. if index != 0 and self.pageBreakAfterText.isChecked(): From 0a2d97021cf97e04336fd271d33b0f2002ef70fc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 30 May 2011 07:03:46 +0200 Subject: [PATCH 08/21] added spaces --- openlp/core/ui/printserviceform.py | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index b1147731b..ccd1eb18c 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -42,44 +42,44 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties */ .serviceTitle { - font-weight:600; - font-size:x-large; - color:black; + font-weight: 600; + font-size: x-large; + color: black; } .item { - color:black; + color: black; } .itemTitle { - font-weight:600; - font-size:large; + font-weight: 600; + font-size: large; } .itemText { - margin-top:10px; + margin-top: 10px; } .itemFooter { - font-size:8px; + font-size: 8px; } .itemNotes {} .itemNotesTitle { - font-weight:bold; - font-size:12px; + font-weight: bold; + font-size: 12px; } .itemNotesText { - font-size:11px; + font-size: 11px; } .media {} .mediaTitle { - font-weight:bold; - font-size:11px; + font-weight: bold; + font-size: 11px; } .mediaText {} @@ -87,20 +87,20 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties .imageList {} .customNotes { - margin-top:10px; + margin-top: 10px; } .customNotesTitle { - font-weight:bold; - font-size:11px; + font-weight: bold; + font-size: 11px; } .customNotesText { - font-size:11px; + font-size: 11px; } .newPage { - page-break-before:always; + page-break-before: always; } """ From 30ec309ff8550cab242331aabcaf2f27cfbd7ff6 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 30 May 2011 08:45:58 +0200 Subject: [PATCH 09/21] Fixed up various index errors on InnoDB tables. --- openlp/plugins/songs/lib/db.py | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index ced98537e..9a332e994 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -165,7 +165,7 @@ def init_schema(url): Column(u'id', types.Integer, primary_key=True), Column(u'first_name', types.Unicode(128)), Column(u'last_name', types.Unicode(128)), - Column(u'display_name', types.Unicode(255), nullable=False) + Column(u'display_name', types.Unicode(255), index=True, nullable=False) ) # Definition of the "media_files" table @@ -186,7 +186,7 @@ def init_schema(url): songs_table = Table(u'songs', metadata, Column(u'id', types.Integer, primary_key=True), Column(u'song_book_id', types.Integer, - ForeignKey(u'song_books.id'), default=0), + ForeignKey(u'song_books.id'), default=None), Column(u'title', types.Unicode(255), nullable=False), Column(u'alternate_title', types.Unicode(255)), Column(u'lyrics', types.UnicodeText, nullable=False), @@ -203,7 +203,7 @@ def init_schema(url): # Definition of the "topics" table topics_table = Table(u'topics', metadata, Column(u'id', types.Integer, primary_key=True), - Column(u'name', types.Unicode(128), nullable=False) + Column(u'name', types.Unicode(128), index=True, nullable=False) ) # Definition of the "authors_songs" table @@ -230,27 +230,6 @@ def init_schema(url): ForeignKey(u'topics.id'), primary_key=True) ) - # Define table indexes - Index(u'authors_id', authors_table.c.id) - Index(u'authors_display_name_id', authors_table.c.display_name, - authors_table.c.id) - Index(u'media_files_id', media_files_table.c.id) - Index(u'song_books_id', song_books_table.c.id) - Index(u'songs_id', songs_table.c.id) - Index(u'topics_id', topics_table.c.id) - Index(u'authors_songs_author', authors_songs_table.c.author_id, - authors_songs_table.c.song_id) - Index(u'authors_songs_song', authors_songs_table.c.song_id, - authors_songs_table.c.author_id) - Index(u'media_files_songs_file', media_files_songs_table.c.media_file_id, - media_files_songs_table.c.song_id) - Index(u'media_files_songs_song', media_files_songs_table.c.song_id, - media_files_songs_table.c.media_file_id) - Index(u'topics_song_topic', songs_topics_table.c.topic_id, - songs_topics_table.c.song_id) - Index(u'topics_song_song', songs_topics_table.c.song_id, - songs_topics_table.c.topic_id) - mapper(Author, authors_table) mapper(Book, song_books_table) mapper(MediaFile, media_files_table) From 99ae60aba318fc9b50bcaa1552ccac61cae593a4 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 30 May 2011 13:17:23 +0200 Subject: [PATCH 10/21] Fixed up loading a song from a service. --- openlp/plugins/songs/lib/mediaitem.py | 1 + openlp/plugins/songs/lib/xml.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 3d9a9ef76..65e2289cd 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -27,6 +27,7 @@ import logging import locale +import re from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 7bcf56aa1..f5ec28103 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -514,7 +514,7 @@ class OpenLyrics(object): ``song`` The song object. """ - song.song_book_id = 0 + song.song_book_id = None song.song_number = u'' if hasattr(properties, u'songbooks'): for songbook in properties.songbooks.songbook: From 27b8ec3deba4fc948d29c3c9daec37cf442c59d1 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 30 May 2011 15:19:16 -0400 Subject: [PATCH 11/21] Add exception logging to import.py --- openlp/plugins/songs/lib/importer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index cf2d3f536..fffc0f4f8 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -38,20 +38,25 @@ from songbeamerimport import SongBeamerImport from songshowplusimport import SongShowPlusImport from foilpresenterimport import FoilPresenterImport # Imports that might fail +import logging +log = logging.getLogger(__name__) try: from olp1import import OpenLP1SongImport HAS_OPENLP1 = True except ImportError: + log.exception('Error importing %s', 'OpenLP1SongImport') HAS_OPENLP1 = False try: from sofimport import SofImport HAS_SOF = True except ImportError: + log.exception('Error importing %s', 'SofImport') HAS_SOF = False try: from oooimport import OooImport HAS_OOO = True except ImportError: + log.exception('Error importing %s', 'OooImport') HAS_OOO = False class SongFormat(object): From 934a70b9555339539757bc97c78f10fc8d5ec3d3 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 30 May 2011 16:14:36 -0400 Subject: [PATCH 12/21] Relocate import logging statement --- openlp/plugins/songs/lib/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index fffc0f4f8..ab92033c4 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -27,6 +27,7 @@ """ The :mod:`importer` modules provides the general song import functionality. """ +import logging from opensongimport import OpenSongImport from easislidesimport import EasiSlidesImport from olpimport import OpenLPSongImport @@ -38,7 +39,6 @@ from songbeamerimport import SongBeamerImport from songshowplusimport import SongShowPlusImport from foilpresenterimport import FoilPresenterImport # Imports that might fail -import logging log = logging.getLogger(__name__) try: from olp1import import OpenLP1SongImport From cde0eb5ab571462751e6291317597aed4a86f331 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 30 May 2011 17:15:34 -0400 Subject: [PATCH 13/21] Only import uno exceptions if not running Windoes --- openlp/plugins/songs/lib/oooimport.py | 1 + openlp/plugins/songs/lib/sofimport.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index ddbab8b31..fb6ee43a6 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -40,6 +40,7 @@ if os.name == u'nt': PAGE_BEFORE = 4 PAGE_AFTER = 5 PAGE_BOTH = 6 + NoConnectException = Exception else: import uno from com.sun.star.connection import NoConnectException diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 5cc0482f2..7f0bed72b 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -36,7 +36,7 @@ import os import re from oooimport import OooImport -from com.sun.star.uno import RuntimeException + log = logging.getLogger(__name__) @@ -44,12 +44,14 @@ if os.name == u'nt': BOLD = 150.0 ITALIC = 2 from oooimport import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH + RuntimeException = Exception else: try: from com.sun.star.awt.FontWeight import BOLD from com.sun.star.awt.FontSlant import ITALIC from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, \ PAGE_BOTH + from com.sun.star.uno import RuntimeException except ImportError: pass From ee151cde2a7bd04b574c6892432b33e2873b71bc Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 31 May 2011 12:59:05 +0200 Subject: [PATCH 14/21] Fixed bug #790382 by using the Mako template engine to pass Python variables into the template. --- openlp/plugins/remotes/html/index.html | 60 ++++++++++++------------ openlp/plugins/remotes/html/stage.html | 4 +- openlp/plugins/remotes/lib/httpserver.py | 38 +++++++++++++-- 3 files changed, 65 insertions(+), 37 deletions(-) diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 6390b9446..b370d589e 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -27,7 +27,7 @@ --> - OpenLP 2.0 Remote + ${app_title} @@ -37,81 +37,81 @@
- Back -

Service Manager

- Refresh + ${back} +

${service_manager}

+ ${refresh}
- Back -

Slide Controller

- Refresh + ${back} +

${slide_controller}

+ ${refresh}
- Back -

Alerts

+ ${back} +

${alerts}

- +
- Show Alert + ${show_alert}
- + \ No newline at end of file diff --git a/openlp/plugins/remotes/html/stage.html b/openlp/plugins/remotes/html/stage.html index b67f0ccd6..c002ea68b 100644 --- a/openlp/plugins/remotes/html/stage.html +++ b/openlp/plugins/remotes/html/stage.html @@ -6,8 +6,8 @@ # --------------------------------------------------------------------------- # # Copyright (c) 2008-2011 Raoul Snyman # # Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # -# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # +# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # +# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # # Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode # # Woldsund # # --------------------------------------------------------------------------- # diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 9d29156f7..d9cae42d0 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -115,7 +115,6 @@ import logging import os import urlparse import re -from pprint import pformat try: import json @@ -123,10 +122,11 @@ except ImportError: import simplejson as json from PyQt4 import QtCore, QtNetwork +from mako.template import Template from openlp.core.lib import Receiver, PluginStatus from openlp.core.ui import HideMode -from openlp.core.utils import AppLocation +from openlp.core.utils import AppLocation, translate log = logging.getLogger(__name__) @@ -261,6 +261,7 @@ class HttpConnection(object): self.ready_read) QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'disconnected()'), self.disconnected) + self.translate() def _get_service_items(self): service_items = [] @@ -280,6 +281,27 @@ class HttpConnection(object): }) return service_items + def translate(self): + """ + Translate various strings in the mobile app. + """ + self.template_vars = { + 'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Remote'), + 'stage_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Stage View'), + 'service_manager': translate('RemotePlugin.Mobile', 'Service Manager'), + 'slide_controller': translate('RemotePlugin.Mobile', 'Slide Controller'), + 'alerts': translate('RemotePlugin.Mobile', 'Alerts'), + 'search': translate('RemotePlugin.Mobile', 'Search'), + 'back': translate('RemotePlugin.Mobile', 'Back'), + 'refresh': translate('RemotePlugin.Mobile', 'Refresh'), + 'blank': translate('RemotePlugin.Mobile', 'Blank'), + 'show': translate('RemotePlugin.Mobile', 'Show'), + 'prev': translate('RemotePlugin.Mobile', 'Prev'), + 'next': translate('RemotePlugin.Mobile', 'Next'), + 'text': translate('RemotePlugin.Mobile', 'Text'), + 'show_alert': translate('RemotePlugin.Mobile', 'Show Alert') + } + def ready_read(self): """ Data has been sent from the client. Respond to it @@ -327,8 +349,11 @@ class HttpConnection(object): if not path.startswith(self.parent.html_dir): return HttpResponse(code=u'404 Not Found') ext = os.path.splitext(filename)[1] + html = None if ext == u'.html': mimetype = u'text/html' + variables = self.template_vars + html = Template(filename=path, input_encoding=u'utf-8', output_encoding=u'utf-8').render(**variables) elif ext == u'.css': mimetype = u'text/css' elif ext == u'.js': @@ -343,9 +368,12 @@ class HttpConnection(object): mimetype = u'text/plain' file_handle = None try: - file_handle = open(path, u'rb') - log.debug(u'Opened %s' % path) - content = file_handle.read() + if html: + content = html + else: + file_handle = open(path, u'rb') + log.debug(u'Opened %s' % path) + content = file_handle.read() except IOError: log.exception(u'Failed to open %s' % path) return HttpResponse(code=u'404 Not Found') From 9f7a96c31514b9dc31c6d766c95b611e3d321c6a Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 31 May 2011 13:25:35 +0200 Subject: [PATCH 15/21] Fixed up some missing translations. --- openlp/plugins/remotes/html/stage.html | 3 ++- openlp/plugins/remotes/html/stage.js | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/remotes/html/stage.html b/openlp/plugins/remotes/html/stage.html index c002ea68b..c5d0872d0 100644 --- a/openlp/plugins/remotes/html/stage.html +++ b/openlp/plugins/remotes/html/stage.html @@ -27,12 +27,13 @@ --> - OpenLP 2.0 Stage View + ${stage_title} +