Exemple #1
0
 def load_plugins(self):
     """Load all the plugins specified by the config file."""
     for plugin in self.blueprints:
         plugin = plugin.strip()
         if not plugin: continue
         load_plugin(plugin)
     for custom in self.custom:
         custom = custom.strip()
         if not custom: continue
         load_plugin(custom, as_blueprint=False)
Exemple #2
0
 def load_plugins(self):
     """Load all the plugins specified by the config file."""
     for plugin in self.blueprints:
         plugin = plugin.strip()
         if not plugin: continue
         load_plugin(plugin)
     for custom in self.custom:
         custom = custom.strip()
         if not custom: continue
         load_plugin(custom, as_blueprint=False)
Exemple #3
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
"""Endpoints for the commenting subsystem."""

from flask import Blueprint, g, request, redirect, url_for, flash
import time

import rophako.model.user as User
import rophako.model.comment as Comment
from rophako.utils import (template, pretty_time, login_required,
                           sanitize_name, remote_addr)
from rophako.plugin import load_plugin
from rophako.settings import Config

mod = Blueprint("comment", __name__, url_prefix="/comments")
load_plugin("rophako.modules.emoticons")


@mod.route("/")
def index():
    return template("blog/index.html")


@mod.route("/preview", methods=["POST"])
def preview():
    # Get the form fields.
    form = get_comment_form(request.form)
    thread = sanitize_name(form["thread"])

    # Trap fields.
    trap1 = request.form.get("website", "x") != "http://"
Exemple #4
0
                else "unicode_escape"

app.DEBUG      = Config.site.debug == "true"
app.secret_key = bytes(Config.security.secret_key.encode("utf-8")) \
                 .decode(string_escape)

# Make templates easier to edit live.
app.config["TEMPLATES_AUTO_RELOAD"] = True

# Security?
if Config.security.force_ssl == True:
    app.config['SESSION_COOKIE_SECURE'] = True
    sslify = SSLify(app)

# Load all the built-in essential plugins.
load_plugin("rophako.modules.admin")
load_plugin("rophako.modules.account")

# Custom Jinja handler to support custom- and default-template folders for
# rendering templates.
template_paths = [
   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
Exemple #5
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

"""Endpoints for the photo albums."""

from flask import Blueprint, g, request, redirect, url_for, flash

import rophako.model.user as User
import rophako.model.photo as Photo
from rophako.utils import (template, pretty_time, render_markdown,
    login_required, ajax_response)
from rophako.plugin import load_plugin
from rophako.settings import Config

mod = Blueprint("photo", __name__, url_prefix="/photos")
load_plugin("rophako.modules.comment")

@mod.route("/")
def index():
    return redirect(url_for(".albums"))


@mod.route("/albums")
def albums():
    """View the index of the photo albums."""
    albums = Photo.list_albums()

    # If there's only one album, jump directly to that one.
    if len(albums) == 1:
        return redirect(url_for(".album_index", name=albums[0]["name"]))
Exemple #6
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

"""Endpoints for the commenting subsystem."""

from flask import Blueprint, g, request, redirect, url_for, flash
import time

import rophako.model.user as User
import rophako.model.comment as Comment
from rophako.utils import (template, pretty_time, sanitize_name, remote_addr)
from rophako.plugin import load_plugin
from rophako.settings import Config

mod = Blueprint("comment", __name__, url_prefix="/comments")
load_plugin("rophako.modules.emoticons")


@mod.route("/")
def index():
    return template("blog/index.html")


@mod.route("/preview", methods=["POST"])
def preview():
    # Get the form fields.
    form   = get_comment_form(request.form)
    thread = sanitize_name(form["thread"])

    # Trap fields.
    trap1 = request.form.get("website", "x") != "http://"
Exemple #7
0
# String escaping for the secret key (processes \ escapes properly), the
# escape encoding name varies between Python 2 and 3.
string_escape = "string_escape" if sys.version_info[0] == 2 \
                else "unicode_escape"

app.DEBUG = Config.site.debug == "true"
app.secret_key = bytes(Config.security.secret_key.encode("utf-8")) \
                 .decode(string_escape)

# Security?
if Config.security.force_ssl == True:
    app.config['SESSION_COOKIE_SECURE'] = True
    sslify = SSLify(app)

# Load all the built-in essential plugins.
load_plugin("rophako.modules.admin")
load_plugin("rophako.modules.account")

# Custom Jinja handler to support custom- and default-template folders for
# rendering templates.
template_paths = [
    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.globals["csrf_token"] = rophako.utils.generate_csrf_token
app.jinja_env.globals["include_page"] = rophako.utils.include
app.jinja_env.globals["settings"] = lambda: Config
Exemple #8
0
import rophako.model.blog as Blog
import rophako.model.comment as Comment
import rophako.model.emoticons as Emoticons
from rophako.utils import (template, render_markdown, pretty_time,
    login_required, remote_addr)
from rophako.plugin import load_plugin
from rophako.settings import Config
from rophako.log import logger

import sys
if sys.version_info[0] > 2:
    def unicode(s):
        return str(s)

mod = Blueprint("blog", __name__, url_prefix="/blog")
load_plugin("rophako.modules.comment")

@mod.route("/")
def index():
    return template("blog/index.html")


@mod.route("/archive")
def archive():
    """List all blog posts over time on one page."""
    index = Blog.get_index()

    # Group by calendar month, and keep track of friendly versions of months.
    groups = dict()
    friendly_months = dict()
    for post_id, data in index.items():