Exemplo n.º 1
0
    def __init__(self):
        self._log = logging.getLogger('%s.DilloExtension' % __name__)

        self.oembed_registry = bootstrap_basic()
        self.oembed_registry.register('https?://sketchfab.com/models/*',
                                      Provider('https://sketchfab.com/oembed'))
        self.oembed_registry.register('https?://p3d.in/*',
                                      Provider('https://p3d.in/oembed'))
        self.oembed_registry.register(
            'https?://instagram.com/p/*',
            Provider('http://api.instagram.com/oembed'))
        self.has_context_processor = True
Exemplo n.º 2
0
def register_filters(app):
    # Library filters
    Misaka(app, autolink=True, fenced_code=True, strikethrough=True, tables=True)

    # Registration of handlers for micawber
    app.oembed_providers = bootstrap_basic()
    @app.template_filter()
    def onebox(value):
        return make_oembedplus(value, app.oembed_providers, maxwidth=600, maxheight=400)

    # Custom filterss
    @app.template_filter()
    def since_date(value):
        return timesince(value)
    @app.template_filter()
    def until_date(value):
        return timesince(value, default="now!", until=True)
    @app.template_filter()
    def format_date(value, format='%d.%m.%Y'):
        return value.strftime(format)
    @app.template_filter()
    def format_datetime(value, format='%d.%m.%Y %H:%M'):
        return value.strftime(format)
Exemplo n.º 3
0
from sqlalchemy.orm import sessionmaker
from database_setup import Base, Category, Item, User
import httplib2
import json
import requests
# import random
import string

engine = create_engine('sqlite:///catalog.db')
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()
app = Flask(__name__)
APP_PATH = os.path.dirname(os.path.abspath(__file__))
auth = HTTPBasicAuth()
oembed_providers = bootstrap_basic()
add_oembed_filters(app, oembed_providers)


@auth.verify_password
def verify_password(username_or_token, password):
    # check to see if it's a token first
    session = DBSession()
    user_id = User.verify_auth_token(username_or_token)
    if user_id:
        user = session.query(User).filter_by(id=user_id).one()
    else:
        user = session.query(User).filter_by(username=username_or_token).\
            first()
        if not user or not user.verify_password(password):
            return False
Exemplo n.º 4
0
from config import Config
#from config.Config import S3_BUCKET, S3_KEY, S3_SECRET

db = SQLAlchemy()
migrate = Migrate()
login = LoginManager()
login.login_view = 'auth.login'
login.login_message = _l('Please log in to access this page.')
mail = Mail()
bootstrap = Bootstrap()
#storage = Storage()
moment = Moment()
babel = Babel()
pagedown = PageDown()
simplemde = SimpleMDE()
providers = bootstrap_basic(embed())


def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(config_class)
    #s3 = boto3.resource("s3",
    #aws_access_key_id = app.config['S3_KEY'],
    #aws_secret_access_key = app.config['S3_SECRET'])
    #app.config.update({
    #"STORAGE_PROVIDER": "S3_US_WEST_OREGON",
    #"STORAGE_CONTAINER": "ogahslab",
    #"STORAGE_KEY": "AKIAJNTHNLVH",
    #"STORAGE_SECRET": "adLbSrNsPvRZnjvy0YtbKJOtVPv9",
    #"STORAGE_SERVER": True
    #})
Exemplo n.º 5
0
    static_folder='static')
# Static and Template folders are overridden in settings.py, based on user
# preferences. If a theme is set, it will alter the paths pointing to the
# custom templates and static provided.

app.config.from_object(config.Deployment)

db = SQLAlchemy(app)
mail = Mail(app)
oauth = OAuth(app)
CsrfProtect(app)
cache = Cache(app)
toolbar = DebugToolbarExtension(app)


registry = bootstrap_basic()
registry.register('http://monitor.eibriel.com/\S*',
    Provider('http://monitor.eibriel.com/api/job/oembed'))
registry.register('https?://sketchfab.com/models/*',
    Provider('https://sketchfab.com/oembed'))
registry.register('https?://p3d.in/*',
    Provider('https://p3d.in/oembed'))
registry.register('https?://vine.co/v/*',
    Provider('https://vine.co/oembed.json'))
registry.register('https?://instagram.com/p/*',
    Provider('http://api.instagram.com/oembed'))

if app.config.get('CACHE_REDIS_HOST') and app.config['CACHE_TYPE'] == 'redis':
    redis_client = redis.StrictRedis(
        host=app.config['CACHE_REDIS_HOST'],
        port=app.config['CACHE_REDIS_PORT'])
Exemplo n.º 6
0
import config
from micawber.providers import bootstrap_basic
from micawber.contrib.mcflask import add_oembed_filters

app = Flask(__name__, static_folder='./static',
                template_folder='./templates')


# log to stderr
import logging
from logging import StreamHandler
file_handler = StreamHandler()
app.logger.setLevel(logging.DEBUG)  # set the desired logging level here
app.logger.addHandler(file_handler)

# app.debug = True
app.config.from_object(config)

db = SQLAlchemy(app)

RQ(app)

# login_manager = LoginManager()
# login_manager.init_app(app)

oembed_providers = bootstrap_basic()
add_oembed_filters(app, oembed_providers)

import views, models
Exemplo n.º 7
0
import os
from flask import Flask
from micawber.providers import bootstrap_basic
from peewee import SqliteDatabase

APP_ROOT = os.path.dirname(os.path.realpath(__file__))
DATABASE = os.path.join(APP_ROOT, 'notes.db')
DEBUG = False

app = Flask(__name__)
app.config.from_object(__name__)
db = SqliteDatabase(app.config['DATABASE'], threadlocals=True)
oembed = bootstrap_basic()
Exemplo n.º 8
0
    static_folder='static')
# Static and Template folders are overridden in settings.py, based on user
# preferences. If a theme is set, it will alter the paths pointing to the
# custom templates and static provided.

app.config.from_object(config.Deployment)

db = SQLAlchemy(app)
mail = Mail(app)
oauth = OAuth(app)
CsrfProtect(app)
cache = Cache(app)
toolbar = DebugToolbarExtension(app)


registry = bootstrap_basic()
registry.register('http://monitor.eibriel.com/\S*',
    Provider('http://monitor.eibriel.com/api/job/oembed'))
registry.register('https?://sketchfab.com/models/*',
    Provider('https://sketchfab.com/oembed'))
registry.register('https?://p3d.in/*',
    Provider('https://p3d.in/oembed'))
registry.register('https?://vine.co/v/*',
    Provider('https://vine.co/oembed.json'))
registry.register('https?://instagram.com/p/*',
    Provider('http://api.instagram.com/oembed'))

if app.config.get('CACHE_REDIS_HOST') and app.config['CACHE_TYPE'] == 'redis':
    redis_client = redis.StrictRedis(
        host=app.config['CACHE_REDIS_HOST'],
        port=app.config['CACHE_REDIS_PORT'])