예제 #1
0
파일: app.py 프로젝트: alexpirine/shelf-cms
def create_app():
    app = Flask(__name__)

    app.debug = True
    app.testing = False

    import config
    app.config.from_object(config)

    app.config['SHELF_PAGES'] = {
        "index": (IndexPage, IndexPageModelView),
        "contact": (ContactPage, ContactPageModelView),
    }

    with app.app_context():
        db.init_app(app)
        db.create_all()

        babel = Babel(app)

        shlf = Shelf(app)
        shlf.init_db(db)

        dview = DashboardView()
        shlf.init_admin(index_view=dview)

        shlf.init_security(User, Role)

        shlf.load_plugins((
            "shelf.plugins.dashboard",
            "shelf.plugins.i18n",
            "shelf.plugins.library",
            "shelf.plugins.page",
            "shelf.plugins.preview",
            "shelf.plugins.workflow",
            "shelf.plugins.wysiwyg",
            "shelf.plugins.ecommerce",
        ))
        init_admin(shlf.admin, db.session)
        shlf.setup_plugins()

        page = shlf.get_plugin_by_class(PagePlugin)
        page.register_pages(app, shlf.db)

        init_views(app)
        init_filters(app)

    return app
예제 #2
0
from flask import Flask

from shelf import LazyConfigured
from shelf import Shelf
from shelf.base import db
from shelf.security.models import User, Role
from shelf.admin.view import SQLAModelView
from sqlalchemy_defaults import Column

app = Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///simplest.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['SECRET_KEY'] = 'notasecret'

class Post(LazyConfigured):
    id = Column(db.Integer, primary_key=True)

    title = Column(db.Unicode(150))
    content = Column(db.UnicodeText)

with app.app_context():
    db.init_app(app)
    shlf = Shelf(app)
    shlf.init_db(db)
    shlf.init_admin()
    shlf.init_security(User, Role)
    shlf.admin.add_view(SQLAModelView(Post, db.session))

    app.run('0.0.0.0')
예제 #3
0
파일: app.py 프로젝트: batimentb/shelf-cms
from shelf import Shelf
from shelf.plugins.library import FileAdmin

import admin
import model

app = Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///blog.db'
app.config['SECRET_KEY'] = 'notasecret'
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = 'mysalt'#"hash_123678*",
app.config['SECURITY_REGISTER_EMAIL'] = False
model.db.init_app(app)
model.db.app = app

shlf = Shelf(app)
shlf.init_db(model.db)
shlf.init_admin()
shlf.init_security(model.User, model.Role)
shlf.load_plugins((
    "shelf.plugins.wysiwyg",
    "shelf.plugins.workflow",
    "shelf.plugins.library"
))
shlf.admin.add_view(admin.PostModelView(model.Post, model.db.session))
shlf.admin.add_view(FileAdmin("static/", name="Media"))
shlf.setup_plugins()
app.run('0.0.0.0')