This project has been archived by its maintainers, and is no longer receiving any updates.
RevAssets
===========================
.. image:: https://travis-ci.org/jpscaletti/rev-assets.svg?branch=master
:target: https://travis-ci.org/jpscaletti/rev-assets
:alt: Build Status
You care about the performance of your site, so you've configured the web server to cache all your assets for a long time. The most used way to bypass that cache when deploying a new version, is to add a hash of the assets to their names.
::
'scripts/home.js' --> 'scripts/home.1a23b.js'
'styles/home.css' --> 'styles/home.aef45.css'
The problem is, now your Python web app can't find the file unless you manually –and painstakingly— update all the URLs in the templates.
.. code:: html+jinja
<script src="{{ url_for('static', filename='scripts/home.js') }}></script>
<link rel="stylesheet" href="{{ url_for('static', filename='styles/home.css') }}</script>
Whit this library, there is no need for that. Just change your templates to:
.. code:: html+jinja
<script src="{{ 'scripts/home.js' | asset_url }}></script>
<link rel="stylesheet" href="{{ 'styles/home.css' | asset_url }}</script>
and use this code:
.. code:: python
# app.py
from flask import Flask, render_template
from rev_assets import RevAssets
app = flask.Flask(__name__)
rev = RevAssets(reload=app.debug)
app.jinja_env.filters['asset_url'] = rev.asset_url
@app.route('/')
def index():
return render_template('index.html')
and it will work for every version of the assets that you build.
This works by reading the ``manifest.json`` generated by the revision tool (so don't forget to configure your task runner to make one).
You can continue to use the old method to link un-versioned assets, like ``favicon.ico`` and others like it.
Note that *this is not a Flask extension*, but a Python library. You can use it with any other framework. You can also have many instances of ``RevAssets`` linked to differents manifests.
Run the tests
======================
We use some external dependencies, listed in ``requirements_tests.txt``::
$ pip install -r requirements-tests.txt
$ python setup.py develop
To run the tests in your current Python version do::
$ make test
To run them in every supported Python version do::
$ tox
Our test suite `runs continuously on Travis CI <https://travis-ci.org/jpscaletti/rev-assets>`_ with every update.
Contributing
======================
#. Check for `open issues <https://github.com/jpscaletti/rev-assets/issues>`_ or open
a fresh issue to start a discussion around a feature idea or a bug.
#. Fork the `RevAssets repository on Github <https://github.com/jpscaletti/rev-assets>`_
to start making your changes.
#. Write a test which shows that the bug was fixed or that the feature works
as expected.
#. Send a pull request and bug the maintainer until it gets merged and published.
:) Make sure to add yourself to ``AUTHORS``.
______
:copyright: `Juan-Pablo Scaletti <http://jpscaletti.com/>`_.
:license: BSD-3-Clause, see LICENSE.
Metadata
Release files for rev-assets 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rev-assets-1.0.3.tar.gz | 5.0 kB | Without provenance | Details for rev-assets-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rev_assets-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for rev_assets-1.0.3-py3-none-any.whl |
Total release size: 10.8 kB
Release files / rev-assets-1.0.3.tar.gz
| Download URL | rev-assets-1.0.3.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57945e3d13968a704bb11d622703a001c5fd762dc4af2cb3cca293f5ffea801f
|
|
BLAKE2b-256 checksum How to use checksums |
45624ca6a3300f454865da840f3b01766d60b9dc38117c4d942755aebfd033ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / rev_assets-1.0.3-py3-none-any.whl
| Download URL | rev_assets-1.0.3-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d5e0f292d740973ca5d335118268ee4d79e97257123bf5d17ecede153d4669c
|
|
BLAKE2b-256 checksum How to use checksums |
cfff2bde4a6a7172b7411c727d9845732013fa54875bf6560daf6656584b4ae1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for rev-assets 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.