diff --git a/mopidy_iris/__init__.py b/mopidy_iris/__init__.py index 872d51ac..9ce44b2d 100755 --- a/mopidy_iris/__init__.py +++ b/mopidy_iris/__init__.py @@ -48,6 +48,7 @@ class Extension( ext.Extension ): def factory(config, core): path = os.path.join( os.path.dirname(__file__), 'static') + frontend = IrisFrontend(config, core) return [ (r"/images/(.*)", tornado.web.StaticFileHandler, { @@ -55,12 +56,12 @@ def factory(config, core): }), (r'/http/([^/]*)', HttpHandler, { 'core': core, - 'frontend': IrisFrontend, + 'frontend': frontend, 'config': config }), (r'/ws/?', WebsocketHandler, { 'core': core, - 'frontend': IrisFrontend + 'frontend': frontend }), (r'/(.*)', tornado.web.StaticFileHandler, { "path": path, diff --git a/mopidy_iris/frontend.py b/mopidy_iris/frontend.py index b80aa9e3..99c35dd8 100755 --- a/mopidy_iris/frontend.py +++ b/mopidy_iris/frontend.py @@ -9,9 +9,35 @@ from mopidy.core import CoreListener from pkg_resources import parse_version from spotipy import Spotify from websocket import WebsocketHandler +from http import HttpHandler # import logger logger = logging.getLogger(__name__) + +def make_iris_factory(apps, statics): + def mopidy_app_factory(config, core): + + path = os.path.join( os.path.dirname(__file__), 'static') + frontend = IrisFrontend(config, core) + + return [ + (r"/images/(.*)", tornado.web.StaticFileHandler, { + "path": config['local-images']['image_dir'] + }), + (r'/http/([^/]*)', HttpHandler, { + 'core': core, + 'frontend': frontend, + 'config': config + }), + (r'/ws/?', WebsocketHandler, { + 'core': core, + 'frontend': frontend + }), + (r'/(.*)', tornado.web.StaticFileHandler, { + "path": path, + "default_filename": "index.html" + }), + ] ### # Spotmop supporting frontend @@ -21,7 +47,6 @@ logger = logging.getLogger(__name__) class IrisFrontend(pykka.ThreadingActor, CoreListener): def __init__(self, config, core): - global spotmop super(IrisFrontend, self).__init__() self.config = config self.core = core @@ -121,7 +146,7 @@ class IrisFrontend(pykka.ThreadingActor, CoreListener): self.core.tracklist.add( uris = uris ) except: - pusher.broadcast('error', {'source': 'load_more_tracks', 'message': 'Failed to fetch Spotify recommendations'}) + WebsocketHandler.broadcast('error', {'source': 'load_more_tracks', 'message': 'Failed to fetch Spotify recommendations'}) logger.error('IrisFrontend: Failed to fetch Spotify recommendations') diff --git a/src/js/views/Settings.js b/src/js/views/Settings.js index da45c81d..290b0875 100755 --- a/src/js/views/Settings.js +++ b/src/js/views/Settings.js @@ -26,7 +26,6 @@ class Settings extends React.Component{ mopidy_host: this.props.mopidy.host, mopidy_port: this.props.mopidy.port, pusher_username: this.props.pusher.username, - pusher_port: this.props.pusher.port, spotify_country: this.props.spotify.country, spotify_locale: this.props.spotify.locale }; @@ -147,6 +146,16 @@ class Settings extends React.Component{ { this.renderConnectionStatus('mopidy') } +
+
Username
+
+ this.setState({ pusher_username: e.target.value }) } + onBlur={ e => this.props.pusherActions.setUsername(this.state.pusher_username) } + value={ this.state.pusher_username } /> +
+
Host
@@ -173,36 +182,6 @@ class Settings extends React.Component{
-

Pusher

-
-
-
Status
-
- { this.renderConnectionStatus('pusher') } -
-
-
-
Username
-
- this.setState({ pusher_username: e.target.value }) } - onBlur={ e => this.props.pusherActions.setUsername(this.state.pusher_username) } - value={ this.state.pusher_username } /> -
-
-
-
Port
-
- this.setState({ pusher_port: e.target.value })} - onBlur={ e => this.props.pusherActions.setPort(this.state.pusher_port) } - value={ this.state.pusher_port } /> -
-
-
-

Spotify

Status