[Python-modules-commits] [flask-htmlmin] 01/06: New upstream version 1.3.1

Adrian Vondendriesch discostu-guest at moszumanska.debian.org
Wed Nov 8 10:20:29 UTC 2017


This is an automated email from the git hooks/post-receive script.

discostu-guest pushed a commit to branch debian/master
in repository flask-htmlmin.

commit 2e68b93e4168c76ca514104fc89791d99688bcfd
Author: Adrian Vondendriesch <adrian.vondendriesch at credativ.de>
Date:   Wed Nov 8 10:03:27 2017 +0100

    New upstream version 1.3.1
---
 MANIFEST.in      |  2 ++
 README.md        |  4 +++-
 flask_htmlmin.py | 20 ++++++++++++++------
 setup.py         |  2 +-
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..04f196a
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,2 @@
+include README.md
+include LICENSE
diff --git a/README.md b/README.md
index 4bd103b..7f42ad2 100644
--- a/README.md
+++ b/README.md
@@ -22,13 +22,15 @@ Example
 -------
 
     from flask import Flask, render_template
-    from flask.ext.htmlmin import HTMLMIN
+    from flask.ext_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():
diff --git a/flask_htmlmin.py b/flask_htmlmin.py
index e6b7edf..e1cdaff 100644
--- a/flask_htmlmin.py
+++ b/flask_htmlmin.py
@@ -1,30 +1,38 @@
-from htmlmin.main import minify
+from htmlmin import Minifier
 
 __author__ = 'Hamid FzM'
 
 
 class HTMLMIN(object):
-    def __init__(self, app=None):
+    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)
 
-    @staticmethod
-    def response_minify(response):
+    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(
-                minify(response.get_data(as_text=True),
-                       remove_comments=True, reduce_empty_attributes=True, remove_optional_attribute_quotes=False)
+                self.html_minify.minify(response.get_data(as_text=True))
             )
 
             return response
diff --git a/setup.py b/setup.py
index 238887d..a14d934 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ from setuptools import setup
 
 setup(
     name='Flask-HTMLmin',
-    version='1.2',
+    version='1.3.1',
     url='https://github.com/hamidfzm/Flask-HTMLmin',
     license='BSD',
     author='Hamid FzM',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/flask-htmlmin.git



More information about the Python-modules-commits mailing list