Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
django_bundles is a media bundler for Django. It can be used to bundle groups of media files (e.g. CSS, JavaScript) into a single file with a hash in the filename (to play nicely with browser caching) whilst keeping the files separate during development.
There are ideas taken from a lot of the other media bundlers - none of them worked quite how I wanted and I fancied writing my own.
I think Django 1.4 is required, but possibly only because of the assignment tag decorator used.
IMPORTANT NOTE: 0.3.0 is not backwards compatible with 0.2.5
The main settings are USE_BUNDLES
which is True/False to enable/disable bundling in the template (defaults to not settings.DEBUG
), BUNDLES_VERSION_FILE
which is where versions are stored (in a python file) and BUNDLES
which looks like:
BUNDLES = (
('master_css', {
'type': 'css',
'files': (
'css/*.css',
'css/more/test3.css',
'less/test.less',
),
}),
('master_js', {
'type': 'js',
'files': (
'js/*.js',
)
}),
('script_loader_example', {
'type': 'js',
'files': (
'script_loader_example.js',
),
'processors': (
'django_bundles.processors.django_template.DjangoTemplateProcessor',
)
}),
)
All of the BUNDLES
options can be found in django_bundles/core.py on the Bundle
and BundleFile
classes.
The {% render_bundle bundle_name %}
template tag can then be used to render the HTML (e.g. script or link tag) in place. django_bundles/templates needs to be in your template directories list (or copy them in).
Other settings are (check out django_bundles/conf/default_settings.py):
DEFAULT_PREPROCESSORS
- dict of file type to list of processors (default is LessCSS for .less files)DEFAULT_POSTPROCESSORS
- dict of bundle type to list of processors (default is UglifyJS for .js bundles)If you define a BUNDLES_LINTING
setting you can use the lint_bundles
management command to lint your files. e.g.
BUNDLES_LINTING = {
'js': {
'command': '/path/to/jslint/bin/jslint.js {infile}',
'default': True,
},
}
It currently expects output like JSLint.
{% if not settings.USE_BUNDLES %}
so you don't use it in production)I think it should be pretty simple to use this with staticfiles with clever use of files_url_root
, files_root
, bundle_url_root
and bundle_file_root
as long as collectstatic
management command is run before create_bundles
in the deployment process.
FAQs
Another Django media bundler
We found that django-bundles demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.