Django Middlware to detect Dartium web browser.
Project description
django-dartium provides for a simple way to detect the Dartium web browser and make it easy to serve Dart sources instead of compiled JavaScript during development.
Installation
Python 3 and Django are the only requirements:
Install django-dartium with your favorite python tool, e.g. pip install django-dartium.
Add django_dartium to your INSTALLED_APPS setting.
Add django_dartium.middleware.DartiumDetectionMiddleware to your MIDDLEWARE_CLASSES setting.
Add two named mappings to STATICFILES_DIRS, one named dart/build which points to the build location of the JavaScript output and the other is dart/src which points to the web directory containing your original Dart source. If you created your Django project by running django-admin startproject your_project and placed your Dart sources in your_project/your_project/dart directory, then you would have the following STATICFILES_DIRS:
STATICFILES_DIRS = [ ('dart/build', 'your_project/dart/build/web'), ('dart/src', 'your_project/dart/web'), ]
Usage
Load the dartium tag library into your Django template, call the webcomponents tag to load the necessary polyfills and then add a reference to your Dart code via the dart tag.
A good setup would be to have the following in your base.html:
{% load dartium %}
<html>
...
<body>
{% block content %}
{% endblock %}
{% webcomponents 'lite' %}
{% block script %}
{% endblock %}
</body>
</html>
Then in each of your pages where you want to use Dart some Dart script you can add:
{% load dartium %}
{% block content %}
... page content ...
{% endblock %}
{% block script %}
{% dart "your_script.dart" %}
{% endblock %}
The end result will be that if you browse to this page with Dartium you will get served your original Dart source but if you are using any other browser you’ll be served your_script.dart.js from the build/web directory.
0.1.3 - 2017-01-31
New style middlware to work with Django 2.0
0.1.0
Initial release.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-dartium-0.1.3.tar.gz
.
File metadata
- Download URL: django-dartium-0.1.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c33ebc7b21dc70054dfc7947a6285c902dfacf8dbd60a17f8420909469a6792 |
|
MD5 | 2a1aa871459f557acbd4134646e3f0bf |
|
BLAKE2b-256 | ac1c57b96206afdac25d596d65a1a6b90bc5225ade052b66f25238456c35303e |
File details
Details for the file django_dartium-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: django_dartium-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a42e284924fcd4833fa3eae71431126de74341176f7f902c8d36a383d98f766 |
|
MD5 | 0b8797b92bb92928f50389a051daa161 |
|
BLAKE2b-256 | 27fd83137ce267d0c4cea98a90e8f1389f5b3a899d1bf31e27631a039dd7a34e |