71 lines
1.9 KiB
Python
Executable File
71 lines
1.9 KiB
Python
Executable File
from __future__ import unicode_literals
|
|
|
|
import logging, os, json
|
|
import tornado.web
|
|
import tornado.websocket
|
|
from mopidy import config, ext
|
|
from frontend import IrisFrontend
|
|
from http import HttpHandler
|
|
from websocket import WebsocketHandler
|
|
|
|
logger = logging.getLogger(__name__)
|
|
__version__ = '2.12.1'
|
|
|
|
##
|
|
# Core extension class
|
|
#
|
|
# Loads config and gets the party started. Initiates any additional frontends, etc.
|
|
##
|
|
class Extension( ext.Extension ):
|
|
|
|
dist_name = 'Mopidy-Iris'
|
|
ext_name = 'iris'
|
|
version = __version__
|
|
|
|
def get_default_config(self):
|
|
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
|
return config.read(conf_file)
|
|
|
|
def get_config_schema(self):
|
|
schema = config.ConfigSchema(self.ext_name)
|
|
schema['enabled'] = config.Boolean()
|
|
schema['pusherport'] = config.String()
|
|
schema['country'] = config.String()
|
|
schema['locale'] = config.String()
|
|
return schema
|
|
|
|
def setup(self, registry):
|
|
|
|
# Add web extension
|
|
registry.add('http:app', {
|
|
'name': self.ext_name,
|
|
'factory': factory
|
|
})
|
|
|
|
# add our frontend
|
|
registry.add('frontend', IrisFrontend)
|
|
|
|
def 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"
|
|
}),
|
|
]
|