# Configurable variables
# ADMIN_USER
# ADMIN_LOOKUP
# ADMIN_ROLE
# ADMIN_KWARGS

variables:
  LOGIN_URL:
    default: /login/
  LOGOUT_URL:
    default: /logout/

import:
  apps/controlpanel/ui:
    path: $GRAMEXAPPS/ui/gramex.yaml
    YAMLURL: $YAMLURL/ui/

url:
  apps/controlpanel/home-$*:
    pattern: /$YAMLURL/
    handler: FileHandler
    kwargs:
      path: $YAMLPATH/index.html
      template: true
      variables: $ADMIN_LOOKUP
      admin_kwargs: $ADMIN_KWARGS
      auth: &ALLOW_ONLY_ADMINS
        login_url: $LOGIN_URL
        condition:
          function: controlpanel.is_admin
          kwargs:
            admin_user: $ADMIN_USER
            admin_role: $ADMIN_ROLE

  apps/controlpanel/default-$*:
    pattern: /$YAMLURL/(.*)
    handler: FileHandler
    kwargs:
      path: $YAMLPATH
      headers:
          Cache-Control: max-age=60
          'node_modules/**':
            Cache-Control: public, max-age=315360000
          'bower_components/**':
            Cache-Control: public, max-age=315360000

  apps/controlpanel/query-$*:
    pattern: /$YAMLURL/users/
    handler: FormHandler
    kwargs: $ADMIN_LOOKUP

  apps/controlpanel/pop-user-$*:
    pattern: /$YAMLURL/pop_user   # Map this URL
    handler: FunctionHandler      # to the logout handler
    kwargs:
      function: controlpanel.pop_user

  apps/controlpanel/webshell-$*:
    pattern: /$YAMLURL/webshell
    handler: WebSocketHandler
    kwargs:
      on_message:
        function: controlpanel.evaluate(handler, message)
      auth:
        <<: *ALLOW_ONLY_ADMINS

email:
    gramex-guide-gmail:
      type: gmail                     # Type of email used is GMail
      email: gramex.guide@gmail.com   # Generic email ID used to test e-mails
      password: tlpmupxnhucitpte      # App-specific password created for Gramex guide
