From 047287950cb748267c4ef9d863c15cd6fb8ba709 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 14 May 2011 10:48:58 +0100 Subject: [PATCH 1/9] Remote song search and go live beginnings --- openlp/core/lib/mediamanageritem.py | 30 ++++++++++++--- openlp/core/lib/pluginmanager.py | 11 +++++- openlp/plugins/remotes/html/index.html | 19 +++++++++- openlp/plugins/remotes/html/openlp.js | 38 +++++++++++++++++++ openlp/plugins/remotes/lib/httpserver.py | 48 +++++++++++++++++++++++- openlp/plugins/songs/lib/mediaitem.py | 32 +++++++++++++--- openlp/plugins/songs/songsplugin.py | 1 - 7 files changed, 163 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 99a42e3cf..fab50b4dc 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -475,11 +475,18 @@ class MediaManagerItem(QtGui.QWidget): translate('OpenLP.MediaManagerItem', 'You must select one or more items to send live.')) else: - log.debug(u'%s Live requested', self.plugin.name) - serviceItem = self.buildServiceItem() - if serviceItem: - serviceItem.from_plugin = True - self.parent.liveController.addServiceItem(serviceItem) + self.goLive() + + def goLive(self, item_id=None): + log.debug(u'%s Live requested', self.plugin.name) + item = None + if item_id: + item = QtGui.QListWidgetItem() + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(item_id)) + serviceItem = self.buildServiceItem(item) + if serviceItem: + serviceItem.from_plugin = True + self.parent.liveController.addServiceItem(serviceItem) def onAddClick(self): """ @@ -573,3 +580,16 @@ class MediaManagerItem(QtGui.QWidget): else: item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] return item_id + + def hasSearch(self): + """ + Returns whether this plugin supports the search method + """ + return False + + def search(self, string): + """ + Performs a plugin specific search for items containing ``string`` + """ + raise NotImplementedError( + u'Plugin.about needs to be defined by the plugin') diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 0fddc75c4..3e1620378 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -45,7 +45,7 @@ class PluginManager(object): """ The constructor for the plugin manager. Passes the controllers on to the plugins for them to interact with via their ServiceItems. - +pluginmanager.py ``plugin_dir`` The directory to search for plugins. """ @@ -211,3 +211,12 @@ class PluginManager(object): if plugin.isActive(): plugin.finalise() log.info(u'Finalisation Complete for %s ' % plugin.name) + + def get_plugin_by_name(self, name): + """ + Return the plugin which has a name with value ``name`` + """ + for plugin in self.plugins: + if plugin.name == name: + return plugin + return None diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 3708db654..bbb0644c3 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -43,6 +43,7 @@ Service Manager Slide Controller Alerts + Search @@ -55,7 +56,7 @@ -
+
Blank Unblank Refresh @@ -72,7 +73,7 @@
-
+
Blank Unblank Refresh @@ -93,5 +94,19 @@ Show Alert
+ diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 74463ffbc..4945e366f 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -189,7 +189,43 @@ window.OpenLP = { } ); return false; + }, + search: function (event) { + var text = JSON.stringify({"request": {"text": $("#search-text").val()}}); + $.getJSON( + "/api/Songs/search", + {"data": text}, + function (data, status) { + var ul = $("#search > div[data-role=content] > ul[data-role=listview]"); + ul.html(""); + if (data.results.items.length == 0) { + var li = $("
  • ").text('No results'); + ul.append(li); + } + else { + $.each(data.results.items, function (idx, value) { + var li = $("
  • ").append( + $("").attr("value", value[0]).text(value[1])); + li.children("a").click(OpenLP.goLive); + ul.append(li); + }); + } + ul.listview("refresh"); + } + ); + return false; + }, + goLive: function (event) { + var slide = OpenLP.getElement(event); + var id = slide.attr("value"); + var text = JSON.stringify({"request": {"id": id}}); + $.getJSON( + "/api/Songs/live", + {"data": text}) + window.location.replace('/#slide-controller'); + return false; } + } // Service Manager $("#service-manager").live("pagebeforeshow", OpenLP.loadService); @@ -207,6 +243,8 @@ $("#controller-blank").live("click", OpenLP.blankDisplay); $("#controller-unblank").live("click", OpenLP.unblankDisplay); // Alerts $("#alert-submit").live("click", OpenLP.showAlert); +// Search +$("#search-submit").live("click", OpenLP.search); // Poll the server twice a second to get any updates. $.ajaxSetup({ cache: false }); setInterval("OpenLP.pollServer();", 500); diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 20005840c..cc56c18f8 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -250,7 +250,10 @@ class HttpConnection(object): (r'^/api/controller/(live|preview)/(.*)$', self.controller), (r'^/api/service/(.*)$', self.service), (r'^/api/display/(hide|show)$', self.display), - (r'^/api/alert$', self.alert) + (r'^/api/alert$', self.alert), + (r'^/api/plugin/(search)$', self.plugin), + (r'^/api/(.*)/search$', self.search), + (r'^/api/(.*)/live$', self.go_live) ] QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'), self.ready_read) @@ -443,6 +446,49 @@ class HttpConnection(object): return HttpResponse(json.dumps({u'results': {u'success': True}}), {u'Content-Type': u'application/json'}) + def plugin(self, action): + """ + Return plugin related actions + + ``action`` - The action to perform + if 'search' return a list of plugin names which support search + """ + if action == u'search': + searches = [] + for plugin in self.parent.parent.pluginManager.plugins: + media_item = plugin.mediaItem + if media_item and media_item.hasSearch(): + searches.append(plugin.Name) + return HttpResponse( + json.dumps({u'results': {u'items': searches}}), + {u'Content-Type': u'application/json'}) + + def search(self, type): + """ + Return a list of items that match the search text + + ``type`` + The plugin name to search in. + """ + text = json.loads(self.url_params[u'data'][0])[u'request'][u'text'] + plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) + media_item = plugin.mediaItem + if media_item and media_item.hasSearch(): + results = media_item.search(text) + return HttpResponse( + json.dumps({u'results': {u'items': results}}), + {u'Content-Type': u'application/json'}) + + def go_live(self, type): + """ + Go live on an item of type ``type``. + """ + id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] + plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) + media_item = plugin.mediaItem + if media_item: + media_item.goLive(id) + def send_response(self, response): http = u'HTTP/1.1 %s\r\n' % response.code for header, value in response.headers.iteritems(): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 3b014d4b0..ccd68705a 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -171,11 +171,7 @@ class SongMediaItem(MediaManagerItem): search_type = self.searchTextEdit.currentSearchType() if search_type == SongSearch.Entire: log.debug(u'Entire Song Search') - search_results = self.parent.manager.get_all_objects(Song, - or_(Song.search_title.like(u'%' + self.whitespace.sub(u' ', - search_keywords.lower()) + u'%'), - Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%'), - Song.comments.like(u'%' + search_keywords.lower() + u'%'))) + search_results = self.searchEntire(search_keywords) self.displayResultsSong(search_results) elif search_type == SongSearch.Titles: log.debug(u'Titles Search') @@ -201,6 +197,13 @@ class SongMediaItem(MediaManagerItem): self.displayResultsSong(search_results) check_search_result(self.listView, search_results) + def searchEntire(self, search_keywords): + return self.parent.manager.get_all_objects(Song, + or_(Song.search_title.like(u'%' + self.whitespace.sub(u' ', + search_keywords.lower()) + u'%'), + Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%'), + Song.comments.like(u'%' + search_keywords.lower() + u'%'))) + def onSongListLoad(self): """ Handle the exit from the edit dialog and trigger remote updates @@ -217,7 +220,8 @@ class SongMediaItem(MediaManagerItem): # Push edits to the service manager to update items if self.editItem and self.updateServiceOnEdit and \ not self.remoteTriggered: - item = self.buildServiceItem(self.editItem) + item_id = _getIdOfItemToGenerate(self.editItem) + item = self.buildServiceItem(item_id) self.parent.serviceManager.replaceServiceItem(item) self.onRemoteEditClear() self.onSearchTextButtonClick() @@ -475,3 +479,19 @@ class SongMediaItem(MediaManagerItem): """ return locale.strcoll(unicode(song_1.title.lower()), unicode(song_2.title.lower())) + + def hasSearch(self): + """ + Returns whether this plugin supports the search method + """ + return True + + def search(self, string): + """ + Search for some songs + """ + search_results = self.searchEntire(string) + results = [] + for song in search_results: + results.append([song.id, song.title]) + return results diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index f3c5705da..0091406d1 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -268,4 +268,3 @@ class SongsPlugin(Plugin): action_list.remove_action(self.songExportItem, UiStrings().Export) action_list.remove_action(self.toolsReindexItem, UiStrings().Tools) Plugin.finalise(self) - From 75414d2ba8e13b0c05c8b0b1fa9d5928630b9725 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 14 May 2011 13:26:05 +0100 Subject: [PATCH 2/9] Fix a couple of things --- openlp/core/lib/mediamanageritem.py | 3 ++- openlp/core/lib/pluginmanager.py | 2 +- openlp/plugins/remotes/html/index.html | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index fab50b4dc..5d9111703 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -485,7 +485,8 @@ class MediaManagerItem(QtGui.QWidget): item.setData(QtCore.Qt.UserRole, QtCore.QVariant(item_id)) serviceItem = self.buildServiceItem(item) if serviceItem: - serviceItem.from_plugin = True + if not item_id: + serviceItem.from_plugin = True self.parent.liveController.addServiceItem(serviceItem) def onAddClick(self): diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 3e1620378..682352aa5 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -45,7 +45,7 @@ class PluginManager(object): """ The constructor for the plugin manager. Passes the controllers on to the plugins for them to interact with via their ServiceItems. -pluginmanager.py + ``plugin_dir`` The directory to search for plugins. """ diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index bbb0644c3..947b135f6 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -56,7 +56,7 @@
  • -
    +
    Blank Unblank Refresh @@ -73,7 +73,7 @@
    -
    +
    Blank Unblank Refresh From 357d34a4d81022833ca3348f32b906eac7126c6d Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 14 May 2011 22:25:22 +0100 Subject: [PATCH 3/9] Remote bible search. Kludgy and probably broken something or going to conflict. Also tweaked Remote web interface --- openlp/core/lib/mediamanageritem.py | 8 ++- openlp/plugins/bibles/lib/db.py | 15 +++-- openlp/plugins/bibles/lib/http.py | 15 +++-- openlp/plugins/bibles/lib/manager.py | 48 +++++++------- openlp/plugins/bibles/lib/mediaitem.py | 82 +++++++++++++++++------- openlp/plugins/remotes/html/index.html | 40 ++++++++---- openlp/plugins/remotes/html/openlp.js | 24 ++++++- openlp/plugins/remotes/lib/httpserver.py | 2 +- 8 files changed, 155 insertions(+), 79 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 5d9111703..da01be6d1 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -481,14 +481,18 @@ class MediaManagerItem(QtGui.QWidget): log.debug(u'%s Live requested', self.plugin.name) item = None if item_id: - item = QtGui.QListWidgetItem() - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(item_id)) + item = self.createItemFromId(item_id) serviceItem = self.buildServiceItem(item) if serviceItem: if not item_id: serviceItem.from_plugin = True self.parent.liveController.addServiceItem(serviceItem) + def createItemFromId(self, item_id): + item = QtGui.QListWidgetItem() + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(item_id)) + return item + def onAddClick(self): """ Add a selected item to the current service diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index ec63dc02f..d09bc9af0 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### @@ -323,7 +323,7 @@ class BibleDB(QtCore.QObject, Manager): """ return self.get_all_objects(Book, order_by_ref=Book.id) - def get_verses(self, reference_list): + def get_verses(self, reference_list, show_error=True): """ This is probably the most used function. It retrieves the list of verses based on the user's query. @@ -360,11 +360,12 @@ class BibleDB(QtCore.QObject, Manager): verse_list.extend(verses) else: log.debug(u'OpenLP failed to find book %s', book) - critical_error_message_box( - translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching book ' - 'could be found in this Bible. Check that you have ' - 'spelled the name of the book correctly.')) + if show_error: + critical_error_message_box( + translate('BiblesPlugin', 'No Book Found'), + translate('BiblesPlugin', 'No matching book ' + 'could be found in this Bible. Check that you have ' + 'spelled the name of the book correctly.')) return verse_list def verse_search(self, text): diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 6a6ef131a..d86b650d5 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -425,7 +425,7 @@ class HTTPBible(BibleDB): self.create_meta(u'proxy password', self.proxy_password) return True - def get_verses(self, reference_list): + def get_verses(self, reference_list, show_error=True): """ A reimplementation of the ``BibleDB.get_verses`` method, this one is specifically for web Bibles. It first checks to see if the particular @@ -453,11 +453,12 @@ class HTTPBible(BibleDB): if not db_book: book_details = HTTPBooks.get_book(book) if not book_details: - critical_error_message_box( - translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching ' - 'book could be found in this Bible. Check that you ' - 'have spelled the name of the book correctly.')) + if show_error: + critical_error_message_box( + translate('BiblesPlugin', 'No Book Found'), + translate('BiblesPlugin', 'No matching ' + 'book could be found in this Bible. Check that you ' + 'have spelled the name of the book correctly.')) return [] db_book = self.create_book(book_details[u'name'], book_details[u'abbreviation'], @@ -480,7 +481,7 @@ class HTTPBible(BibleDB): Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') - return BibleDB.get_verses(self, reference_list) + return BibleDB.get_verses(self, reference_list, show_error) def get_chapter(self, book, chapter): """ diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 67469e063..4299a3d89 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -231,7 +231,7 @@ class BibleManager(object): bible, book, chapter) return self.db_cache[bible].get_verse_count(book, chapter) - def get_verses(self, bible, versetext): + def get_verses(self, bible, versetext, show_error=True): """ Parses a scripture reference, fetches the verses from the Bible specified, and returns a list of ``Verse`` objects. @@ -252,32 +252,34 @@ class BibleManager(object): """ log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext) if not bible: - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', - 'No Bibles Available'), - u'message': translate('BiblesPlugin.BibleManager', - 'There are no Bibles currently installed. Please use the ' - 'Import Wizard to install one or more Bibles.') - }) + if show_error: + Receiver.send_message(u'openlp_information_message', { + u'title': translate('BiblesPlugin.BibleManager', + 'No Bibles Available'), + u'message': translate('BiblesPlugin.BibleManager', + 'There are no Bibles currently installed. Please use the ' + 'Import Wizard to install one or more Bibles.') + }) return None reflist = parse_reference(versetext) if reflist: - return self.db_cache[bible].get_verses(reflist) + return self.db_cache[bible].get_verses(reflist, show_error) else: - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', - 'Scripture Reference Error'), - u'message': translate('BiblesPlugin.BibleManager', - 'Your scripture reference is either not supported by OpenLP ' - 'or is invalid. Please make sure your reference conforms to ' - 'one of the following patterns:\n\n' - 'Book Chapter\n' - 'Book Chapter-Chapter\n' - 'Book Chapter:Verse-Verse\n' - 'Book Chapter:Verse-Verse,Verse-Verse\n' - 'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n' - 'Book Chapter:Verse-Chapter:Verse') - }) + if show_message: + Receiver.send_message(u'openlp_information_message', { + u'title': translate('BiblesPlugin.BibleManager', + 'Scripture Reference Error'), + u'message': translate('BiblesPlugin.BibleManager', + 'Your scripture reference is either not supported by OpenLP ' + 'or is invalid. Please make sure your reference conforms to ' + 'one of the following patterns:\n\n' + 'Book Chapter\n' + 'Book Chapter-Chapter\n' + 'Book Chapter:Verse-Verse\n' + 'Book Chapter:Verse-Verse,Verse-Verse\n' + 'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n' + 'Book Chapter:Verse-Chapter:Verse') + }) return None def verse_search(self, bible, second_bible, text): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4f349c998..a169dc401 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -590,7 +590,7 @@ class BibleMediaItem(MediaManagerItem): item_second_bible = self._decodeQtObject(bitem, 'second_bible') if item_second_bible and second_bible or not item_second_bible and \ not second_bible: - self.displayResults(bible, second_bible) + self.displayResults(bible, second_bible, self_search_results) elif critical_error_message_box( message=translate('BiblePlugin.MediaItem', 'You cannot combine single and dual Bible verse search results. ' @@ -601,6 +601,18 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, second_bible) def displayResults(self, bible, second_bible=u''): + """ + Displays the search results in the media manager. All data needed for + further action is saved for/in each row. + """ + items = self.buildDisplayResults(bible, second_bible, self.search_results) + for bible_verse in items: + self.listView.addItem(bible_verse) + self.listView.selectAll() + self.search_results = {} + self.second_search_results = {} + + def buildDisplayResults(self, bible, second_bible, search_results): """ Displays the search results in the media manager. All data needed for further action is saved for/in each row. @@ -620,7 +632,8 @@ class BibleMediaItem(MediaManagerItem): second_bible, u'Copyright').value second_permissions = self.parent.manager.get_meta_data( second_bible, u'Permissions').value - for count, verse in enumerate(self.search_results): + items = [] + for count, verse in enumerate(search_results): data = { 'book': QtCore.QVariant(verse.book.name), 'chapter': QtCore.QVariant(verse.chapter), @@ -652,10 +665,8 @@ class BibleMediaItem(MediaManagerItem): verse.chapter, verse_separator, verse.verse, version) bible_verse = QtGui.QListWidgetItem(bible_text) bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) - self.listView.addItem(bible_verse) - self.listView.selectAll() - self.search_results = {} - self.second_search_results = {} + items.append(bible_verse) + return items def _decodeQtObject(self, bitem, key): reference = bitem.data(QtCore.Qt.UserRole) @@ -672,7 +683,10 @@ class BibleMediaItem(MediaManagerItem): service item's title. """ log.debug(u'generating slide data') - items = self.listView.selectedIndexes() + if item: + items = item + else: + items = self.listView.selectedItems() if len(items) == 0: return False bible_text = u'' @@ -681,8 +695,7 @@ class BibleMediaItem(MediaManagerItem): raw_slides = [] raw_title = [] verses = VerseReferenceList() - for item in items: - bitem = self.listView.item(item.row()) + for bitem in items: book = self._decodeQtObject(bitem, 'book') chapter = int(self._decodeQtObject(bitem, 'chapter')) verse = int(self._decodeQtObject(bitem, 'verse')) @@ -716,11 +729,11 @@ class BibleMediaItem(MediaManagerItem): else: bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) if not old_item: - start_item = item - elif self.checkTitle(item, old_item): + start_item = bitem + elif self.checkTitle(bitem, old_item): raw_title.append(self.formatTitle(start_item, old_item)) - start_item = item - old_item = item + start_item = bitem + old_item = bitem old_chapter = chapter # Add footer service_item.raw_footer.append(verses.format_verses()) @@ -728,7 +741,7 @@ class BibleMediaItem(MediaManagerItem): verses.add_version(second_version, second_copyright, second_permissions) service_item.raw_footer.append(verses.format_versions()) - raw_title.append(self.formatTitle(start_item, item)) + raw_title.append(self.formatTitle(start_item, bitem)) # If there are no more items we check whether we have to add bible_text. if bible_text: raw_slides.append(bible_text.lstrip()) @@ -751,9 +764,9 @@ class BibleMediaItem(MediaManagerItem): [service_item.add_from_text(slide[:30], slide) for slide in raw_slides] return True - def formatTitle(self, start_item, old_item): + def formatTitle(self, start_bitem, old_bitem): """ - This methode is called, when we have to change the title, because + This method is called, when we have to change the title, because we are at the end of a verse range. E. g. if we want to add Genesis 1:1-6 as well as Daniel 2:14. @@ -765,10 +778,8 @@ class BibleMediaItem(MediaManagerItem): """ verse_separator = get_reference_match(u'sep_v_display') range_separator = get_reference_match(u'sep_r_display') - old_bitem = self.listView.item(old_item.row()) old_chapter = self._decodeQtObject(old_bitem, 'chapter') old_verse = self._decodeQtObject(old_bitem, 'verse') - start_bitem = self.listView.item(start_item.row()) start_book = self._decodeQtObject(start_bitem, 'book') start_chapter = self._decodeQtObject(start_bitem, 'chapter') start_verse = self._decodeQtObject(start_bitem, 'verse') @@ -789,9 +800,9 @@ class BibleMediaItem(MediaManagerItem): range_separator + old_chapter + verse_separator + old_verse return u'%s %s (%s)' % (start_book, verse_range, bibles) - def checkTitle(self, item, old_item): + def checkTitle(self, bitem, old_bitem): """ - This methode checks if we are at the end of an verse range. If that is + This method checks if we are at the end of an verse range. If that is the case, we return True, otherwise False. E. g. if we added Genesis 1:1-6, but the next verse is Daniel 2:14, we return True. @@ -802,13 +813,11 @@ class BibleMediaItem(MediaManagerItem): The item we were previously dealing with. """ # Get all the necessary meta data. - bitem = self.listView.item(item.row()) book = self._decodeQtObject(bitem, 'book') chapter = int(self._decodeQtObject(bitem, 'chapter')) verse = int(self._decodeQtObject(bitem, 'verse')) bible = self._decodeQtObject(bitem, 'bible') second_bible = self._decodeQtObject(bitem, 'second_bible') - old_bitem = self.listView.item(old_item.row()) old_book = self._decodeQtObject(old_bitem, 'book') old_chapter = int(self._decodeQtObject(old_bitem, 'chapter')) old_verse = int(self._decodeQtObject(old_bitem, 'verse')) @@ -868,3 +877,32 @@ class BibleMediaItem(MediaManagerItem): QtCore.QSettings().setValue( self.settingsSection + u'/verse layout style', QtCore.QVariant(self.settings.layout_style)) + + def hasSearch(self): + """ + Returns whether this plugin supports the search method + """ + return True + + def search(self, string): + """ + Search for some Bible verses (by reference). + """ + bible = unicode(self.quickVersionComboBox.currentText()) + search_results = self.parent.manager.get_verses(bible, string, False) + results = [] + if search_results: + versetext = u'' + for verse in search_results: + if versetext: + versetext += u' ' + versetext += verse.text + results.append([string, versetext]) + return results + + def createItemFromId(self, item_id): + item = QtGui.QListWidgetItem() + bible = unicode(self.quickVersionComboBox.currentText()) + search_results = self.parent.manager.get_verses(bible, item_id, False) + items = self.buildDisplayResults(bible, u'', search_results) + return items diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 947b135f6..b07aaec8c 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -51,34 +51,42 @@
    Back

    Service Manager

    -
    + Refresh +
    +
    Back

    Slide Controller

    + Refresh
    +
    -
    +
    @@ -101,8 +109,12 @@
    - - + + +
    +
    + +
    Search
    +
    -
    - Previous Slide - Next Slide + Blank + Show + Prev + Next
    @@ -75,18 +71,14 @@ Refresh
    - -
    +
    - Previous Song - Next Song + Blank + Show + Prev + Next
    @@ -113,7 +105,7 @@
    - +
    Search diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 69a213fa2..04945425b 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -247,8 +247,6 @@ $("#service-next").live("click", OpenLP.nextItem); $("#service-previous").live("click", OpenLP.previousItem); $("#service-blank").live("click", OpenLP.blankDisplay); $("#service-unblank").live("click", OpenLP.unblankDisplay); -$("#service-nextslide").live("click", OpenLP.nextSlide); -$("#service-previousslide").live("click", OpenLP.previousSlide); // Slide Controller $("#slide-controller").live("pagebeforeshow", OpenLP.loadController); $("#controller-refresh").live("click", OpenLP.loadController); @@ -256,8 +254,6 @@ $("#controller-next").live("click", OpenLP.nextSlide); $("#controller-previous").live("click", OpenLP.previousSlide); $("#controller-blank").live("click", OpenLP.blankDisplay); $("#controller-unblank").live("click", OpenLP.unblankDisplay); -$("#controller-nextsong").live("click", OpenLP.nextItem); -$("#controller-previoussong").live("click", OpenLP.previousItem); // Alerts $("#alert-submit").live("click", OpenLP.showAlert); // Search diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 259ecfe49..e1e2857bf 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -457,7 +457,7 @@ class HttpConnection(object): searches = [] for plugin in self.parent.parent.pluginManager.plugins: media_item = plugin.mediaItem - if media_item and media_item.hasSearch(): + if media_item and media_item.hasSearch: searches.append(plugin.name) return HttpResponse( json.dumps({u'results': {u'items': searches}}), @@ -473,7 +473,7 @@ class HttpConnection(object): text = json.loads(self.url_params[u'data'][0])[u'request'][u'text'] plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) media_item = plugin.mediaItem - if media_item and media_item.hasSearch(): + if media_item and media_item.hasSearch: results = media_item.search(text) return HttpResponse( json.dumps({u'results': {u'items': results}}), diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index ccd68705a..66d2b5630 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -74,6 +74,7 @@ class SongMediaItem(MediaManagerItem): self.editItem = None self.whitespace = re.compile(r'\W+', re.UNICODE) self.quickPreviewAllowed = True + self.hasSearch = True def addEndHeaderBar(self): self.addToolbarSeparator() @@ -480,12 +481,6 @@ class SongMediaItem(MediaManagerItem): return locale.strcoll(unicode(song_1.title.lower()), unicode(song_2.title.lower())) - def hasSearch(self): - """ - Returns whether this plugin supports the search method - """ - return True - def search(self, string): """ Search for some songs From 2655c1b13356df12154ff5fbfcc7dd9d96f6b29a Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 15 May 2011 21:03:45 +0100 Subject: [PATCH 5/9] Remote searches presentations, media and images --- openlp/plugins/images/lib/mediaitem.py | 98 +++++++++++-------- openlp/plugins/media/lib/mediaitem.py | 12 +++ openlp/plugins/presentations/lib/mediaitem.py | 22 ++++- 3 files changed, 84 insertions(+), 48 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 21b81128d..1377feef8 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -47,6 +47,7 @@ class ImageMediaItem(MediaManagerItem): self.IconPath = u'images/image' MediaManagerItem.__init__(self, parent, self, icon) self.quickPreviewAllowed = True + self.hasSearch = True QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged) @@ -130,51 +131,51 @@ class ImageMediaItem(MediaManagerItem): self.parent.formparent.finishedProgressBar() def generateSlideData(self, service_item, item=None, xmlVersion=False): - items = self.listView.selectedIndexes() - if items: - service_item.title = unicode(self.plugin.nameStrings[u'plural']) - service_item.add_capability(ItemCapabilities.AllowsMaintain) - service_item.add_capability(ItemCapabilities.AllowsPreview) - service_item.add_capability(ItemCapabilities.AllowsLoop) - service_item.add_capability(ItemCapabilities.AllowsAdditions) - # force a nonexistent theme - service_item.theme = -1 - missing_items = [] - missing_items_filenames = [] - for item in items: - bitem = self.listView.item(item.row()) - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) - if not os.path.exists(filename): - missing_items.append(item) - missing_items_filenames.append(filename) - for item in missing_items: - items.remove(item) - # We cannot continue, as all images do not exist. - if not items: - critical_error_message_box( - translate('ImagePlugin.MediaItem', 'Missing Image(s)'), - unicode(translate('ImagePlugin.MediaItem', - 'The following image(s) no longer exist: %s')) % - u'\n'.join(missing_items_filenames)) - return False - # We have missing as well as existing images. We ask what to do. - elif missing_items and QtGui.QMessageBox.question(self, - translate('ImagePlugin.MediaItem', 'Missing Image(s)'), - unicode(translate('ImagePlugin.MediaItem', 'The following ' - 'image(s) no longer exist: %s\nDo you want to add the other ' - 'images anyway?')) % u'\n'.join(missing_items_filenames), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | - QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: - return False - # Continue with the existing images. - for item in items: - bitem = self.listView.item(item.row()) - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) - (path, name) = os.path.split(filename) - service_item.add_from_image(filename, name) - return True + if item: + items = [item] else: + items = self.listView.selectedItems() + if not items: + return False + service_item.title = unicode(self.plugin.nameStrings[u'plural']) + service_item.add_capability(ItemCapabilities.AllowsMaintain) + service_item.add_capability(ItemCapabilities.AllowsPreview) + service_item.add_capability(ItemCapabilities.AllowsLoop) + service_item.add_capability(ItemCapabilities.AllowsAdditions) + # force a nonexistent theme + service_item.theme = -1 + missing_items = [] + missing_items_filenames = [] + for bitem in items: + filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + if not os.path.exists(filename): + missing_items.append(item) + missing_items_filenames.append(filename) + for item in missing_items: + items.remove(item) + # We cannot continue, as all images do not exist. + if not items: + critical_error_message_box( + translate('ImagePlugin.MediaItem', 'Missing Image(s)'), + unicode(translate('ImagePlugin.MediaItem', + 'The following image(s) no longer exist: %s')) % + u'\n'.join(missing_items_filenames)) return False + # We have missing as well as existing images. We ask what to do. + elif missing_items and QtGui.QMessageBox.question(self, + translate('ImagePlugin.MediaItem', 'Missing Image(s)'), + unicode(translate('ImagePlugin.MediaItem', 'The following ' + 'image(s) no longer exist: %s\nDo you want to add the other ' + 'images anyway?')) % u'\n'.join(missing_items_filenames), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | + QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: + return False + # Continue with the existing images. + for bitem in items: + filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + (path, name) = os.path.split(filename) + service_item.add_from_image(filename, name) + return True def onResetClick(self): """ @@ -208,3 +209,14 @@ class ImageMediaItem(MediaManagerItem): unicode(translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' 'the image file "%s" no longer exists.')) % filename) + + def search(self, string): + list = SettingsManager.load_list(self.settingsSection, + self.settingsSection) + results = [] + string = string.lower() + for file in list: + filename = os.path.split(unicode(file))[1] + if filename.lower().find(string) > -1: + results.append([file, filename]) + return results diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index aa574d029..9f1d72f73 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -50,6 +50,7 @@ class MediaMediaItem(MediaManagerItem): u':/media/media_video.png').toImage() MediaManagerItem.__init__(self, parent, self, icon) self.singleServiceItem = False + self.hasSearch = True self.mediaObject = None QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'), @@ -212,3 +213,14 @@ class MediaMediaItem(MediaManagerItem): log.debug(u'CreatePhonon') if not self.mediaObject: self.mediaObject = Phonon.MediaObject(self) + + def search(self, string): + list = SettingsManager.load_list(self.settingsSection, + self.settingsSection) + results = [] + string = string.lower() + for file in list: + filename = os.path.split(unicode(file))[1] + if filename.lower().find(string) > -1: + results.append([file, filename]) + return results diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 65b85454d..7660c9099 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -53,6 +53,7 @@ class PresentationMediaItem(MediaManagerItem): self.Automatic = u'' MediaManagerItem.__init__(self, parent, self, icon) self.message_listener = MessageListener(self) + self.hasSearch = True QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), self.rebuild) @@ -231,17 +232,19 @@ class PresentationMediaItem(MediaManagerItem): in the slidecontroller. In the case of powerpoints, an image for each slide """ - items = self.listView.selectedIndexes() - if len(items) > 1: - return False + if item: + items = [item] + else: + items = self.listView.selectedItems() + if len(items) > 1: + return False service_item.title = unicode(self.displayTypeComboBox.currentText()) service_item.shortname = unicode(self.displayTypeComboBox.currentText()) service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay) shortname = service_item.shortname if shortname: - for item in items: - bitem = self.listView.item(item.row()) + for bitem in items: filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filename): if shortname == self.Automatic: @@ -303,3 +306,12 @@ class PresentationMediaItem(MediaManagerItem): if filetype in self.controllers[controller].alsosupports: return controller return None + + def search(self, string): + list = SettingsManager.load_list(self.settingsSection, u'presentations') + results = [] + string = string.lower() + for file in list: + if file.lower().find(string) > -1: + results.append([file, file]) + return results From 274c4ee87a22f73b887ec5db3b192958c3367304 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 15 May 2011 21:53:25 +0100 Subject: [PATCH 6/9] tidies --- openlp/core/lib/mediamanageritem.py | 2 +- openlp/plugins/bibles/lib/db.py | 6 +++--- openlp/plugins/bibles/lib/manager.py | 6 +++--- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index d9a037122..2e514935f 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -605,4 +605,4 @@ class MediaManagerItem(QtGui.QWidget): Performs a plugin specific search for items containing ``string`` """ raise NotImplementedError( - u'Plugin.about needs to be defined by the plugin') + u'Plugin.search needs to be defined by the plugin') diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index d09bc9af0..175cdf098 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -1,4 +1,4 @@ - # -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### @@ -364,8 +364,8 @@ class BibleDB(QtCore.QObject, Manager): critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), translate('BiblesPlugin', 'No matching book ' - 'could be found in this Bible. Check that you have ' - 'spelled the name of the book correctly.')) + 'could be found in this Bible. Check that you ' + 'have spelled the name of the book correctly.')) return verse_list def verse_search(self, text): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 4299a3d89..fb83b7b7d 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -270,9 +270,9 @@ class BibleManager(object): u'title': translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), u'message': translate('BiblesPlugin.BibleManager', - 'Your scripture reference is either not supported by OpenLP ' - 'or is invalid. Please make sure your reference conforms to ' - 'one of the following patterns:\n\n' + 'Your scripture reference is either not supported by ' + 'OpenLP or is invalid. Please make sure your reference ' + 'conforms to one of the following patterns:\n\n' 'Book Chapter\n' 'Book Chapter-Chapter\n' 'Book Chapter:Verse-Verse\n' diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 9e5e64a66..4feac5208 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -651,7 +651,8 @@ class BibleMediaItem(MediaManagerItem): Displays the search results in the media manager. All data needed for further action is saved for/in each row. """ - items = self.buildDisplayResults(bible, second_bible, self.search_results) + items = self.buildDisplayResults(bible, second_bible, + self.search_results) for bible_verse in items: self.listView.addItem(bible_verse) self.listView.selectAll() From 5fcb41bc9df557ca84eaadcd1e9b036b62dbc149 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Mon, 16 May 2011 22:01:21 +0100 Subject: [PATCH 7/9] fixes --- openlp/plugins/remotes/html/openlp.js | 4 ++-- openlp/plugins/remotes/lib/httpserver.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 04945425b..57c770447 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -39,7 +39,7 @@ window.OpenLP = { } return $(targ); }, - searchPlugins: function (event) { + getSearchablePlugins: function (event) { $.getJSON( "/api/plugin/search", function (data, status) { @@ -259,7 +259,7 @@ $("#alert-submit").live("click", OpenLP.showAlert); // Search $("#search-submit").live("click", OpenLP.search); // Poll the server twice a second to get any updates. -OpenLP.searchPlugins(); +OpenLP.getSearchablePlugins(); $.ajaxSetup({ cache: false }); setInterval("OpenLP.pollServer();", 500); OpenLP.pollServer(); diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index e1e2857bf..122ea64b4 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -251,7 +251,7 @@ class HttpConnection(object): (r'^/api/service/(.*)$', self.service), (r'^/api/display/(hide|show)$', self.display), (r'^/api/alert$', self.alert), - (r'^/api/plugin/(search)$', self.plugin), + (r'^/api/plugin/(search)$', self.pluginInfo), (r'^/api/(.*)/search$', self.search), (r'^/api/(.*)/live$', self.go_live) ] @@ -446,9 +446,9 @@ class HttpConnection(object): return HttpResponse(json.dumps({u'results': {u'success': True}}), {u'Content-Type': u'application/json'}) - def plugin(self, action): + def pluginInfo(self, action): """ - Return plugin related actions + Return plugin related information, based on the action ``action`` - The action to perform if 'search' return a list of plugin names which support search From 7a857290a67f12487df56f37fb96da513fc9fcd8 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Tue, 17 May 2011 19:48:04 +0100 Subject: [PATCH 8/9] More fixes --- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 10 +++------- openlp/plugins/remotes/lib/httpserver.py | 25 ++++++++++++------------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index fb83b7b7d..da23c8d25 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -265,7 +265,7 @@ class BibleManager(object): if reflist: return self.db_cache[bible].get_verses(reflist, show_error) else: - if show_message: + if show_error: Receiver.send_message(u'openlp_information_message', { u'title': translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4feac5208..9a9e3f9ec 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -916,13 +916,9 @@ class BibleMediaItem(MediaManagerItem): search_results = self.parent.manager.get_verses(bible, string, False) results = [] if search_results: - versetext = u'' - for verse in search_results: - if versetext: - versetext += u' ' - versetext += verse.text - results.append([string, versetext]) - return results + versetext = u' '.join([verse.text for verse in search_results]) + return [[string, versetext]] + return [] def createItemFromId(self, item_id): item = QtGui.QListWidgetItem() diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 122ea64b4..224a2513e 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -123,7 +123,7 @@ except ImportError: from PyQt4 import QtCore, QtNetwork -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, PluginStatus from openlp.core.ui import HideMode from openlp.core.utils import AppLocation @@ -456,8 +456,8 @@ class HttpConnection(object): if action == u'search': searches = [] for plugin in self.parent.parent.pluginManager.plugins: - media_item = plugin.mediaItem - if media_item and media_item.hasSearch: + if plugin.status == PluginStatus.Active and \ + plugin.mediaItem and plugin.mediaItem.hasSearch: searches.append(plugin.name) return HttpResponse( json.dumps({u'results': {u'items': searches}}), @@ -472,12 +472,14 @@ class HttpConnection(object): """ text = json.loads(self.url_params[u'data'][0])[u'request'][u'text'] plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) - media_item = plugin.mediaItem - if media_item and media_item.hasSearch: - results = media_item.search(text) - return HttpResponse( - json.dumps({u'results': {u'items': results}}), - {u'Content-Type': u'application/json'}) + if plugin.status == PluginStatus.Active and \ + plugin.mediaItem and plugin.mediaItem.hasSearch: + results =plugin.mediaItem.search(text) + else: + results = [] + return HttpResponse( + json.dumps({u'results': {u'items': results}}), + {u'Content-Type': u'application/json'}) def go_live(self, type): """ @@ -485,9 +487,8 @@ class HttpConnection(object): """ id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) - media_item = plugin.mediaItem - if media_item: - media_item.goLive(id) + if plugin.status == PluginStatus.Active and plugin.mediaItem: + plugin.mediaItem.goLive(id) def send_response(self, response): http = u'HTTP/1.1 %s\r\n' % response.code From 2d5d16b40b2cd37cf462f246dd69d7db79d940c1 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Tue, 17 May 2011 23:00:50 +0100 Subject: [PATCH 9/9] Return filename in text for non-text types. Display verse tag in remote view --- openlp/plugins/remotes/html/openlp.js | 4 +++- openlp/plugins/remotes/lib/httpserver.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 57c770447..4eee047a4 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -76,7 +76,9 @@ window.OpenLP = { var ul = $("#slide-controller > div[data-role=content] > ul[data-role=listview]"); ul.html(""); for (idx in data.results.slides) { - var text = data.results.slides[idx]["text"]; + var text = data.results.slides[idx]["tag"]; + if (text != "") text = text + ": "; + text = text + data.results.slides[idx]["text"]; text = text.replace(/\n/g, '
    '); var li = $("
  • ").append( $("").attr("value", parseInt(idx, 10)).html(text)); diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 224a2513e..351e7f905 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -412,8 +412,8 @@ class HttpConnection(object): item[u'html'] = unicode(frame[u'html']) else: item[u'tag'] = unicode(index + 1) - item[u'text'] = u'' - item[u'html'] = u'' + item[u'text'] = unicode(frame[u'title']) + item[u'html'] = unicode(frame[u'title']) item[u'selected'] = (self.parent.current_slide == index) data.append(item) json_data = {u'results': {u'slides': data}}