From 3e1bdc7475f98e72207e2056a85e7a3f95800919 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 11 May 2011 23:32:25 +0100 Subject: [PATCH 1/3] More stageview changes --- openlp/core/lib/renderer.py | 4 +-- openlp/core/lib/serviceitem.py | 2 ++ openlp/plugins/remotes/html/stage.css | 6 ++-- openlp/plugins/remotes/html/stage.js | 37 ++++++++++++++++++------ openlp/plugins/remotes/lib/httpserver.py | 9 +++--- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index bba85d176..98ae877b2 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -189,10 +189,10 @@ class Renderer(object): serviceItem.theme = theme_data if self.force_page: # make big page for theme edit dialog to get line count - serviceItem.add_from_text(u'', VERSE + VERSE + VERSE, FOOTER) + serviceItem.add_from_text(u'', VERSE + VERSE + VERSE) else: self.image_manager.del_image(theme_data.theme_name) - serviceItem.add_from_text(u'', VERSE, FOOTER) + serviceItem.add_from_text(u'', VERSE) serviceItem.renderer = self serviceItem.raw_footer = FOOTER serviceItem.render(True) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index c1ae95b8b..95702f229 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -219,6 +219,8 @@ class ServiceItem(object): ``raw_slide`` The raw text of the slide. """ + if verse_tag: + verse_tag = verse_tag.upper() self.service_item_type = ServiceItemType.Text title = title.split(u'\n')[0] self._raw_frames.append( diff --git a/openlp/plugins/remotes/html/stage.css b/openlp/plugins/remotes/html/stage.css index a773c2393..73551b92e 100644 --- a/openlp/plugins/remotes/html/stage.css +++ b/openlp/plugins/remotes/html/stage.css @@ -30,12 +30,14 @@ body { #currentslide { font-size: 40pt; color: white; + padding-bottom: 0px; } #nextslide { - font-size: 30pt; + font-size: 40pt; color: grey; - padding-top: 25px; + padding-top: 0px; + padding-bottom: 0px; } #right { diff --git a/openlp/plugins/remotes/html/stage.js b/openlp/plugins/remotes/html/stage.js index 96e4c5a14..0c1c0ce63 100644 --- a/openlp/plugins/remotes/html/stage.js +++ b/openlp/plugins/remotes/html/stage.js @@ -46,15 +46,21 @@ window.OpenLP = { function (data, status) { OpenLP.currentSlides = data.results.slides; OpenLP.currentSlide = 0; + OpenLP.currentTags = Array(); var div = $("#verseorder"); div.html(""); + var tag = ""; + var tags = 0; for (idx in data.results.slides) { idx = parseInt(idx, 10); - div.append(" "); - var tag = data.results.slides[idx]["tag"]; - if (tag == 'None') - tag = idx; - $("#verseorder span").last().attr("id", "tag" + idx).text(tag); + var prevtag = tag; + tag = data.results.slides[idx]["tag"]; + if (tag != prevtag) { + tags = tags + 1; + div.append(" "); + $("#verseorder span").last().attr("id", "tag" + tags).text(tag); + } + OpenLP.currentTags[idx] = tags; if (data.results.slides[idx]["selected"]) OpenLP.currentSlide = idx; } @@ -64,17 +70,30 @@ window.OpenLP = { }, updateSlide: function() { $("#verseorder span").removeClass("currenttag"); - $("#tag" + OpenLP.currentSlide).addClass("currenttag"); - var text = OpenLP.currentSlides[OpenLP.currentSlide]["text"]; + $("#tag" + OpenLP.currentTags[OpenLP.currentSlide]).addClass("currenttag"); + var slide = OpenLP.currentSlides[OpenLP.currentSlide]; + var text = slide["text"]; text = text.replace(/\n/g, '
'); $("#currentslide").html(text); + text = ""; if (OpenLP.currentSlide < OpenLP.currentSlides.length - 1) { - text = OpenLP.currentSlides[OpenLP.currentSlide + 1]["text"]; + for (var idx = OpenLP.currentSlide + 1; idx < OpenLP.currentSlides.length; idx++) { + var prevslide = slide; + slide = OpenLP.currentSlides[idx]; + if (slide["tag"] != prevslide["tag"]) + text = text + '

'; + text = text + slide["text"]; + if (slide["tag"] != prevslide["tag"]) + text = text + '

'; + else + text = text + '
'; + } text = text.replace(/\n/g, '
'); $("#nextslide").html(text); } else - $("#nextslide").html("Next: " + OpenLP.nextSong); + text = '

Next: ' + OpenLP.nextSong + '

