Ejemplo n.º 1
0
    def __init__(self, manager, parser):
        self.manager = manager
        self.gears = Gears(
            compilers={
            '.less': LESSCompiler.as_handler(),
            '.coffee': CoffeeScriptCompiler.as_handler(),
            #    '.hbs': 'gears_handlebars.HandlebarsCompiler'
            },
            public_assets=(
                os.path.join(settings.PROJECT_DIR, 'hpit/server/assets/css/style.css'), 
                os.path.join(settings.PROJECT_DIR, 'hpit/server/assets/js/script.js')
            )
        )

        parser.add_argument('--dest', type=str, default="hpit/server/assets/compiled", help="The destination directory of where to put these assets.")
        parser.add_argument('--watch', action='store_true', help="Watch for changes to source files and compile on demand.")
Ejemplo n.º 2
0
    def __init__(self, manager, parser):
        self.manager = manager
        self.gears = Gears(
            compilers={
                '.less': LESSCompiler.as_handler(),
                '.coffee': CoffeeScriptCompiler.as_handler(),
                #    '.hbs': 'gears_handlebars.HandlebarsCompiler'
            },
            public_assets=(os.path.join(settings.PROJECT_DIR,
                                        'hpit/server/assets/css/style.css'),
                           os.path.join(settings.PROJECT_DIR,
                                        'hpit/server/assets/js/script.js')))

        parser.add_argument(
            '--dest',
            type=str,
            default="hpit/server/assets/compiled",
            help="The destination directory of where to put these assets.")
        parser.add_argument(
            '--watch',
            action='store_true',
            help="Watch for changes to source files and compile on demand.")
Ejemplo n.º 3
0
    def __init__(self):
        if self.instance:
            raise ValueError("ServerApp instance already created.")

        self.gears = Gears(
            compilers={
                '.less': LESSCompiler.as_handler(),
                '.coffee': CoffeeScriptCompiler.as_handler(),
                #    '.hbs': 'gears_handlebars.HandlebarsCompiler'
            })

        self.app = Flask(__name__)
        self.gears.init_app(self.app)

        self.app.config.from_object(settings)

        import logging
        from logging.handlers import RotatingFileHandler
        log_handler = RotatingFileHandler("log/app.log",
                                          maxBytes=10000000,
                                          backupCount=1)  #10mb
        log_handler.setLevel(logging.DEBUG)
        self.app.logger.addHandler(log_handler)

        try:
            self.mongo = PyMongo(self.app)
            #self.app.session_interface = MongoSessionInterface(self.app, self.mongo)
        except ConnectionFailure:
            self.mongo = None

        self.babel = Babel(self.app)
        self.db = SQLAlchemy(self.app)
        self.mail = Mail(self.app)
        self.md = Markdown(self.app)
        self.csrf = CsrfProtect(self.app)

        self.user_bootstrapped = False
Ejemplo n.º 4
0
    def __init__(self):
        if self.instance:
            raise ValueError("ServerApp instance already created.")

        self.gears = Gears(
            compilers={
            '.less': LESSCompiler.as_handler(),
            '.coffee': CoffeeScriptCompiler.as_handler(),
            #    '.hbs': 'gears_handlebars.HandlebarsCompiler'
            }
        )

        self.app = Flask(__name__)
        self.gears.init_app(self.app)

        self.app.config.from_object(settings)
        
        import logging
        from logging.handlers import RotatingFileHandler
        log_handler = RotatingFileHandler("log/app.log",maxBytes = 10000000, backupCount = 1) #10mb
        log_handler.setLevel(logging.DEBUG)
        self.app.logger.addHandler(log_handler)

        try:
            self.mongo = PyMongo(self.app)
            #self.app.session_interface = MongoSessionInterface(self.app, self.mongo)
        except ConnectionFailure:
            self.mongo = None

        self.babel = Babel(self.app)
        self.db = SQLAlchemy(self.app)
        self.mail = Mail(self.app)
        self.md = Markdown(self.app)
        self.csrf = CsrfProtect(self.app)

        self.user_bootstrapped = False
Ejemplo n.º 5
0
from gears.compressors import SlimItCompressor, CSSMinCompressor
from gears_coffeescript import CoffeeScriptCompiler
from gears_less import LESSCompiler


_compilers = {
    ".coffee": CoffeeScriptCompiler.as_handler(),
    ".less": LESSCompiler.as_handler()
}

_compressors = {
    "text/css": CSSMinCompressor.as_handler(),
    "application/javascript": SlimItCompressor.as_handler()
}


gears_environment = lambda app: app.extensions["gears"]["environment"]
gears_environment.__doc__ = """Gets gears environments of the app instance."""


def setup_assets_compilers(app):
    """Set up compilers of assets."""
    env = gears_environment(app)
    for extension, compiler in _compilers.iteritems():
        env.compilers.register(extension, compiler)


def setup_assets_compressors(app):
    """Set up compressors of assets."""
    env = gears_environment(app)
    if not app.config["DEBUG"] or app.config["TESTING"]:
Ejemplo n.º 6
0
app.config.from_object(
    os.environ.get('FLASK_SETTINGS_MODULE', 'app.settings.production'))


class RegexConverter(BaseConverter):
    def __init__(self, url_map, *items):
        super(RegexConverter, self).__init__(url_map)
        self.regex = items[0]


app.url_map.converters['regex'] = RegexConverter

gears = Gears(
    compilers={
        '.styl': StylusCompiler.as_handler(),
        '.less': LESSCompiler.as_handler(),
        '.coffee': CoffeeScriptCompiler.as_handler(),
        '.sass': SASSCompiler.as_handler(),
        '.scss': SASSCompiler.as_handler()
    },
    compressors={
        'text/css': CleanCSSCompressor.as_handler(),
        'text/javascript': UglifyJSCompressor.as_handler()
    },
)
gears.init_app(app)
db = SQLAlchemy(app)
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'
# admin = Admin(app)
Ejemplo n.º 7
0
from gears_stylus import StylusCompiler
from gears_less import LESSCompiler
from gears_coffeescript import CoffeeScriptCompiler
from gears_sass import SASSCompiler
from gears_clean_css import CleanCSSCompressor
from gears_uglifyjs import UglifyJSCompressor

from app import app, db

migrate = Migrate(app, db)

gears = Gears(
    compilers={
        '.styl': StylusCompiler.as_handler(),
        '.less': LESSCompiler.as_handler(),
        '.coffee': CoffeeScriptCompiler.as_handler(),
        '.sass': SASSCompiler.as_handler(),
        '.scss': SASSCompiler.as_handler()
    },
    compressors={
        'text/css': CleanCSSCompressor.as_handler(),
        'text/javascript': UglifyJSCompressor.as_handler()
    },
)
gears.init_app(app)

manager = Manager(app)
manager.add_command('db', MigrateCommand)
manager.add_command('runserver', Server(host='0.0.0.0', port=80))
Ejemplo n.º 8
0
import os

from gears.environment import Environment
from gears.finders import FileSystemFinder

from gears_less import LESSCompiler


ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
ASSETS_DIR = os.path.join(ROOT_DIR, "assets")
STATIC_DIR = os.path.join(ROOT_DIR, "static")

env = Environment(STATIC_DIR)
env.finders.register(FileSystemFinder([ASSETS_DIR]))
env.compilers.register(".less", LESSCompiler.as_handler())
env.register_defaults()


if __name__ == "__main__":
    env.save()