Esempio n. 1
0
def index():
    """List the available emoticons."""
    theme = Emoticons.load_theme()

    smileys = []
    for img in sorted(theme["map"]):
        smileys.append({
            "img": img,
            "triggers": theme["map"][img],
        })

    g.info["theme"] = Config.emoticons.theme
    g.info["theme_name"] = theme["name"]
    g.info["smileys"]    = smileys
    return template("emoticons/index.html")
Esempio n. 2
0
   Config.site.site_root, # Site specific.
   "rophako/www",         # Default/fall-back
]
template_paths.extend(BLUEPRINT_PATHS)
app.jinja_loader = jinja2.ChoiceLoader([ jinja2.FileSystemLoader(x) for x in template_paths])

app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
app.jinja_env.globals["csrf_token"] = rophako.utils.generate_csrf_token
app.jinja_env.globals["include_page"] = rophako.utils.include
app.jinja_env.globals["settings"] = lambda: Config
app.jinja_env.globals["strftime"] = lambda x: datetime.datetime.utcnow().strftime(x)

# Preload the emoticon data.
import rophako.model.emoticons as Emoticons
Emoticons.load_theme()


@app.before_request
def before_request():
    """Called before all requests. Initialize global template variables."""

    # Session lifetime.
    app.permanent_session_lifetime = datetime.timedelta(days=Config.security.session_lifetime)
    session.permanent = True

    # Default template vars.
    g.info = rophako.utils.default_vars()

    # Default session vars.
    if not "login" in session:
Esempio n. 3
0
    "rophako/www",  # Default/fall-back
]
template_paths.extend(BLUEPRINT_PATHS)
app.jinja_loader = jinja2.ChoiceLoader(
    [jinja2.FileSystemLoader(x) for x in template_paths])

app.jinja_env.globals["csrf_token"] = rophako.utils.generate_csrf_token
app.jinja_env.globals["include_page"] = rophako.utils.include
app.jinja_env.globals["settings"] = lambda: Config
app.jinja_env.globals["strftime"] = lambda x: datetime.datetime.utcnow(
).strftime(x)

# Preload the emoticon data.
import rophako.model.emoticons as Emoticons

Emoticons.load_theme()


@app.before_request
def before_request():
    """Called before all requests. Initialize global template variables."""

    # Default template vars.
    g.info = rophako.utils.default_vars()

    # Default session vars.
    if not "login" in session:
        session.update(g.info["session"])

    # CSRF protection.
    if request.method == "POST":