Ejemplo n.º 1
0
    def setUp(self):
        # initialize the flask app
        app = flask.Flask(__name__)
        app.config["TESTING"] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        # some simple processors
        def test1(content):
            return "FOOBAR" + str(content)

        def test2(content):
            return str(content) + "BARFOO"

        compressor.register_processor(test1)
        compressor.register_processor(test2)

        # our bundle
        bundle = Bundle(
            name="test_bundle",
            assets=[Asset(content="first asset", processors=["test1"]), Asset(content="second asset")],
            processors=["test2"],
        )
        self.bundle = bundle

        compressor.register_bundle(bundle)
Ejemplo n.º 2
0
    def setUp(self):
        # initialize the flask app
        app = flask.Flask(__name__)
        app.config["TESTING"] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        # our bundle
        bundle = CSSBundle(name="test_bundle", assets=[Asset(content="first asset"), Asset(content="second asset")])
        self.bundle = bundle

        compressor.register_bundle(bundle)
Ejemplo n.º 3
0
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {"/": os.path.join(os.path.dirname(__file__), "static")})


#
# Web assets
#
css_bundle = CSSBundle(
    name="all.css",
    assets=[
        FileAsset("css/normalize.css"),
        Asset(pygments_style_defs()),
        FileAsset("css/styles.less", processors=["lesscss"]),
    ],
    processors=["cssmin"],
)
compressor.register_bundle(css_bundle)


#
# Filters
#
@app.template_filter()
def dateformat(value, format=u"%H:%M / %d-%m-%Y"):
    if not value:
        return u""
    return unicode(value.strftime(format).decode("utf8"))


@app.template_filter()
def summarize(html):
    if "<!-- BODY -->" in html: