{ "info": { "author": "Alan Hamlett", "author_email": "alan.hamlett@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Flask-Static-Compress\n=====================\n\n.. image:: https://travis-ci.org/alanhamlett/flask-static-compress.svg?branch=master\n :target: https://travis-ci.org/alanhamlett/flask-static-compress\n :alt: Tests\n\n.. image:: https://codecov.io/gh/alanhamlett/flask-static-compress/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/alanhamlett/flask-static-compress\n :alt: Coverage\n\nAuto-detects your static files for minification, combination, and versioning. Like Django-Compressor for Flask.\n\n\nInstallation\n------------\n\n::\n\n pip install flask-static-compress\n\n\nUsage\n-----\n\nJust wrap your existing css/js with a compress block and Flask-Static-Compress handles the rest::\n\n {% compress 'css' %}\n \n {% endcompress %}\n\n {% compress 'js' %}\n \n {% endcompress %}\n\nAlso, initialize the extension inside your Flask app::\n\n from flask_static_compress import FlaskStaticCompress\n app = Flask(__name__)\n compress = FlaskStaticCompress(app)\n\nAll static assets inside a ``compress`` block are compressed into a single file, and your html is updated to the new path when rendering the template.\n\nFor example::\n\n {% compress 'js' %}\n \n \n {% endcompress %}\n\nIs turned into::\n\n \n\nThe compressed ``a041936b125a3ec4ce9bf7a83130157d.js`` contains both ``app.js`` and ``config.js`` combined for faster page loading.\nThe file name is calculated based on the contents of ``app.js`` and ``config.js``.\nThis means any change to your static code is automatically reloaded, or cache-busted, in browsers.\n\nWith debug mode turned on, file names and line numbers are preserved while still running the compression flow::\n\n \n \n\nThe ``type`` attribute is used to decide which compressor to use for the asset.\n\nUse `offline compression `_ for improved performance.\n\nCreate `custom compressors `_ to support more types of static files.\n\nFor example, to remove trailing commas with `Prettier `_ then compress with `jsmin `_::\n\n import errno\n import subprocess\n from jac.compat import file, u, utf8_encode\n from jac.exceptions import InvalidCompressorError\n from rjsmin import jsmin\n\n\n class CustomJavaScriptCompressor(object):\n binary = 'prettier'\n\n @classmethod\n def compile(cls, content, mimetype='text/less', cwd=None, uri_cwd=None,\n debug=None):\n if debug:\n return content\n\n args = ['--no-config', '--ignore-path', '--trailing-comma', 'none']\n\n args.insert(0, cls.binary)\n\n try:\n handler = subprocess.Popen(args,\n stdout=subprocess.PIPE,\n stdin=subprocess.PIPE,\n stderr=subprocess.PIPE, cwd=None)\n except OSError as e:\n msg = '{0} encountered an error when executing {1}: {2}'.format(\n cls.__name__,\n cls.binary,\n u(e),\n )\n if e.errno == errno.ENOENT:\n msg += ' Make sure {0} is in your PATH.'.format(cls.binary)\n raise InvalidCompressorError(msg)\n\n if isinstance(content, file):\n content = content.read()\n (stdout, stderr) = handler.communicate(input=utf8_encode(content))\n stdout = u(stdout)\n\n if handler.returncode == 0:\n return jsmin(stdout)\n else:\n raise RuntimeError('Error compressing: %s' % stderr)\n\n\n COMPRESSOR_CLASSES = {\n 'text/javascript': CustomJavaScriptCompressor,\n }\n\n\nConfiguration\n-------------\n\n``COMPRESSOR_ENABLED`` Default: True\n\n``COMPRESSOR_OFFLINE_COMPRESS`` Default: False\n\n``COMPRESSOR_FOLLOW_SYMLINKS`` Default: False\n\n``COMPRESSOR_DEBUG`` Default: False\n\n``COMPRESSOR_OUTPUT_DIR`` Default: app.static_folder + '/sdist'\n\n``COMPRESSOR_STATIC_PREFIX`` Default: app.static_url_path + '/sdist'\n\n``COMPRESSOR_CLASSES`` Default::\n\n [\n 'text/css': LessCompressor,\n 'text/coffeescript': CoffeeScriptCompressor,\n 'text/less': LessCompressor,\n 'text/javascript': JavaScriptCompressor,\n 'text/sass': SassCompressor,\n 'text/scss': SassCompressor,\n ]\n\n\nThanks to Jay Santos, creator of `jac `_. Flask-Static-Compress is just a wrapper around jac!\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alanhamlett/flask-static-compress", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "Flask-Static-Compress", "package_url": "https://pypi.org/project/Flask-Static-Compress/", "platform": "any", "project_url": "https://pypi.org/project/Flask-Static-Compress/", "project_urls": { "Homepage": "https://github.com/alanhamlett/flask-static-compress" }, "release_url": "https://pypi.org/project/Flask-Static-Compress/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "Auto-detects your static files for minification, combination, and versioning. Like Django-Compressor for Flask.", "version": "1.0.2" }, "last_serial": 3270201, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "cf829c973e8166c72130150ed9ff2c34", "sha256": "2c284ba2b2b32c3633e1051ee382d2f6a413aa5bcf72e7ee07cc6c42232130bb" }, "downloads": -1, "filename": "Flask-Static-Compress-1.0.0.tar.gz", "has_sig": false, "md5_digest": "cf829c973e8166c72130150ed9ff2c34", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3549, "upload_time": "2016-12-15T12:25:49", "url": "https://files.pythonhosted.org/packages/5b/67/9ef0d5a3b9b758d49744cfb03a20884a264ce568de5ce02e1a04a17b3773/Flask-Static-Compress-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "03d9a282598ee1b5e544f45622fa7eb1", "sha256": "a5649f36fe6e75a2ee2d7cce99db7527f307f4a5756a0478a2a3b15abc9e8e70" }, "downloads": -1, "filename": "Flask-Static-Compress-1.0.1.tar.gz", "has_sig": false, "md5_digest": "03d9a282598ee1b5e544f45622fa7eb1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4035, "upload_time": "2017-08-28T00:58:39", "url": "https://files.pythonhosted.org/packages/0e/21/a68a4e0608d150f48fed742c5a1f10b1f5a1cf525b06a4a10ad6c255a85d/Flask-Static-Compress-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "9d1d9b7a1d5e963633b895583a96c384", "sha256": "fbe494ba840fe861614ea5ae7fa23e1f4f92dae76b33c15ac48a3a68620b18a4" }, "downloads": -1, "filename": "Flask-Static-Compress-1.0.2.tar.gz", "has_sig": false, "md5_digest": "9d1d9b7a1d5e963633b895583a96c384", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5062, "upload_time": "2017-10-22T17:33:13", "url": "https://files.pythonhosted.org/packages/36/f1/421a9570be04bac2b430a65b3b0e24a08cb9867410cb77df5ed5ec2b8e0e/Flask-Static-Compress-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9d1d9b7a1d5e963633b895583a96c384", "sha256": "fbe494ba840fe861614ea5ae7fa23e1f4f92dae76b33c15ac48a3a68620b18a4" }, "downloads": -1, "filename": "Flask-Static-Compress-1.0.2.tar.gz", "has_sig": false, "md5_digest": "9d1d9b7a1d5e963633b895583a96c384", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5062, "upload_time": "2017-10-22T17:33:13", "url": "https://files.pythonhosted.org/packages/36/f1/421a9570be04bac2b430a65b3b0e24a08cb9867410cb77df5ed5ec2b8e0e/Flask-Static-Compress-1.0.2.tar.gz" } ] }