forked from openlp/openlp
More remotes removal and custom pages
This commit is contained in:
parent
dc95d77511
commit
eaa7904f58
|
@ -19,12 +19,16 @@
|
|||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
import os
|
||||
import json
|
||||
import re
|
||||
import urllib
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.lib import PluginStatus
|
||||
from urllib.parse import urlparse
|
||||
from webob import Response
|
||||
|
||||
from openlp.core.common import Registry, AppLocation
|
||||
from openlp.core.lib import PluginStatus, image_to_byte
|
||||
|
||||
|
||||
def search(request, plugin_name, log):
|
||||
|
@ -104,14 +108,6 @@ def display_thumbnails(request, controller_name, log, dimensions, file_name, sli
|
|||
:param slide: the individual image name
|
||||
:return:
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import urllib
|
||||
from urllib.parse import urlparse
|
||||
from webob import Response
|
||||
from openlp.core.common import Registry, AppLocation
|
||||
from openlp.core.lib import image_to_byte
|
||||
|
||||
log.debug('serve thumbnail {cname}/thumbnails{dim}/{fname}/{slide}'.format(cname=controller_name,
|
||||
dim=dimensions,
|
||||
fname=file_name,
|
||||
|
|
|
@ -52,7 +52,7 @@ class HttpWorker(QtCore.QObject):
|
|||
"""
|
||||
Run the thread.
|
||||
"""
|
||||
serve(application, host='0.0.0.0', port=4318)
|
||||
serve(application, host='0.0.0.0', port=4316)
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
|
|
@ -79,8 +79,7 @@ class ApiTab(SettingsTab):
|
|||
self.http_setting_layout.setObjectName('http_setting_layout')
|
||||
self.port_label = QtWidgets.QLabel(self.http_settings_group_box)
|
||||
self.port_label.setObjectName('port_label')
|
||||
self.port_spin_box = QtWidgets.QSpinBox(self.http_settings_group_box)
|
||||
self.port_spin_box.setMaximum(32767)
|
||||
self.port_spin_box = QtWidgets.QLabel(self.http_settings_group_box)
|
||||
self.port_spin_box.setObjectName('port_spin_box')
|
||||
self.http_setting_layout.addRow(self.port_label, self.port_spin_box)
|
||||
self.remote_url_label = QtWidgets.QLabel(self.http_settings_group_box)
|
||||
|
@ -154,7 +153,6 @@ class ApiTab(SettingsTab):
|
|||
self.twelve_hour_check_box.stateChanged.connect(self.on_twelve_hour_check_box_changed)
|
||||
self.thumbnails_check_box.stateChanged.connect(self.on_thumbnails_check_box_changed)
|
||||
self.address_edit.textChanged.connect(self.set_urls)
|
||||
self.port_spin_box.valueChanged.connect(self.set_urls)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.tab_title_visible = translate('RemotePlugin.RemoteTab', 'Remote Interface')
|
||||
|
@ -187,14 +185,15 @@ class ApiTab(SettingsTab):
|
|||
Update the display based on the data input on the screen
|
||||
"""
|
||||
ip_address = self.get_ip_address(self.address_edit.text())
|
||||
http_url = 'http://{url}:{text}/'.format(url=ip_address, text=self.port_spin_box.value())
|
||||
http_url = 'http://{url}:{text}/'.format(url=ip_address, text=self.port_spin_box.text())
|
||||
self.remote_url.setText('<a href="{url}">{url}</a>'.format(url=http_url))
|
||||
http_url_temp = http_url + 'stage'
|
||||
self.stage_url.setText('<a href="{url}">{url}</a>'.format(url=http_url_temp))
|
||||
http_url_temp = http_url + 'main'
|
||||
self.live_url.setText('<a href="{url}">{url}</a>'.format(url=http_url_temp))
|
||||
|
||||
def get_ip_address(self, ip_address):
|
||||
@staticmethod
|
||||
def get_ip_address(ip_address):
|
||||
"""
|
||||
returns the IP address in dependency of the passed address
|
||||
ip_address == 0.0.0.0: return the IP address of the first valid interface
|
||||
|
@ -218,7 +217,7 @@ class ApiTab(SettingsTab):
|
|||
"""
|
||||
Load the configuration and update the server configuration if necessary
|
||||
"""
|
||||
self.port_spin_box.setValue(Settings().value(self.settings_section + '/port'))
|
||||
self.port_spin_box.setText(str(Settings().value(self.settings_section + '/port')))
|
||||
self.address_edit.setText(Settings().value(self.settings_section + '/ip address'))
|
||||
self.twelve_hour = Settings().value(self.settings_section + '/twelve hour')
|
||||
self.twelve_hour_check_box.setChecked(self.twelve_hour)
|
||||
|
@ -233,10 +232,8 @@ class ApiTab(SettingsTab):
|
|||
"""
|
||||
Save the configuration and update the server configuration if necessary
|
||||
"""
|
||||
if Settings().value(self.settings_section + '/ip address') != self.address_edit.text() or \
|
||||
Settings().value(self.settings_section + '/port') != self.port_spin_box.value():
|
||||
if Settings().value(self.settings_section + '/ip address') != self.address_edit.text():
|
||||
self.settings_form.register_post_process('remotes_config_updated')
|
||||
Settings().setValue(self.settings_section + '/port', self.port_spin_box.value())
|
||||
Settings().setValue(self.settings_section + '/ip address', self.address_edit.text())
|
||||
Settings().setValue(self.settings_section + '/twelve hour', self.twelve_hour)
|
||||
Settings().setValue(self.settings_section + '/thumbnails', self.thumbnails)
|
||||
|
|
|
@ -134,6 +134,16 @@ class Settings(QtCore.QSettings):
|
|||
'advanced/single click service preview': False,
|
||||
'advanced/x11 bypass wm': X11_BYPASS_DEFAULT,
|
||||
'advanced/search as type': True,
|
||||
|
||||
'remotes/twelve hour': True,
|
||||
'remotes/port': 4316,
|
||||
'remotes/websocket port': 4317,
|
||||
'remotes/user id': 'openlp',
|
||||
'remotes/password': 'password',
|
||||
'remotes/authentication enabled': False,
|
||||
'remotes/ip address': '0.0.0.0',
|
||||
'remotes/thumbnails': True,
|
||||
|
||||
'crashreport/last directory': '',
|
||||
'formattingTags/html_tags': '',
|
||||
'core/audio repeat list': False,
|
||||
|
|
|
@ -557,7 +557,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||
self.tools_first_time_wizard.triggered.connect(self.on_first_time_wizard_clicked)
|
||||
self.update_theme_images.triggered.connect(self.on_update_theme_images)
|
||||
self.formatting_tag_item.triggered.connect(self.on_formatting_tag_item_clicked)
|
||||
self.settings_configure_item.triggered.connect(self.on_settings_configure_iem_clicked)
|
||||
self.settings_configure_item.triggered.connect(self.on_settings_configure_item_clicked)
|
||||
self.settings_shortcuts_item.triggered.connect(self.on_settings_shortcuts_item_clicked)
|
||||
self.settings_import_item.triggered.connect(self.on_settings_import_item_clicked)
|
||||
self.settings_export_item.triggered.connect(self.on_settings_export_item_clicked)
|
||||
|
@ -822,7 +822,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||
"""
|
||||
self.formatting_tag_form.exec()
|
||||
|
||||
def on_settings_configure_iem_clicked(self):
|
||||
def on_settings_configure_item_clicked(self):
|
||||
"""
|
||||
Show the Settings dialog
|
||||
"""
|
||||
|
|
|
@ -19,71 +19,3 @@
|
|||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`remotes` plugin allows OpenLP to be controlled from another machine
|
||||
over a network connection.
|
||||
|
||||
Routes:
|
||||
|
||||
``/``
|
||||
Go to the web interface.
|
||||
|
||||
``/files/{filename}``
|
||||
Serve a static file.
|
||||
|
||||
``/api/poll``
|
||||
Poll to see if there are any changes. Returns a JSON-encoded dict of
|
||||
any changes that occurred::
|
||||
|
||||
{"results": {"type": "controller"}}
|
||||
|
||||
Or, if there were no results, False::
|
||||
|
||||
{"results": False}
|
||||
|
||||
``/api/controller/{live|preview}/{action}``
|
||||
Perform ``{action}`` on the live or preview controller. Valid actions
|
||||
are:
|
||||
|
||||
``next``
|
||||
Load the next slide.
|
||||
|
||||
``previous``
|
||||
Load the previous slide.
|
||||
|
||||
``jump``
|
||||
Jump to a specific slide. Requires an id return in a JSON-encoded
|
||||
dict like so::
|
||||
|
||||
{"request": {"id": 1}}
|
||||
|
||||
``first``
|
||||
Load the first slide.
|
||||
|
||||
``last``
|
||||
Load the last slide.
|
||||
|
||||
``text``
|
||||
Request the text of the current slide.
|
||||
|
||||
``/api/service/{action}``
|
||||
Perform ``{action}`` on the service manager (e.g. go live). Data is
|
||||
passed as a json-encoded ``data`` parameter. Valid actions are:
|
||||
|
||||
``next``
|
||||
Load the next item in the service.
|
||||
|
||||
``previous``
|
||||
Load the previews item in the service.
|
||||
|
||||
``jump``
|
||||
Jump to a specific item in the service. Requires an id returned in
|
||||
a JSON-encoded dict like so::
|
||||
|
||||
{"request": {"id": 1}}
|
||||
|
||||
``list``
|
||||
Request a list of items in the service.
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
@ -20,8 +20,5 @@
|
|||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from .httprouter import HttpRouter
|
||||
from .httpserver import OpenLPServer
|
||||
from .remotetab import RemoteTab
|
||||
from .endpoint import remote_endpoint
|
||||
|
||||
__all__ = ['RemoteTab', 'OpenLPServer', 'HttpRouter']
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2016 OpenLP Developers #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
import logging
|
||||
|
||||
import os
|
||||
|
||||
from openlp.core.api.http.endpoint import Endpoint
|
||||
from openlp.core.api.http.endpoint.core import TRANSLATED_STRINGS
|
||||
from openlp.core.api.http import register_endpoint
|
||||
from openlp.core.common import AppLocation
|
||||
|
||||
|
||||
static_dir = os.path.join(AppLocation.get_section_data_path('remotes'))
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
remote_endpoint = Endpoint('remote', template_dir=static_dir, static_dir=static_dir)
|
||||
|
||||
|
||||
@remote_endpoint.route('{view}')
|
||||
def index(request, view):
|
||||
"""
|
||||
Handles requests for /remotes url
|
||||
|
||||
:param request: The http request object.
|
||||
:param view: The view name to be servered.
|
||||
"""
|
||||
return remote_endpoint.render_template('{view}.mako'.format(view=view), **TRANSLATED_STRINGS)
|
||||
|
||||
register_endpoint(remote_endpoint)
|
|
@ -22,11 +22,10 @@
|
|||
|
||||
import logging
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
from openlp.core.common import OpenLPMixin
|
||||
from openlp.core.lib import Plugin, StringContent, translate, build_icon
|
||||
from openlp.plugins.remotes.lib import RemoteTab, OpenLPServer
|
||||
from openlp.plugins.remotes.lib.endpoint import remote_endpoint
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -49,42 +48,11 @@ class RemotesPlugin(Plugin, OpenLPMixin):
|
|||
"""
|
||||
remotes constructor
|
||||
"""
|
||||
super(RemotesPlugin, self).__init__('remotes', __default_settings__, settings_tab_class=RemoteTab)
|
||||
super(RemotesPlugin, self).__init__('remotes', __default_settings__)
|
||||
self.icon_path = ':/plugins/plugin_remote.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
self.weight = -1
|
||||
self.server = None
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Initialise the remotes plugin, and start the http server
|
||||
"""
|
||||
super(RemotesPlugin, self).initialise()
|
||||
self.server = OpenLPServer()
|
||||
# if not hasattr(self, 'remote_server_icon'):
|
||||
# self.remote_server_icon = QtWidgets.QLabel(self.main_window.status_bar)
|
||||
# size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
|
||||
# size_policy.setHorizontalStretch(0)
|
||||
# size_policy.setVerticalStretch(0)
|
||||
# size_policy.setHeightForWidth(self.remote_server_icon.sizePolicy().hasHeightForWidth())
|
||||
# self.remote_server_icon.setSizePolicy(size_policy)
|
||||
# self.remote_server_icon.setFrameShadow(QtWidgets.QFrame.Plain)
|
||||
# self.remote_server_icon.setLineWidth(1)
|
||||
# self.remote_server_icon.setScaledContents(True)
|
||||
# self.remote_server_icon.setFixedSize(20, 20)
|
||||
# self.remote_server_icon.setObjectName('remote_server_icon')
|
||||
# self.main_window.status_bar.insertPermanentWidget(2, self.remote_server_icon)
|
||||
# self.settings_tab.remote_server_icon = self.remote_server_icon
|
||||
# self.settings_tab.generate_icon()
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
Tidy up and close down the http server
|
||||
"""
|
||||
super(RemotesPlugin, self).finalise()
|
||||
if self.server:
|
||||
self.server.stop_server()
|
||||
self.server = None
|
||||
|
||||
@staticmethod
|
||||
def about():
|
||||
|
@ -92,9 +60,8 @@ class RemotesPlugin(Plugin, OpenLPMixin):
|
|||
Information about this plugin
|
||||
"""
|
||||
about_text = translate('RemotePlugin', '<strong>Remote Plugin</strong>'
|
||||
'<br />The remote plugin provides the ability to send messages to '
|
||||
'a running version of OpenLP on a different computer via a web '
|
||||
'browser or through the remote API.')
|
||||
'<br />The remote plugin provides the ability develop web based '
|
||||
'interfaces using openlp web services')
|
||||
return about_text
|
||||
|
||||
def set_plugin_text_strings(self):
|
||||
|
@ -111,14 +78,3 @@ class RemotesPlugin(Plugin, OpenLPMixin):
|
|||
'title': translate('RemotePlugin', 'Remote', 'container title')
|
||||
}
|
||||
|
||||
def config_update(self):
|
||||
"""
|
||||
Called when Config is changed to requests a restart with the server on new address or port
|
||||
"""
|
||||
log.debug('remote config changed')
|
||||
QtWidgets.QMessageBox.information(self.main_window,
|
||||
translate('RemotePlugin', 'Server Config Change'),
|
||||
translate('RemotePlugin',
|
||||
'Server configuration changes will require a restart '
|
||||
'to take effect.'),
|
||||
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
|
||||
|
|
Loading…
Reference in New Issue