/
__init__.py
36 lines (26 loc) · 1.06 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from __future__ import unicode_literals
import os
from mopidy import config, ext
__version__ = '0.7.0'
class Extension(ext.Extension):
dist_name = 'Mopidy-Mobile'
ext_name = 'mobile'
version = __version__
def get_config_schema(self):
schema = super(Extension, self).get_config_schema()
schema['title'] = config.String()
schema['ws_url'] = config.String(optional=True)
return schema
def get_default_config(self):
return config.read(os.path.join(os.path.dirname(__file__), 'ext.conf'))
def setup(self, registry):
registry.add('http:app', {'name': 'mobile', 'factory': self.factory})
def factory(self, config, core):
from tornado.web import RedirectHandler
from .web import IndexHandler, StaticHandler
path = os.path.join(os.path.dirname(__file__), 'www')
return [
(r'/', RedirectHandler, {'url': 'index.html'}),
(r'/(index.html)', IndexHandler, {'config': config, 'path': path}),
(r'/(.*)', StaticHandler, {'path': path})
]