import Application from require "lapis" import APIKeys, Tasks from require "models" import autoload, locate, registry from require "locator" import settings from autoload "utility" class Simplex extends Application @before_filter => settings.load! registry.before_filter(@) @include locate "users" @include locate "api" [index: "/"]: => -- NOTE TEMPORARY if @user @keys = APIKeys\select "WHERE user_id = ? ORDER BY id ASC", @user.id @tasks = Tasks\select "WHERE user_id = ? ORDER BY id ASC", @user.id unless @keys and #@keys > 0 @keys = {APIKeys\create(@user)} return render: "index.logged_in" else return redirect_to: @url_for "user_login", nil, redirect: @url_for "index" [new_api_key: "/new-api-key"]: => if @user if api_key = APIKeys\create(@user) return json: { success: true, :api_key } [console: "/console"]: => if @user and @user.admin console = require "lapis.console" return console.make(env: "all")(@)