STATIC_PATH = set_local_or_prod('OPENSHIFT_REPO_DIR', 'wsgi/static', 'wsgi/static')
CONTENT_PATH = set_local_or_prod('OPENSHIFT_DATA_DIR', '.', './data')

# This must be added in order to do correct path lookups for the views
if VIEWS_PATH not in TEMPLATE_PATH:
    TEMPLATE_PATH.append(VIEWS_PATH)

app = Bottle()

import os
from localconfig import LocalConfig as Configuration
from db import PostsDatabase, TokensDatabase, ResourcesDatabase

import dropbox_utils

app.conf = Configuration(os.path.join(CONTENT_PATH, 'config.ini'))
app.posts = PostsDatabase(os.path.join(CONTENT_PATH, 'posts.json'))
app.tokens = TokensDatabase(os.path.join(CONTENT_PATH, 'tokens.json'))
app.post_resources = ResourcesDatabase(os.path.join(CONTENT_PATH, 'resources.json'))


@app.route('/static/<path:path>')
def serve_static(path):
    return static_file(path, STATIC_PATH)


@app.route('/bumper')
def bumper():
    return template('bumper.tpl')