# Path: app.py
# def inject_static():
#     def static(filename, **kwargs):
# def install_security_headers(resp):
# 
# Path: libforget/auth.py
# def get_viewer_session():
#     from model import Session
#     sid = request.cookies.get('forget_sid', None)
#     if sid:
#         return Session.query.get(sid)
# 
# def set_session_cookie(session, response, secure=True):
#     response.set_cookie(
#         'forget_sid', session.id,
#         max_age=60*60*48,
#         httponly=True,
#         secure=secure)


from app import app, db, sentry
from flask import g, render_template, make_response, redirect, request
from libforget.auth import get_viewer_session, set_session_cookie
import version
import libforget.version
    g.viewer = get_viewer_session()
    if g.viewer and sentry:
        sentry.user_context({
                'id': g.viewer.account.id,
                'username': g.viewer.account.screen_name,
                'service': g.viewer.account.service
            })


@app.context_processor
def inject_version():
    v = version.get_versions()
    return dict(
            version=v['version'],
            repo_url=libforget.version.url_for_version(v),
        )


@app.context_processor
def inject_sentry():
    if sentry:
        return dict(sentry=True)
    return dict()


@app.after_request
def touch_viewer(resp):
    if 'viewer' in g and g.viewer:
        set_session_cookie(g.viewer, resp, app.config.get('HTTPS'))
        g.viewer.touch()

# Path: app.py
# def inject_static():
#     def static(filename, **kwargs):
# def install_security_headers(resp):
# 
# Path: libforget/auth.py
# def get_viewer_session():
#     from model import Session
#     sid = request.cookies.get('forget_sid', None)
#     if sid:
#         return Session.query.get(sid)
# 
# def set_session_cookie(session, response, secure=True):
#     response.set_cookie(
#         'forget_sid', session.id,
#         max_age=60*60*48,
#         httponly=True,
#         secure=secure)


# Path: routes/misc.py
from app import app, db, sentry
from flask import g, render_template, make_response, redirect, request
from libforget.auth import get_viewer_session, set_session_cookie
import version
import libforget.version

    g.viewer = get_viewer_session()
    if g.viewer and sentry:
        sentry.user_context({
                'id': g.viewer.account.id,
                'username': g.viewer.account.screen_name,
                'service': g.viewer.account.service
            })


@app.context_processor
def inject_version():
    v = version.get_versions()
    return dict(
            version=v['version'],
            repo_url=libforget.version.url_for_version(v),
        )


@app.context_processor
def inject_sentry():
    if sentry:
        return dict(sentry=True)
    return dict()


@app.after_request
def touch_viewer(resp):
    if 'viewer' in g and g.viewer:
        set_session_cookie(g.viewer, resp, app.config.get('HTTPS'))
        g.viewer.touch()

        db.session.commit()