[Python-modules-commits] [django-webpack-loader] 01/06: Import django-webpack-loader_0.3.3.orig.tar.gz

Michael Fladischer fladi at moszumanska.debian.org
Tue Jul 26 06:42:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository django-webpack-loader.

commit 947c41b82283500d4a31d7e63c22dcb0210b3c89
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Tue Jul 26 08:27:26 2016 +0200

    Import django-webpack-loader_0.3.3.orig.tar.gz
---
 MANIFEST.in                                   |  2 ++
 PKG-INFO                                      | 32 ++++++++++++++++++++++-----
 README.md                                     | 28 ++++++++++++++++++++---
 django_webpack_loader.egg-info/PKG-INFO       | 32 ++++++++++++++++++++++-----
 django_webpack_loader.egg-info/SOURCES.txt    |  1 +
 setup.py                                      |  1 -
 webpack_loader/__init__.py                    |  2 +-
 webpack_loader/config.py                      |  1 +
 webpack_loader/exceptions.py                  |  4 ++++
 webpack_loader/loader.py                      | 23 +++++++++++++++----
 webpack_loader/templatetags/webpack_loader.py | 14 ++++++------
 11 files changed, 114 insertions(+), 26 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..c1a7121
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,2 @@
+include LICENSE
+include README.md
diff --git a/PKG-INFO b/PKG-INFO
index 3074e60..80a0c18 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: django-webpack-loader
-Version: 0.3.0
+Version: 0.3.3
 Summary: Transparently use webpack with django
 Home-page: https://github.com/owais/django-webpack-loader
 Author: Owais Lone
 Author-email: hello at owaislone.org
 License: UNKNOWN
