forked from openlp/openlp
Remote bible search. Kludgy and probably broken something or going to conflict. Also tweaked Remote web interface
This commit is contained in:
parent
75414d2ba8
commit
357d34a4d8
@ -481,14 +481,18 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
log.debug(u'%s Live requested', self.plugin.name)
|
log.debug(u'%s Live requested', self.plugin.name)
|
||||||
item = None
|
item = None
|
||||||
if item_id:
|
if item_id:
|
||||||
item = QtGui.QListWidgetItem()
|
item = self.createItemFromId(item_id)
|
||||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(item_id))
|
|
||||||
serviceItem = self.buildServiceItem(item)
|
serviceItem = self.buildServiceItem(item)
|
||||||
if serviceItem:
|
if serviceItem:
|
||||||
if not item_id:
|
if not item_id:
|
||||||
serviceItem.from_plugin = True
|
serviceItem.from_plugin = True
|
||||||
self.parent.liveController.addServiceItem(serviceItem)
|
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):
|
def onAddClick(self):
|
||||||
"""
|
"""
|
||||||
Add a selected item to the current service
|
Add a selected item to the current service
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
# 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)
|
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
|
This is probably the most used function. It retrieves the list of
|
||||||
verses based on the user's query.
|
verses based on the user's query.
|
||||||
@ -360,11 +360,12 @@ class BibleDB(QtCore.QObject, Manager):
|
|||||||
verse_list.extend(verses)
|
verse_list.extend(verses)
|
||||||
else:
|
else:
|
||||||
log.debug(u'OpenLP failed to find book %s', book)
|
log.debug(u'OpenLP failed to find book %s', book)
|
||||||
critical_error_message_box(
|
if show_error:
|
||||||
translate('BiblesPlugin', 'No Book Found'),
|
critical_error_message_box(
|
||||||
translate('BiblesPlugin', 'No matching book '
|
translate('BiblesPlugin', 'No Book Found'),
|
||||||
'could be found in this Bible. Check that you have '
|
translate('BiblesPlugin', 'No matching book '
|
||||||
'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
|
return verse_list
|
||||||
|
|
||||||
def verse_search(self, text):
|
def verse_search(self, text):
|
||||||
|
@ -425,7 +425,7 @@ class HTTPBible(BibleDB):
|
|||||||
self.create_meta(u'proxy password', self.proxy_password)
|
self.create_meta(u'proxy password', self.proxy_password)
|
||||||
return True
|
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
|
A reimplementation of the ``BibleDB.get_verses`` method, this one is
|
||||||
specifically for web Bibles. It first checks to see if the particular
|
specifically for web Bibles. It first checks to see if the particular
|
||||||
@ -453,11 +453,12 @@ class HTTPBible(BibleDB):
|
|||||||
if not db_book:
|
if not db_book:
|
||||||
book_details = HTTPBooks.get_book(book)
|
book_details = HTTPBooks.get_book(book)
|
||||||
if not book_details:
|
if not book_details:
|
||||||
critical_error_message_box(
|
if show_error:
|
||||||
translate('BiblesPlugin', 'No Book Found'),
|
critical_error_message_box(
|
||||||
translate('BiblesPlugin', 'No matching '
|
translate('BiblesPlugin', 'No Book Found'),
|
||||||
'book could be found in this Bible. Check that you '
|
translate('BiblesPlugin', 'No matching '
|
||||||
'have spelled the name of the book correctly.'))
|
'book could be found in this Bible. Check that you '
|
||||||
|
'have spelled the name of the book correctly.'))
|
||||||
return []
|
return []
|
||||||
db_book = self.create_book(book_details[u'name'],
|
db_book = self.create_book(book_details[u'name'],
|
||||||
book_details[u'abbreviation'],
|
book_details[u'abbreviation'],
|
||||||
@ -480,7 +481,7 @@ class HTTPBible(BibleDB):
|
|||||||
Receiver.send_message(u'openlp_process_events')
|
Receiver.send_message(u'openlp_process_events')
|
||||||
Receiver.send_message(u'cursor_normal')
|
Receiver.send_message(u'cursor_normal')
|
||||||
Receiver.send_message(u'openlp_process_events')
|
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):
|
def get_chapter(self, book, chapter):
|
||||||
"""
|
"""
|
||||||
|
@ -231,7 +231,7 @@ class BibleManager(object):
|
|||||||
bible, book, chapter)
|
bible, book, chapter)
|
||||||
return self.db_cache[bible].get_verse_count(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
|
Parses a scripture reference, fetches the verses from the Bible
|
||||||
specified, and returns a list of ``Verse`` objects.
|
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)
|
log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext)
|
||||||
if not bible:
|
if not bible:
|
||||||
Receiver.send_message(u'openlp_information_message', {
|
if show_error:
|
||||||
u'title': translate('BiblesPlugin.BibleManager',
|
Receiver.send_message(u'openlp_information_message', {
|
||||||
'No Bibles Available'),
|
u'title': translate('BiblesPlugin.BibleManager',
|
||||||
u'message': translate('BiblesPlugin.BibleManager',
|
'No Bibles Available'),
|
||||||
'There are no Bibles currently installed. Please use the '
|
u'message': translate('BiblesPlugin.BibleManager',
|
||||||
'Import Wizard to install one or more Bibles.')
|
'There are no Bibles currently installed. Please use the '
|
||||||
})
|
'Import Wizard to install one or more Bibles.')
|
||||||
|
})
|
||||||
return None
|
return None
|
||||||
reflist = parse_reference(versetext)
|
reflist = parse_reference(versetext)
|
||||||
if reflist:
|
if reflist:
|
||||||
return self.db_cache[bible].get_verses(reflist)
|
return self.db_cache[bible].get_verses(reflist, show_error)
|
||||||
else:
|
else:
|
||||||
Receiver.send_message(u'openlp_information_message', {
|
if show_message:
|
||||||
u'title': translate('BiblesPlugin.BibleManager',
|
Receiver.send_message(u'openlp_information_message', {
|
||||||
'Scripture Reference Error'),
|
u'title': translate('BiblesPlugin.BibleManager',
|
||||||
u'message': translate('BiblesPlugin.BibleManager',
|
'Scripture Reference Error'),
|
||||||
'Your scripture reference is either not supported by OpenLP '
|
u'message': translate('BiblesPlugin.BibleManager',
|
||||||
'or is invalid. Please make sure your reference conforms to '
|
'Your scripture reference is either not supported by OpenLP '
|
||||||
'one of the following patterns:\n\n'
|
'or is invalid. Please make sure your reference conforms to '
|
||||||
'Book Chapter\n'
|
'one of the following patterns:\n\n'
|
||||||
'Book Chapter-Chapter\n'
|
'Book Chapter\n'
|
||||||
'Book Chapter:Verse-Verse\n'
|
'Book Chapter-Chapter\n'
|
||||||
'Book Chapter:Verse-Verse,Verse-Verse\n'
|
'Book Chapter:Verse-Verse\n'
|
||||||
'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n'
|
'Book Chapter:Verse-Verse,Verse-Verse\n'
|
||||||
'Book Chapter:Verse-Chapter:Verse')
|
'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n'
|
||||||
})
|
'Book Chapter:Verse-Chapter:Verse')
|
||||||
|
})
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def verse_search(self, bible, second_bible, text):
|
def verse_search(self, bible, second_bible, text):
|
||||||
|
@ -590,7 +590,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
|
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
|
||||||
if item_second_bible and second_bible or not item_second_bible and \
|
if item_second_bible and second_bible or not item_second_bible and \
|
||||||
not second_bible:
|
not second_bible:
|
||||||
self.displayResults(bible, second_bible)
|
self.displayResults(bible, second_bible, self_search_results)
|
||||||
elif critical_error_message_box(
|
elif critical_error_message_box(
|
||||||
message=translate('BiblePlugin.MediaItem',
|
message=translate('BiblePlugin.MediaItem',
|
||||||
'You cannot combine single and dual Bible verse search results. '
|
'You cannot combine single and dual Bible verse search results. '
|
||||||
@ -601,6 +601,18 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.displayResults(bible, second_bible)
|
self.displayResults(bible, second_bible)
|
||||||
|
|
||||||
def displayResults(self, bible, second_bible=u''):
|
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
|
Displays the search results in the media manager. All data needed for
|
||||||
further action is saved for/in each row.
|
further action is saved for/in each row.
|
||||||
@ -620,7 +632,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
second_bible, u'Copyright').value
|
second_bible, u'Copyright').value
|
||||||
second_permissions = self.parent.manager.get_meta_data(
|
second_permissions = self.parent.manager.get_meta_data(
|
||||||
second_bible, u'Permissions').value
|
second_bible, u'Permissions').value
|
||||||
for count, verse in enumerate(self.search_results):
|
items = []
|
||||||
|
for count, verse in enumerate(search_results):
|
||||||
data = {
|
data = {
|
||||||
'book': QtCore.QVariant(verse.book.name),
|
'book': QtCore.QVariant(verse.book.name),
|
||||||
'chapter': QtCore.QVariant(verse.chapter),
|
'chapter': QtCore.QVariant(verse.chapter),
|
||||||
@ -652,10 +665,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
verse.chapter, verse_separator, verse.verse, version)
|
verse.chapter, verse_separator, verse.verse, version)
|
||||||
bible_verse = QtGui.QListWidgetItem(bible_text)
|
bible_verse = QtGui.QListWidgetItem(bible_text)
|
||||||
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
||||||
self.listView.addItem(bible_verse)
|
items.append(bible_verse)
|
||||||
self.listView.selectAll()
|
return items
|
||||||
self.search_results = {}
|
|
||||||
self.second_search_results = {}
|
|
||||||
|
|
||||||
def _decodeQtObject(self, bitem, key):
|
def _decodeQtObject(self, bitem, key):
|
||||||
reference = bitem.data(QtCore.Qt.UserRole)
|
reference = bitem.data(QtCore.Qt.UserRole)
|
||||||
@ -672,7 +683,10 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
service item's title.
|
service item's title.
|
||||||
"""
|
"""
|
||||||
log.debug(u'generating slide data')
|
log.debug(u'generating slide data')
|
||||||
items = self.listView.selectedIndexes()
|
if item:
|
||||||
|
items = item
|
||||||
|
else:
|
||||||
|
items = self.listView.selectedItems()
|
||||||
if len(items) == 0:
|
if len(items) == 0:
|
||||||
return False
|
return False
|
||||||
bible_text = u''
|
bible_text = u''
|
||||||
@ -681,8 +695,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
raw_slides = []
|
raw_slides = []
|
||||||
raw_title = []
|
raw_title = []
|
||||||
verses = VerseReferenceList()
|
verses = VerseReferenceList()
|
||||||
for item in items:
|
for bitem in items:
|
||||||
bitem = self.listView.item(item.row())
|
|
||||||
book = self._decodeQtObject(bitem, 'book')
|
book = self._decodeQtObject(bitem, 'book')
|
||||||
chapter = int(self._decodeQtObject(bitem, 'chapter'))
|
chapter = int(self._decodeQtObject(bitem, 'chapter'))
|
||||||
verse = int(self._decodeQtObject(bitem, 'verse'))
|
verse = int(self._decodeQtObject(bitem, 'verse'))
|
||||||
@ -716,11 +729,11 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
else:
|
else:
|
||||||
bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
|
bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
|
||||||
if not old_item:
|
if not old_item:
|
||||||
start_item = item
|
start_item = bitem
|
||||||
elif self.checkTitle(item, old_item):
|
elif self.checkTitle(bitem, old_item):
|
||||||
raw_title.append(self.formatTitle(start_item, old_item))
|
raw_title.append(self.formatTitle(start_item, old_item))
|
||||||
start_item = item
|
start_item = bitem
|
||||||
old_item = item
|
old_item = bitem
|
||||||
old_chapter = chapter
|
old_chapter = chapter
|
||||||
# Add footer
|
# Add footer
|
||||||
service_item.raw_footer.append(verses.format_verses())
|
service_item.raw_footer.append(verses.format_verses())
|
||||||
@ -728,7 +741,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
verses.add_version(second_version, second_copyright,
|
verses.add_version(second_version, second_copyright,
|
||||||
second_permissions)
|
second_permissions)
|
||||||
service_item.raw_footer.append(verses.format_versions())
|
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 there are no more items we check whether we have to add bible_text.
|
||||||
if bible_text:
|
if bible_text:
|
||||||
raw_slides.append(bible_text.lstrip())
|
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]
|
[service_item.add_from_text(slide[:30], slide) for slide in raw_slides]
|
||||||
return True
|
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
|
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.
|
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')
|
verse_separator = get_reference_match(u'sep_v_display')
|
||||||
range_separator = get_reference_match(u'sep_r_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_chapter = self._decodeQtObject(old_bitem, 'chapter')
|
||||||
old_verse = self._decodeQtObject(old_bitem, 'verse')
|
old_verse = self._decodeQtObject(old_bitem, 'verse')
|
||||||
start_bitem = self.listView.item(start_item.row())
|
|
||||||
start_book = self._decodeQtObject(start_bitem, 'book')
|
start_book = self._decodeQtObject(start_bitem, 'book')
|
||||||
start_chapter = self._decodeQtObject(start_bitem, 'chapter')
|
start_chapter = self._decodeQtObject(start_bitem, 'chapter')
|
||||||
start_verse = self._decodeQtObject(start_bitem, 'verse')
|
start_verse = self._decodeQtObject(start_bitem, 'verse')
|
||||||
@ -789,9 +800,9 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
range_separator + old_chapter + verse_separator + old_verse
|
range_separator + old_chapter + verse_separator + old_verse
|
||||||
return u'%s %s (%s)' % (start_book, verse_range, bibles)
|
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
|
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.
|
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.
|
The item we were previously dealing with.
|
||||||
"""
|
"""
|
||||||
# Get all the necessary meta data.
|
# Get all the necessary meta data.
|
||||||
bitem = self.listView.item(item.row())
|
|
||||||
book = self._decodeQtObject(bitem, 'book')
|
book = self._decodeQtObject(bitem, 'book')
|
||||||
chapter = int(self._decodeQtObject(bitem, 'chapter'))
|
chapter = int(self._decodeQtObject(bitem, 'chapter'))
|
||||||
verse = int(self._decodeQtObject(bitem, 'verse'))
|
verse = int(self._decodeQtObject(bitem, 'verse'))
|
||||||
bible = self._decodeQtObject(bitem, 'bible')
|
bible = self._decodeQtObject(bitem, 'bible')
|
||||||
second_bible = self._decodeQtObject(bitem, 'second_bible')
|
second_bible = self._decodeQtObject(bitem, 'second_bible')
|
||||||
old_bitem = self.listView.item(old_item.row())
|
|
||||||
old_book = self._decodeQtObject(old_bitem, 'book')
|
old_book = self._decodeQtObject(old_bitem, 'book')
|
||||||
old_chapter = int(self._decodeQtObject(old_bitem, 'chapter'))
|
old_chapter = int(self._decodeQtObject(old_bitem, 'chapter'))
|
||||||
old_verse = int(self._decodeQtObject(old_bitem, 'verse'))
|
old_verse = int(self._decodeQtObject(old_bitem, 'verse'))
|
||||||
@ -868,3 +877,32 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
QtCore.QSettings().setValue(
|
QtCore.QSettings().setValue(
|
||||||
self.settingsSection + u'/verse layout style',
|
self.settingsSection + u'/verse layout style',
|
||||||
QtCore.QVariant(self.settings.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
|
||||||
|
@ -51,34 +51,42 @@
|
|||||||
<div data-role="header">
|
<div data-role="header">
|
||||||
<a href="#" data-rel="back" data-icon="arrow-l">Back</a>
|
<a href="#" data-rel="back" data-icon="arrow-l">Back</a>
|
||||||
<h1>Service Manager</h1>
|
<h1>Service Manager</h1>
|
||||||
</div>
|
<a href="#" id="service-refresh" data-role="button" data-icon="refresh">Refresh</a>
|
||||||
|
</div>
|
||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
|
<div class="ui-grid-c">
|
||||||
|
<div class="ui-block-a"><a href="#" id="service-blank" data-role="button" data-icon="blank">Blank</a></div>
|
||||||
|
<div class="ui-block-b"><a href="#" id="service-unblank" data-role="button" data-icon="unblank">Unblank</a></div>
|
||||||
|
<div class="ui-block-c"><a href="#" id="service-previous" data-role="button" data-icon="arrow-l">Previous</a></div>
|
||||||
|
<div class="ui-block-d"><a href="#" id="service-next" data-role="button" data-icon="arrow-r" data-iconpos="right">Next</a></div>
|
||||||
|
</div>
|
||||||
<ul data-role="listview" data-inset="true">
|
<ul data-role="listview" data-inset="true">
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div data-role="footer" data-theme="b" class="ui-bar">
|
<div data-role="footer" data-theme="b" class="ui-bar">
|
||||||
<a href="#" id="service-blank" data-role="button" data-icon="blank">Blank</a>
|
<a href="#" id="service-previousslide" data-role="button" data-icon="arrow-l">Previous Slide</a>
|
||||||
<a href="#" id="service-unblank" data-role="button" data-icon="unblank">Unblank</a>
|
<a href="#" class="ui-btn-right" id="service-nextslide" data-role="button" data-icon="arrow-r" data-iconpos="right">Next Slide</a>
|
||||||
<a href="#" id="service-refresh" data-role="button" data-icon="refresh">Refresh</a>
|
|
||||||
<a href="#" id="service-previous" data-role="button" data-icon="arrow-l">Previous</a>
|
|
||||||
<a href="#" id="service-next" data-role="button" data-icon="arrow-r" data-iconpos="right">Next</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-role="page" id="slide-controller">
|
<div data-role="page" id="slide-controller">
|
||||||
<div data-role="header">
|
<div data-role="header">
|
||||||
<a href="#" data-rel="back" data-icon="arrow-l">Back</a>
|
<a href="#" data-rel="back" data-icon="arrow-l">Back</a>
|
||||||
<h1>Slide Controller</h1>
|
<h1>Slide Controller</h1>
|
||||||
|
<a href="#" id="controller-refresh" data-role="button" data-icon="refresh">Refresh</a>
|
||||||
</div>
|
</div>
|
||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
|
<div class="ui-grid-c">
|
||||||
|
<div class="ui-block-a"><a href="#" id="controller-blank" data-role="button" data-icon="blank">Blank</a></div>
|
||||||
|
<div class="ui-block-d"><a href="#" id="controller-unblank" data-role="button" data-icon="unblank">Unblank</a></div>
|
||||||
|
<div class="ui-block-c"><a href="#" id="controller-previous" data-role="button" data-icon="arrow-l">Previous</a></div>
|
||||||
|
<div class="ui-block-d"><a href="#" id="controller-next" data-role="button" data-icon="arrow-r" data-iconpos="right">Next</a></div>
|
||||||
|
</div>
|
||||||
<ul data-role="listview" data-inset="true">
|
<ul data-role="listview" data-inset="true">
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div data-role="footer" data-theme="b" class="ui-bar">
|
<div data-role="footer" data-theme="b" class="ui-bar">
|
||||||
<a href="#" id="controller-blank" data-role="button" data-icon="blank">Blank</a>
|
<a href="#" id="controller-prevsong" data-role="button" data-icon="arrow-l">Previous Song</a>
|
||||||
<a href="#" id="controller-unblank" data-role="button" data-icon="unblank">Unblank</a>
|
<a href="#" class="ui-btn-right" id="controller-nextsong" data-role="button" data-icon="arrow-r" data-iconpos="right">Next Song</a>
|
||||||
<a href="#" id="controller-refresh" data-role="button" data-icon="refresh">Refresh</a>
|
|
||||||
<a href="#" id="controller-previous" data-role="button" data-icon="arrow-l">Previous</a>
|
|
||||||
<a href="#" id="controller-next" data-role="button" data-icon="arrow-r" data-iconpos="right">Next</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-role="page" id="alerts">
|
<div data-role="page" id="alerts">
|
||||||
@ -101,8 +109,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
<div data-role="fieldcontain">
|
<div data-role="fieldcontain">
|
||||||
<label for="search-text">Search:</label>
|
<label for="search-plugin">Search:</label>
|
||||||
<input type="text" name="search-text" id="search-text" value="" />
|
<select name="search-plugin" id="search-plugin" data-native-menu="false"></select>
|
||||||
|
</div>
|
||||||
|
<div data-role="fieldcontain">
|
||||||
|
<label for="search-text">For:</label>
|
||||||
|
<input type="search" name="search-text" id="search-text" value="" />
|
||||||
</div>
|
</div>
|
||||||
<a href="#" id="search-submit" data-role="button">Search</a>
|
<a href="#" id="search-submit" data-role="button">Search</a>
|
||||||
<ul data-role="listview" data-inset="true">
|
<ul data-role="listview" data-inset="true">
|
||||||
|
@ -39,6 +39,19 @@ window.OpenLP = {
|
|||||||
}
|
}
|
||||||
return $(targ);
|
return $(targ);
|
||||||
},
|
},
|
||||||
|
searchPlugins: function (event) {
|
||||||
|
$.getJSON(
|
||||||
|
"/api/plugin/search",
|
||||||
|
function (data, status) {
|
||||||
|
var select = $("#search-plugin");
|
||||||
|
select.html("");
|
||||||
|
$.each(data.results.items, function (idx, value) {
|
||||||
|
select.append("<option value='" + value + "'>" + value + "</option>");
|
||||||
|
});
|
||||||
|
select.selectmenu("refresh");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
loadService: function (event) {
|
loadService: function (event) {
|
||||||
$.getJSON(
|
$.getJSON(
|
||||||
"/api/service/list",
|
"/api/service/list",
|
||||||
@ -193,7 +206,7 @@ window.OpenLP = {
|
|||||||
search: function (event) {
|
search: function (event) {
|
||||||
var text = JSON.stringify({"request": {"text": $("#search-text").val()}});
|
var text = JSON.stringify({"request": {"text": $("#search-text").val()}});
|
||||||
$.getJSON(
|
$.getJSON(
|
||||||
"/api/Songs/search",
|
"/api/" + $("#search-plugin").val() + "/search",
|
||||||
{"data": text},
|
{"data": text},
|
||||||
function (data, status) {
|
function (data, status) {
|
||||||
var ul = $("#search > div[data-role=content] > ul[data-role=listview]");
|
var ul = $("#search > div[data-role=content] > ul[data-role=listview]");
|
||||||
@ -220,9 +233,9 @@ window.OpenLP = {
|
|||||||
var id = slide.attr("value");
|
var id = slide.attr("value");
|
||||||
var text = JSON.stringify({"request": {"id": id}});
|
var text = JSON.stringify({"request": {"id": id}});
|
||||||
$.getJSON(
|
$.getJSON(
|
||||||
"/api/Songs/live",
|
"/api/" + $("#search-plugin").val() + "/live",
|
||||||
{"data": text})
|
{"data": text})
|
||||||
window.location.replace('/#slide-controller');
|
$.mobile.changePage("slide-controller");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +247,8 @@ $("#service-next").live("click", OpenLP.nextItem);
|
|||||||
$("#service-previous").live("click", OpenLP.previousItem);
|
$("#service-previous").live("click", OpenLP.previousItem);
|
||||||
$("#service-blank").live("click", OpenLP.blankDisplay);
|
$("#service-blank").live("click", OpenLP.blankDisplay);
|
||||||
$("#service-unblank").live("click", OpenLP.unblankDisplay);
|
$("#service-unblank").live("click", OpenLP.unblankDisplay);
|
||||||
|
$("#service-nextslide").live("click", OpenLP.nextSlide);
|
||||||
|
$("#service-previousslide").live("click", OpenLP.previousSlide);
|
||||||
// Slide Controller
|
// Slide Controller
|
||||||
$("#slide-controller").live("pagebeforeshow", OpenLP.loadController);
|
$("#slide-controller").live("pagebeforeshow", OpenLP.loadController);
|
||||||
$("#controller-refresh").live("click", OpenLP.loadController);
|
$("#controller-refresh").live("click", OpenLP.loadController);
|
||||||
@ -241,11 +256,14 @@ $("#controller-next").live("click", OpenLP.nextSlide);
|
|||||||
$("#controller-previous").live("click", OpenLP.previousSlide);
|
$("#controller-previous").live("click", OpenLP.previousSlide);
|
||||||
$("#controller-blank").live("click", OpenLP.blankDisplay);
|
$("#controller-blank").live("click", OpenLP.blankDisplay);
|
||||||
$("#controller-unblank").live("click", OpenLP.unblankDisplay);
|
$("#controller-unblank").live("click", OpenLP.unblankDisplay);
|
||||||
|
$("#controller-nextsong").live("click", OpenLP.nextItem);
|
||||||
|
$("#controller-previoussong").live("click", OpenLP.previousItem);
|
||||||
// Alerts
|
// Alerts
|
||||||
$("#alert-submit").live("click", OpenLP.showAlert);
|
$("#alert-submit").live("click", OpenLP.showAlert);
|
||||||
// Search
|
// Search
|
||||||
$("#search-submit").live("click", OpenLP.search);
|
$("#search-submit").live("click", OpenLP.search);
|
||||||
// Poll the server twice a second to get any updates.
|
// Poll the server twice a second to get any updates.
|
||||||
|
OpenLP.searchPlugins();
|
||||||
$.ajaxSetup({ cache: false });
|
$.ajaxSetup({ cache: false });
|
||||||
setInterval("OpenLP.pollServer();", 500);
|
setInterval("OpenLP.pollServer();", 500);
|
||||||
OpenLP.pollServer();
|
OpenLP.pollServer();
|
||||||
|
@ -458,7 +458,7 @@ class HttpConnection(object):
|
|||||||
for plugin in self.parent.parent.pluginManager.plugins:
|
for plugin in self.parent.parent.pluginManager.plugins:
|
||||||
media_item = plugin.mediaItem
|
media_item = plugin.mediaItem
|
||||||
if media_item and media_item.hasSearch():
|
if media_item and media_item.hasSearch():
|
||||||
searches.append(plugin.Name)
|
searches.append(plugin.name)
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
json.dumps({u'results': {u'items': searches}}),
|
json.dumps({u'results': {u'items': searches}}),
|
||||||
{u'Content-Type': u'application/json'})
|
{u'Content-Type': u'application/json'})
|
||||||
|
Loading…
Reference in New Issue
Block a user