pax_global_header00006660000000000000000000000064132533320410014506gustar00rootroot0000000000000052 comment=af86cb287ec7f90d528533c7e29f1e23cc38e38b Flask-HTMLmin-1.3.2/000077500000000000000000000000001325333204100140175ustar00rootroot00000000000000Flask-HTMLmin-1.3.2/.gitignore000066400000000000000000000000261325333204100160050ustar00rootroot00000000000000.idea/ env/ .DS_Store Flask-HTMLmin-1.3.2/LICENSE000066400000000000000000000027271325333204100150340ustar00rootroot00000000000000Copyright (c) 2015, Hamid Feizabadi All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Hamid Feizabadi nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Hamid Feizabadi BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.Flask-HTMLmin-1.3.2/MANIFEST.in000066400000000000000000000000421325333204100155510ustar00rootroot00000000000000include README.md include LICENSE Flask-HTMLmin-1.3.2/README.md000066400000000000000000000020151325333204100152740ustar00rootroot00000000000000Flask-HTMLmin ============= Minify flask `text/html` mime types responses. Just add `MINIFY_PAGE = True` to your deployment config to minify html and text responses of your flask application. Installation ------------ To install Flask-HTMLmin, simply: pip install Flask-HTMLmin Or alternatively, you can download the repository and install manually by doing: git clone git@github.com:hamidfzm/Flask-HTMLmin.git cd Flask-HTMLmin python setup.py install Example ------- from flask import Flask, render_template from flask_htmlmin import HTMLMIN app = Flask(__name__) app.config['MINIFY_PAGE'] = True HTMLMIN(app) # or you can use HTMLMIN.init_app(app) # pass additional parameters to htmlmin # HTMLMIN(app, **kwargs) @app.route('/') def main(): # index.html will be minimized !!! return render_template('index.html') if __name__ == '__main__': app.run() TODO ---- - [ ] Test cases - [ ] Route (or URL rule) exemption Flask-HTMLmin-1.3.2/flask_htmlmin.py000066400000000000000000000020451325333204100172220ustar00rootroot00000000000000from htmlmin import Minifier __author__ = 'Hamid FzM' class HTMLMIN(object): def __init__(self, app=None, **kwargs): self.app = app if app is not None: self.init_app(app) default_options = { 'remove_comments': True, 'reduce_empty_attributes': True, 'remove_optional_attribute_quotes': False } default_options.update(kwargs) self.html_minify = Minifier( **default_options) def init_app(self, app): app.config.setdefault('MINIFY_PAGE', False) if app.config['MINIFY_PAGE']: app.after_request(self.response_minify) def response_minify(self, response): """ minify response html to decrease traffic """ if response.content_type == u'text/html; charset=utf-8': response.direct_passthrough = False response.set_data( self.html_minify.minify(response.get_data(as_text=True)) ) return response return response Flask-HTMLmin-1.3.2/setup.py000066400000000000000000000020751325333204100155350ustar00rootroot00000000000000 """ Flask-HTMLmin ------------- minimize your flask rendered html """ from setuptools import setup setup( name='Flask-HTMLmin', version='1.3.2', url='https://github.com/hamidfzm/Flask-HTMLmin', license='BSD-3-Clause', author='Hamid FzM', author_email='hamidfzm@gmail.com', description='Minimize render templates html', long_description=__doc__, py_modules=['flask_htmlmin'], zip_safe=False, include_package_data=True, platforms='any', install_requires=[ 'Flask', 'htmlmin' ], classifiers=[ 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.2', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Text Processing :: Markup :: HTML', ] )