from __future__ import unicode_literals

import logging
import os

from mopidy import config, ext


__version__ = '0.1.0'

# TODO: If you need to log, use loggers named after the current Python module
logger = logging.getLogger(__name__)


class Extension(ext.Extension):

    dist_name = 'Mopidy-KTD'
    ext_name = 'kill_the_dj'
    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 = super(Extension, self).get_config_schema()
        # TODO: Comment in and edit, or remove entirely
        #schema['username'] = config.String()
        #schema['password'] = config.Secret()
        return schema

    def setup(self, registry):
        # You will typically only implement one of the following things
        # in a single extension.

        # TODO: Edit or remove entirely
        from .frontend import FoobarFrontend
        registry.add('frontend', FoobarFrontend)

        # TODO: Edit or remove entirely
        from .backend import FoobarBackend
        registry.add('backend', FoobarBackend)

        # TODO: Edit or remove entirely
        registry.add('http:static', {
            'name': self.ext_name,
            'path': os.path.join(os.path.dirname(__file__), 'static'),
        })

@@ -60,16 +60,36 @@
 ort os%0A%0A
+import tornado.web%0A%0A
 from mop
@@ -112,17 +112,16 @@
 g, ext%0A%0A
-%0A
 __versio
@@ -252,16 +252,361 @@
 me__)%0A%0A%0A
+class MyRequestHandler(tornado.web.RequestHandler):%0A    def initialize(self, core):%0A        self.core = core%0A%0A    def get(self):%0A        self.write(%0A            'Hello, world! This is Mopidy %25s' %25%0A            self.core.get_version().get())%0A%0A%0Adef my_app_factory(config, core):%0A    return %5B%0A        ('/', MyRequestHandler, %7B'core': core%7D)%0A    %5D%0A%0A%0A
 class Ex
@@ -629,17 +629,16 @@
 nsion):%0A
-%0A
     dist
@@ -658,10 +658,16 @@
 dy-K
-TD
+illTheDJ
 '%0A  
@@ -684,19 +684,17 @@
  = '
-kill_the_dj
+KillTheDJ
 '%0A  
@@ -1013,32 +1013,33 @@
 tirely%0A        #
+ 
 schema%5B'username
@@ -1068,16 +1068,17 @@
        #
+ 
 schema%5B'
@@ -1172,554 +1172,107 @@
     
-# You will typically only implement one of the following things%0A        # in a single extension.%0A%0A        # TODO: Edit or remove entirely%0A        from .frontend import FoobarFrontend%0A        registry.add('frontend', FoobarFrontend)%0A%0A        # TODO: Edit or remove entirely%0A        from .backend import FoobarBackend%0A        registry.add('backend', FoobarBackend)%0A%0A        # TODO: Edit or remove entirely%0A        registry.add('http:static', %7B%0A            'name': self.ext_name,%0A            'path': os.path.join(os.path.dirname(__file__), 'static')
+registry.add('http:app', %7B%0A            'name': self.ext_name,%0A            'factory': my_app_factory
 ,%0A  
@@ -1279,9 +1279,8 @@
       %7D)
-%0A

http://localhost:6680/KillTheDJ/ return a web page (no 404)