diff --git a/.gitignore b/.gitignore index db4561e..3135745 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Custom +venv/ + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..347a0ef --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,21 @@ +from flask import Flask, render_template +from flask.ext.bootstrap import Bootstrap +from flask.ext.sqlalchemy import SQLAlchemy +from config import config + +bootstrap = Bootstrap() +db = SQLAlchemy() + +def create_app(config_name): + app = Flask(__name__) + app.config.from_object(config[config_name]) + config[config_name].init_app(app) + + bootstrap.init_app(app) + db.init_app(app) + + # attach routes and custom error pages + from .main import main as main_blueprint + app.register_blueprint(main_blueprint) + + return app diff --git a/app/main/__init__.py b/app/main/__init__.py new file mode 100644 index 0000000..5a8cf53 --- /dev/null +++ b/app/main/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint, render_template + +main = Blueprint('main', __name__) + +@main.route('/') +def index(): + return render_template('index.html') diff --git a/app/models.py b/app/models.py new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/base.html b/app/templates/base.html new file mode 100644 index 0000000..a000d64 --- /dev/null +++ b/app/templates/base.html @@ -0,0 +1,37 @@ +{% extends "bootstrap/base.html" %} + +{% block title %}Sirius{% endblock %} + +{% block navbar %} + +{% endblock %} + +{% block content %} +
+ {% for message in get_flashed_messages() %} +
+ + {{ message }} +
+ {% endfor %} + + {% block page_content %}{% endblock %} +
+{% endblock %} diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000..5c33eac --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block title %}Sirius - Index{% endblock %} + +{% block page_content %} +

Hello, World!

+{% endblock %} \ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000..49993cf --- /dev/null +++ b/config.py @@ -0,0 +1,22 @@ +import os +basedir = os.path.abspath(os.path.dirname(__file__)) + + +class Config: + SECRET_KEY = os.environ.get('SECRET_KEY') or 'this is the lp2 secret' + SQLALCHEMY_COMMIT_ON_TEARDOWN = True + + @staticmethod + def init_app(app): + pass + +class DevelopmentConfig(Config): + DEBUG = True + SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \ + 'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite') + +config = { + 'development': DevelopmentConfig, + + 'default': DevelopmentConfig +} \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..460e9b7 --- /dev/null +++ b/manage.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import os + +if os.path.exists('.env'): + print('Importing environment from .env...') + for line in open('.env'): + var = line.strip().split('=') + if len(var) == 2: + os.environ[var[0]] = var[1] + +from app import create_app, db +from flask.ext.script import Manager, Shell +from flask.ext.migrate import Migrate, MigrateCommand + +app = create_app(os.getenv('FLASK_CONFIG') or 'default') +manager = Manager(app) +migrate = Migrate(app, db) + + +def make_shell_context(): + return dict(app=app, db=db, User=User, Follow=Follow, Role=Role, + Permission=Permission, Post=Post, Comment=Comment) +manager.add_command("shell", Shell(make_context=make_shell_context)) +manager.add_command('db', MigrateCommand) + + +if __name__ == '__main__': + manager.run() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8dc21d9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,12 @@ +Flask==0.10.1 +Flask-Bootstrap==3.2.0.2 +Flask-Migrate==1.2.0 +Flask-SQLAlchemy==2.0 +Flask-Script==2.0.5 +Jinja2==2.7.3 +Mako==1.0.0 +MarkupSafe==0.23 +SQLAlchemy==0.9.7 +Werkzeug==0.9.6 +alembic==0.6.7 +itsdangerous==0.24