'; + $("#nextslide").html(text); }, updateClock: function() { var div = $("#clock"); diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 790175965..6e5c2c0b6 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -115,7 +115,6 @@ import os import urlparse import re from pprint import pformat -from lxml import html try: import json @@ -402,9 +401,11 @@ class HttpConnection(object): for index, frame in enumerate(current_item.get_frames()): item = {} if current_item.is_text(): - item[u'tag'] = unicode(frame[u'verseTag']) - text = unicode(frame[u'html'].replace('
', '\n')) - item[u'text'] = html.fromstring(text).text_content() + if frame[u'verseTag']: + item[u'tag'] = unicode(frame[u'verseTag']) + else: + item[u'tag'] = unicode(index) + item[u'text'] = unicode(frame[u'text']) item[u'html'] = unicode(frame[u'html']) else: item[u'tag'] = unicode(index) From e940279b34c792480d15658370eb495a8ab52eb2 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 12 May 2011 00:16:53 +0100 Subject: [PATCH 2/3] More stageview changes --- openlp/core/ui/slidecontroller.py | 2 +- openlp/plugins/remotes/lib/httpserver.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index fdbf184b5..7623faa9b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -616,7 +616,7 @@ class SlideController(QtGui.QWidget): if frame[u'verseTag']: # These tags are already translated. verse_def = frame[u'verseTag'] - verse_def = u'%s%s' % (verse_def[0].upper(), verse_def[1:]) + verse_def = u'%s%s' % (verse_def[0], verse_def[1:]) two_line_def = u'%s\n%s' % (verse_def[0], verse_def[1:]) row = two_line_def if self.isLive: diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 6e5c2c0b6..20005840c 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -404,11 +404,11 @@ class HttpConnection(object): if frame[u'verseTag']: item[u'tag'] = unicode(frame[u'verseTag']) else: - item[u'tag'] = unicode(index) + item[u'tag'] = unicode(index + 1) item[u'text'] = unicode(frame[u'text']) item[u'html'] = unicode(frame[u'html']) else: - item[u'tag'] = unicode(index) + item[u'tag'] = unicode(index + 1) item[u'text'] = u'' item[u'html'] = u'' item[u'selected'] = (self.parent.current_slide == index) From ef5c4bc7d413369cc771b9325a4be285f86cd89a Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 12 May 2011 22:55:45 +0100 Subject: [PATCH 3/3] Detect repeat verses --- openlp/plugins/remotes/html/stage.js | 47 +++++++++++++++++++++------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/remotes/html/stage.js b/openlp/plugins/remotes/html/stage.js index 0c1c0ce63..8ca041366 100644 --- a/openlp/plugins/remotes/html/stage.js +++ b/openlp/plugins/remotes/html/stage.js @@ -51,24 +51,50 @@ window.OpenLP = { div.html(""); var tag = ""; var tags = 0; - for (idx in data.results.slides) { - idx = parseInt(idx, 10); + var lastChange = 0; + $.each(data.results.slides, function(idx, slide) { var prevtag = tag; - tag = data.results.slides[idx]["tag"]; + tag = slide["tag"]; if (tag != prevtag) { + // If the tag has changed, add new one to the list + lastChange = idx; tags = tags + 1; div.append(" "); $("#verseorder span").last().attr("id", "tag" + tags).text(tag); } + else { + if ((slide["text"] == data.results.slides[lastChange]["text"]) && + (data.results.slides.length > idx + (idx - lastChange))) { + // If the tag hasn't changed, check to see if the same verse + // has been repeated consecutively. Note the verse may have been + // split over several slides, so search through. If so, repeat the tag. + var match = true; + for (var idx2 = 0; idx2 < idx - lastChange; idx2++) { + if(data.results.slides[lastChange + idx2]["text"] != data.results.slides[idx + idx2]["text"]) { + match = false; + break; + } + } + if (match) { + lastChange = idx; + tags = tags + 1; + div.append(" "); + $("#verseorder span").last().attr("id", "tag" + tags).text(tag); + } + } + } OpenLP.currentTags[idx] = tags; - if (data.results.slides[idx]["selected"]) + if (slide["selected"]) OpenLP.currentSlide = idx; - } + }) OpenLP.loadService(); } ); }, updateSlide: function() { + // Show the current slide on top. Any trailing slides for the same verse + // are shown too underneath in grey. + // Then leave a blank line between following verses $("#verseorder span").removeClass("currenttag"); $("#tag" + OpenLP.currentTags[OpenLP.currentSlide]).addClass("currenttag"); var slide = OpenLP.currentSlides[OpenLP.currentSlide]; @@ -78,12 +104,10 @@ window.OpenLP = { text = ""; if (OpenLP.currentSlide < OpenLP.currentSlides.length - 1) { for (var idx = OpenLP.currentSlide + 1; idx < OpenLP.currentSlides.length; idx++) { - var prevslide = slide; - slide = OpenLP.currentSlides[idx]; - if (slide["tag"] != prevslide["tag"]) + if (OpenLP.currentTags[idx] != OpenLP.currentTags[idx - 1]) text = text + '

'; - text = text + slide["text"]; - if (slide["tag"] != prevslide["tag"]) + text = text + OpenLP.currentSlides[idx]["text"]; + if (OpenLP.currentTags[idx] != OpenLP.currentTags[idx - 1]) text = text + '

'; else text = text + '
'; @@ -91,9 +115,10 @@ window.OpenLP = { text = text.replace(/\n/g, '
'); $("#nextslide").html(text); } - else + else { text = '

Next: ' + OpenLP.nextSong + '

'; $("#nextslide").html(text); + } }, updateClock: function() { var div = $("#clock");