-Download-URL: https://github.com/owais/django-webpack-loader/tarball/0.3.0
+Download-URL: https://github.com/owais/django-webpack-loader/tarball/0.3.3
 Description: # django-webpack-loader
         
         [![Join the chat at https://gitter.im/owais/django-webpack-loader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/owais/django-webpack-loader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -89,9 +89,10 @@ Description: # django-webpack-loader
         WEBPACK_LOADER = {
             'DEFAULT': {
                 'CACHE': not DEBUG,
-                'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
-                'STATS_FILE': 'webpack-stats.json',
+                'BUNDLE_DIR_NAME': 'bundles/', # must end with slash
+                'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
                 'POLL_INTERVAL': 0.1,
+                'TIMEOUT': None,
                 'IGNORE': ['.+\.hot-update.js', '.+\.map']
             }
         }
@@ -156,12 +157,18 @@ Description: # django-webpack-loader
         
         #### POLL_INTERVAL
         
-        `POLL_INTERVAL` is the number of seconds webpack_loader should wait between polling the stats file. The stats file is polled every 200 miliseconds by default and any requests to are blocked while webpack compiles the bundles. You can reduce this if your bundles take shorter to compile.
+        `POLL_INTERVAL` is the number of seconds webpack_loader should wait between polling the stats file. The stats file is polled every 100 miliseconds by default and any requests to are blocked while webpack compiles the bundles. You can reduce this if your bundles take shorter to compile.
         
         **NOTE:** Stats file is not polled when in production (DEBUG=False).
         
         <br>
         
+        #### TIMEOUT
+        
+        `TIMEOUT` is the number of seconds webpack_loader should wait for webpack to finish compiling before raising an exception. `0`, `None` or leaving the value out of settings disables timeouts. 
+        
+        <br>
+        
         
         ## Usage
         <br>
@@ -244,6 +251,9 @@ Description: # django-webpack-loader
             {% render_bundle 'main' 'css' 'DASHBOARD' %}
             {% render_bundle 'main' extension='css' config='DASHBOARD' %}
             {% render_bundle 'main' config='DASHBOARD' extension='css' %}
+        
+            <!-- add some extra attributes to the tag -->
+            {% render_bundle 'main' 'js' 'DEFAULT' attrs='async chatset="UTF-8"'%}
           </body>
         </head>
         ```
@@ -269,6 +279,18 @@ Description: # django-webpack-loader
         </ul>
         ```
         
+        #### Refer other static assets
+        
+        `webpack_static` template tag provides facilities to load static assets managed by webpack
+        in django templates. It is like django's built in `static` tag but for webpack assets instead.
+        In the below example, `logo.png` can be any static asset shipped with any npm or bower package.
+        
+        ```HTML+Django
+        {% load webpack_static from webpack_loader %}
+        
+        <!-- render full public path of logo.png -->
+        <img src="{% webpack_static 'logo.png' %}"/>
+        ```
         
         <br>
         
diff --git a/README.md b/README.md
index bdb93e2..4f2c1cf 100644
--- a/README.md
+++ b/README.md
@@ -80,9 +80,10 @@ module.exports = {
 WEBPACK_LOADER = {
     'DEFAULT': {
         'CACHE': not DEBUG,
-        'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
-        'STATS_FILE': 'webpack-stats.json',
+        'BUNDLE_DIR_NAME': 'bundles/', # must end with slash
+        'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
         'POLL_INTERVAL': 0.1,
+        'TIMEOUT': None,
         'IGNORE': ['.+\.hot-update.js', '.+\.map']
     }
 }
@@ -147,12 +148,18 @@ and your webpack config is located at `/home/src/webpack.config.js`, then the va
 
 #### POLL_INTERVAL
 
-`POLL_INTERVAL` is the number of seconds webpack_loader should wait between polling the stats file. The stats file is polled every 200 miliseconds by default and any requests to are blocked while webpack compiles the bundles. You can reduce this if your bundles take shorter to compile.
+`POLL_INTERVAL` is the number of seconds webpack_loader should wait between polling the stats file. The stats file is polled every 100 miliseconds by default and any requests to are blocked while webpack compiles the bundles. You can reduce this if your bundles take shorter to compile.
 
 **NOTE:** Stats file is not polled when in production (DEBUG=False).
 
 <br>
 
+#### TIMEOUT
+
+`TIMEOUT` is the number of seconds webpack_loader should wait for webpack to finish compiling before raising an exception. `0`, `None` or leaving the value out of settings disables timeouts. 
+
+<br>
+
 
 ## Usage
 <br>
@@ -235,6 +242,9 @@ WEBPACK_LOADER = {
     {% render_bundle 'main' 'css' 'DASHBOARD' %}
     {% render_bundle 'main' extension='css' config='DASHBOARD' %}
     {% render_bundle 'main' config='DASHBOARD' extension='css' %}
+
+    <!-- add some extra attributes to the tag -->
+    {% render_bundle 'main' 'js' 'DEFAULT' attrs='async chatset="UTF-8"'%}
   </body>
 </head>
 ```
@@ -260,6 +270,18 @@ CKEDITOR.config.contentsCss = '{{ editor_css_files.0.publicPath }}';
 </ul>
 ```
 
+#### Refer other static assets
+
+`webpack_static` template tag provides facilities to load static assets managed by webpack
+in django templates. It is like django's built in `static` tag but for webpack assets instead.
+In the below example, `logo.png` can be any static asset shipped with any npm or bower package.
+
+```HTML+Django
+{% load webpack_static from webpack_loader %}
+
+<!-- render full public path of logo.png -->
+<img src="{% webpack_static 'logo.png' %}"/>
+```
 
 <br>
 
diff --git a/django_webpack_loader.egg-info/PKG-INFO b/django_webpack_loader.egg-info/PKG-INFO
index 3074e60..80a0c18 100644
--- a/django_webpack_loader.egg-info/PKG-INFO
+++ b/django_webpack_loader.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: django-webpack-loader
-Version: 0.3.0
+Version: 0.3.3
 Summary: Transparently use webpack with django
 Home-page: https://github.com/owais/django-webpack-loader
 Author: Owais Lone
 Author-email: hello at owaislone.org
 License: UNKNOWN
-Download-URL: https://github.com/owais/django-webpack-loader/tarball/0.3.0
+Download-URL: https://github.com/owais/django-webpack-loader/tarball/0.3.3
 Description: # django-webpack-loader
         
         [![Join the chat at https://gitter.im/owais/django-webpack-loader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/owais/django-webpack-loader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -89,9 +89,10 @@ Description: # django-webpack-loader
         WEBPACK_LOADER = {
             'DEFAULT': {
                 'CACHE': not DEBUG,
-                'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
-                'STATS_FILE': 'webpack-stats.json',
+                'BUNDLE_DIR_NAME': 'bundles/', # must end with slash
+                'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
                 'POLL_INTERVAL': 0.1,
+                'TIMEOUT': None,
                 'IGNORE': ['.+\.hot-update.js', '.+\.map']
             }
         }
@@ -156,12 +157,18 @@ Description: # django-webpack-loader
         
         #### POLL_INTERVAL
         
-        `POLL_INTERVAL` is the number of seconds webpack_loader should wait between polling the stats file. The stats file is polled every 200 miliseconds by default and any requests to are blocked while webpack compiles the bundles. You can reduce this if your bundles take shorter to compile.
+        `POLL_INTERVAL` is the number of seconds webpack_loader should wait between polling the stats file. The stats file is polled every 100 miliseconds by default and any requests to are blocked while webpack compiles the bundles. You can reduce this if your bundles take shorter to compile.
         
         **NOTE:** Stats file is not polled when in production (DEBUG=False).
         
         <br>
         
+        #### TIMEOUT
+        
+        `TIMEOUT` is the number of seconds webpack_loader should wait for webpack to finish compiling before raising an exception. `0`, `None` or leaving the value out of settings disables timeouts. 
+        
+        <br>
+        
         
         ## Usage
         <br>
@@ -244,6 +251,9 @@ Description: # django-webpack-loader
             {% render_bundle 'main' 'css' 'DASHBOARD' %}
             {% render_bundle 'main' extension='css' config='DASHBOARD' %}
             {% render_bundle 'main' config='DASHBOARD' extension='css' %}
+        
+            <!-- add some extra attributes to the tag -->
+            {% render_bundle 'main' 'js' 'DEFAULT' attrs='async chatset="UTF-8"'%}
           </body>
         </head>
         ```
@@ -269,6 +279,18 @@ Description: # django-webpack-loader
         </ul>
         ```
         
+        #### Refer other static assets
+        
+        `webpack_static` template tag provides facilities to load static assets managed by webpack
+        in django templates. It is like django's built in `static` tag but for webpack assets instead.
+        In the below example, `logo.png` can be any static asset shipped with any npm or bower package.
+        
+        ```HTML+Django
+        {% load webpack_static from webpack_loader %}
+        
+        <!-- render full public path of logo.png -->
+        <img src="{% webpack_static 'logo.png' %}"/>
+        ```
         
         <br>
         
diff --git a/django_webpack_loader.egg-info/SOURCES.txt b/django_webpack_loader.egg-info/SOURCES.txt
index 8656200..50b3c9f 100644
--- a/django_webpack_loader.egg-info/SOURCES.txt
+++ b/django_webpack_loader.egg-info/SOURCES.txt
@@ -1,4 +1,5 @@
 LICENSE
+MANIFEST.in
 README.md
 setup.cfg
 setup.py
diff --git a/setup.py b/setup.py
index c1652e7..035a568 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,6 @@ setup(
   download_url = 'https://github.com/owais/django-webpack-loader/tarball/{0}'.format(VERSION),
   url = 'https://github.com/owais/django-webpack-loader', # use the URL to the github repo
   keywords = ['django', 'webpack', 'assets'], # arbitrary keywords
-  data_files = [("", ["LICENSE"])],
   classifiers = [
     'Programming Language :: Python :: 2.6',
     'Programming Language :: Python :: 2.7',
diff --git a/webpack_loader/__init__.py b/webpack_loader/__init__.py
index a952178..12b6a3c 100644
--- a/webpack_loader/__init__.py
+++ b/webpack_loader/__init__.py
@@ -1,4 +1,4 @@
 __author__ = 'Owais Lone'
-__version__ = '0.3.0'
+__version__ = '0.3.3'
 
 default_app_config = 'webpack_loader.apps.WebpackLoaderConfig'
diff --git a/webpack_loader/config.py b/webpack_loader/config.py
index 3bb26ca..39ff2b1 100644
--- a/webpack_loader/config.py
+++ b/webpack_loader/config.py
@@ -13,6 +13,7 @@ DEFAULT_CONFIG = {
         'STATS_FILE': 'webpack-stats.json',
         # FIXME: Explore usage of fsnotify
         'POLL_INTERVAL': 0.1,
+        'TIMEOUT': None,
         'IGNORE': ['.+\.hot-update.js', '.+\.map']
     }
 }
diff --git a/webpack_loader/exceptions.py b/webpack_loader/exceptions.py
index c7a5165..307b088 100644
--- a/webpack_loader/exceptions.py
+++ b/webpack_loader/exceptions.py
@@ -7,3 +7,7 @@ class WebpackError(Exception):
 
 class WebpackLoaderBadStatsError(Exception):
     pass
+
+
+class WebpackLoaderTimeoutError(Exception):
+    pass
diff --git a/webpack_loader/loader.py b/webpack_loader/loader.py
index 869613e..4fd106f 100644
--- a/webpack_loader/loader.py
+++ b/webpack_loader/loader.py
@@ -4,7 +4,11 @@ import time
 from django.conf import settings
 from django.contrib.staticfiles.storage import staticfiles_storage
 
-from .exceptions import WebpackError, WebpackLoaderBadStatsError
+from .exceptions import (
+    WebpackError,
+    WebpackLoaderBadStatsError,
+    WebpackLoaderTimeoutError
+)
 from .config import load_config
 
 
@@ -53,13 +57,24 @@ class WebpackLoader(object):
     def get_bundle(self, bundle_name):
         assets = self.get_assets()
 
+        # poll when debugging and block request until bundle is compiled
+        # or the build times out
         if settings.DEBUG:
-            # poll when debugging and block request until bundle is compiled
-            # TODO: support timeouts
-            while assets['status'] == 'compiling':
+            timeout = self.config['TIMEOUT'] or 0
+            timed_out = False
+            start = time.time()
+            while assets['status'] == 'compiling' and not timed_out:
                 time.sleep(self.config['POLL_INTERVAL'])
+                if timeout and (time.time() - timeout > start):
+                    timed_out = True
                 assets = self.get_assets()
 
+            if timed_out:
+                raise WebpackLoaderTimeoutError(
+                    "Timed Out. Bundle `{0}` took more than {1} seconds "
+                    "to compile.".format(bundle_name, timeout)
+                )
+
         if assets.get('status') == 'done':
             chunks = assets['chunks'][bundle_name]
             return self.filter_chunks(chunks)
diff --git a/webpack_loader/templatetags/webpack_loader.py b/webpack_loader/templatetags/webpack_loader.py
index a964dc0..f83ae4a 100644
--- a/webpack_loader/templatetags/webpack_loader.py
+++ b/webpack_loader/templatetags/webpack_loader.py
@@ -14,17 +14,17 @@ def filter_by_extension(bundle, extension):
             yield chunk
 
 
-def render_as_tags(bundle):
+def render_as_tags(bundle, attrs):
     tags = []
     for chunk in bundle:
         if chunk['name'].endswith('.js'):
             tags.append((
-                '<script type="text/javascript" src="{0}"></script>'
-            ).format(chunk['url']))
+                '<script type="text/javascript" src="{0}" {1}></script>'
+            ).format(chunk['url'], attrs))
         elif chunk['name'].endswith('.css'):
             tags.append((
-                '<link type="text/css" href="{0}" rel="stylesheet"/>'
-            ).format(chunk['url']))
+                '<link type="text/css" href="{0}" rel="stylesheet" {1}/>'
+            ).format(chunk['url'], attrs))
     return mark_safe('\n'.join(tags))
 
 
@@ -36,8 +36,8 @@ def _get_bundle(bundle_name, extension, config):
 
 
 @register.simple_tag
-def render_bundle(bundle_name, extension=None, config='DEFAULT'):
-    return render_as_tags(_get_bundle(bundle_name, extension, config))
+def render_bundle(bundle_name, extension=None, config='DEFAULT', attrs=''):
+    return render_as_tags(_get_bundle(bundle_name, extension, config), attrs)
 
 
 @register.simple_tag

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-webpack-loader.git



More information about the Python-modules-commits mailing list