# Path: ddserver/interface/user.py
# @property
# @require(session = 'ddserver.interface.session:SessionManager')
# def authorized(self, session):
#   if session.username:
#     return self[session.username]
# 
# Path: ddserver/utils/deps.py
# def require(**requirements):
#   ''' Decorator to inject requirements into a function.
# 
#       The decorated function is called with a named argument for each
#       specified requirement containing the exported instances.
#   '''
# 
#   exports = {name : Export.load(requirement)
#              for name, requirement
#              in requirements.iteritems()}
# 
#   def wrapper(func):
#     def wrapped(*args, **kwargs):
#       # Update the keyword arguments with the required instances
#       kwargs.update({name : export.instance
#                      for name, export
#                      in exports.iteritems()
#                      if name not in kwargs})
# 
#       return func(*args,
#                   **kwargs)
# 
#     wrapped.__name__ = func.__name__
# 
#     return wrapped
#   return wrapper
# 
# def extend(self, extend):
#   ''' Extends this export.
# 
#       The instance created by the wrapped factory is extended by passing the
#       created instance to the given extend function after creation.
# 
#       The extend function must accept the instance as its only argument. If
#       the function returns a value which is not None, the instance is replaced
#       with the returned value.
#   '''
# 
#   assert self.__instance is None
# 
#   self.__extends.append(extend)


import os
import bottle
from ddserver.web import route
from ddserver.interface.user import authorized
from ddserver.utils.deps import require, extend
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

ddserver is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with ddserver. If not, see <http://www.gnu.org/licenses/>.
'''








@extend('ddserver.config:ConfigDeclaration')
def config_wsgi(config_decl):
  with config_decl.declare('wsgi') as s:
    s('static_files',
      conv = str,
      default = '/usr/share/ddserver/static')



@route('/static/<path:path>', method = 'GET')

# Path: ddserver/interface/user.py
# @property
# @require(session = 'ddserver.interface.session:SessionManager')
# def authorized(self, session):
#   if session.username:
#     return self[session.username]
# 
# Path: ddserver/utils/deps.py
# def require(**requirements):
#   ''' Decorator to inject requirements into a function.
# 
#       The decorated function is called with a named argument for each
#       specified requirement containing the exported instances.
#   '''
# 
#   exports = {name : Export.load(requirement)
#              for name, requirement
#              in requirements.iteritems()}
# 
#   def wrapper(func):
#     def wrapped(*args, **kwargs):
#       # Update the keyword arguments with the required instances
#       kwargs.update({name : export.instance
#                      for name, export
#                      in exports.iteritems()
#                      if name not in kwargs})
# 
#       return func(*args,
#                   **kwargs)
# 
#     wrapped.__name__ = func.__name__
# 
#     return wrapped
#   return wrapper
# 
# def extend(self, extend):
#   ''' Extends this export.
# 
#       The instance created by the wrapped factory is extended by passing the
#       created instance to the given extend function after creation.
# 
#       The extend function must accept the instance as its only argument. If
#       the function returns a value which is not None, the instance is replaced
#       with the returned value.
#   '''
# 
#   assert self.__instance is None
# 
#   self.__extends.append(extend)


# Path: ddserver/interface/pages/index.py
import os
import bottle
from ddserver.web import route
from ddserver.interface.user import authorized
from ddserver.utils.deps import require, extend

it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

ddserver is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with ddserver. If not, see <http://www.gnu.org/licenses/>.
'''








@extend('ddserver.config:ConfigDeclaration')
def config_wsgi(config_decl):
  with config_decl.declare('wsgi') as s:
    s('static_files',
      conv = str,
      default = '/usr/share/ddserver/static')



@route('/static/<path:path>', method = 'GET')

@require(config = 'ddserver.config:Config')