# Path: modules/bottle_gettext.py
# class GettextPlugin(object):
#     def __init__(self, domain, localedir, allowed_languages, keyword='lang'):
#     def get_language(self):
#     def apply(self, callback, route):
#         def wrapper(*args, **kwargs):
# 
# Path: api/app.py
# class OsmoseAPIBottle(bottle.Bottle):
#     def default_error_handler(self, res):


import bottle
import os.path
import functools
import os
import modules.osmose_bottle
from modules import utils
from modules import bottle_gettext
from web_api import app as web_app
from control import app as control_app
from api import app as api_app

app.install(bottle_gettext.Plugin('osmose-frontend', os.path.join("web", "po", "mo"), utils.allowed_languages))

for l in utils.allowed_languages:
  app.mount('/' + l, web_app.app)

@app.route('/')
@app.route('/map')
@app.route('/map/')
def index(lang):
    # Route to force a redirect, for missing langue in URL
    pass

app.mount('/control/', control_app.app)

web_app.app.mount('api/0.2/', api_app.app_0_2)
app.mount('/api/0.3/', api_app.app_0_3)

@bottle.route('/images/markers/<filename:path>.png')
def marker(filename):
    if os.path.isfile('web_api/static' + bottle.request.path):
        return bottle.static_file(bottle.request.path, root='web_api/static')
    else:
        return bottle.static_file('/images/markers/marker-b-0.png', root='web_api/static')

@bottle.route('/<filename:path>', name='static')
def static(filename):
    if os.path.isfile('web_api/public' + bottle.request.path):
        return bottle.static_file(filename, root='web_api/public')
    else:

# Path: modules/bottle_gettext.py
# class GettextPlugin(object):
#     def __init__(self, domain, localedir, allowed_languages, keyword='lang'):
#     def get_language(self):
#     def apply(self, callback, route):
#         def wrapper(*args, **kwargs):
# 
# Path: api/app.py
# class OsmoseAPIBottle(bottle.Bottle):
#     def default_error_handler(self, res):


# Path: osmose.py
import bottle
import os.path
import functools
import os
import modules.osmose_bottle
from modules import utils
from modules import bottle_gettext
from web_api import app as web_app
from control import app as control_app
from api import app as api_app


app.install(bottle_gettext.Plugin('osmose-frontend', os.path.join("web", "po", "mo"), utils.allowed_languages))

for l in utils.allowed_languages:
  app.mount('/' + l, web_app.app)

@app.route('/')
@app.route('/map')
@app.route('/map/')
def index(lang):
    # Route to force a redirect, for missing langue in URL
    pass

app.mount('/control/', control_app.app)

web_app.app.mount('api/0.2/', api_app.app_0_2)
app.mount('/api/0.3/', api_app.app_0_3)

@bottle.route('/images/markers/<filename:path>.png')
def marker(filename):
    if os.path.isfile('web_api/static' + bottle.request.path):
        return bottle.static_file(bottle.request.path, root='web_api/static')
    else:
        return bottle.static_file('/images/markers/marker-b-0.png', root='web_api/static')

@bottle.route('/<filename:path>', name='static')
def static(filename):
    if os.path.isfile('web_api/public' + bottle.request.path):
        return bottle.static_file(filename, root='web_api/public')
    else:

        return bottle.static_file(filename, root='web/public')