# Path: wwwhisper_auth/assets.py
# class Asset:
#     """Stores a static file to be returned by requests."""
# 
#     def __init__(self, prefix, *args):
#         assert prefix is not None
#         self.body = file(os.path.join(prefix, *args)).read()
# 
# class HtmlFileView(StaticFileView):
# 
#     def do_get(self, body):
#         return http.HttpResponseOKHtml(body)
# 
# class JsFileView(StaticFileView):
# 
#     def do_get(self, body):
#         return http.HttpResponseOKJs(body)


from django.conf import settings
from django.conf.urls import include, url
from django.conf import settings
from wwwhisper_auth.assets import Asset, HtmlFileView, JsFileView
import logging
# wwwhisper - web access control.
# Copyright (C) 2012-2018 Jan Wrobel <jan@mixedbit.org>



logger = logging.getLogger(__name__)

def _add_suffix(suffix):
    return r'^%s%s' % (settings.WWWHISPER_PATH_PREFIX, suffix)

def _url(path, *args):
    return url(_add_suffix(path), *args)

urlpatterns = [
    _url(r'auth/api/', include('wwwhisper_auth.urls')),
    _url(r'admin/api/', include('wwwhisper_admin.urls'))
]

if settings.WWWHISPER_STATIC is not None:
    logger.debug('wwwhisper configured to serve static files.')
    admin = Asset(settings.WWWHISPER_STATIC, 'admin', 'index.html')

# Path: wwwhisper_auth/assets.py
# class Asset:
#     """Stores a static file to be returned by requests."""
# 
#     def __init__(self, prefix, *args):
#         assert prefix is not None
#         self.body = file(os.path.join(prefix, *args)).read()
# 
# class HtmlFileView(StaticFileView):
# 
#     def do_get(self, body):
#         return http.HttpResponseOKHtml(body)
# 
# class JsFileView(StaticFileView):
# 
#     def do_get(self, body):
#         return http.HttpResponseOKJs(body)


# Path: wwwhisper_service/urls.py
from django.conf import settings
from django.conf.urls import include, url
from django.conf import settings
from wwwhisper_auth.assets import Asset, HtmlFileView, JsFileView
import logging

# wwwhisper - web access control.
# Copyright (C) 2012-2018 Jan Wrobel <jan@mixedbit.org>



logger = logging.getLogger(__name__)

def _add_suffix(suffix):
    return r'^%s%s' % (settings.WWWHISPER_PATH_PREFIX, suffix)

def _url(path, *args):
    return url(_add_suffix(path), *args)

urlpatterns = [
    _url(r'auth/api/', include('wwwhisper_auth.urls')),
    _url(r'admin/api/', include('wwwhisper_admin.urls'))
]

if settings.WWWHISPER_STATIC is not None:
    logger.debug('wwwhisper configured to serve static files.')
    admin = Asset(settings.WWWHISPER_STATIC, 'admin', 'index.html')

    overlay = Asset(settings.WWWHISPER_STATIC, 'auth', 'overlay.html')