djed.static¶
djed.static integrates BowerStatic into the Pyramid Web Framework. BowerStatic is a WSGI component that can serve static resources from front-end packages (JavaScript, CSS) that you install through the Bower package manager.
Contents¶
Getting Started¶
Install the package into your python environment:
pip install djed.static
Include it in your Pyramid application:
config.include('djed.static')
Initialize a bower_components directory:
config.init_bower_components('myapp:static/bower_components')
Include desired Bower packages on your page. You can do this in templates or somewhere else in your code:
request.include('bootstrap')
All required dependencies are also included on the page.
Local Components¶
If you develop your own front-end-code (so called “local components”), you can add them as follows:
config.add_bower_component('myapp:static/my_component', version='1.0.0')
You can retrieve the version of your Pyramid application like this:
import pkg_resources
version = pkg_resources.get_distribution('myproject').version
You can include local components on page like any other component:
request.include('my_component')
This includes your front-end-code on the page and all dependencies that are defined in the bower.json file.
Configuration¶
You can configure djed.static via your ini-file:
[app:myapp]
djed.static.components_name = lib
...
To understand the ini-setting options, let’s take a look at the URL structure that is generated by BowerStatic:
/bowerstatic/components/jquery/2.1.1/dist/jquery.js
Or for local components:
/bowerstatic/local/mycomponent/1.0.0/mycomponent.js
The setting options allow you to change the first two parts of the URLs:
- djed.static.publisher_signature
The first part of the components and local URLs.
default: bowerstatic
- djed.static.components_name
The second part of the components URLs.
default: components
- djed.static.local_components_name
The second part of the local URLs.
default: local
Support and Development¶
If you’ve got questions, contact the djedproject mailling list.
To report bugs, use the issue tracker.
Check out trunk version via the Github repository:
git clone git@github.com:djedproject/djed.static.git