Skip to content

Commit

Permalink
Merge branch 'release/v0.12' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
miracle2k committed Aug 18, 2016
2 parents aff3edb + 6e99ec0 commit ae94534
Show file tree
Hide file tree
Showing 33 changed files with 1,059 additions and 315 deletions.
24 changes: 10 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
sudo: required
dist: trusty
language: python
python:
- 2.6
install:
node_js:
- "4.3.2"
install:
- sudo apt-get -qq update

# Supposed to help get PIL to install on PyPi
# https://github.com/python-imaging/Pillow/issues/570
- sudo apt-get install python-tk

# To install external filter binaries, we first need to install
# RubyGems and Node/NPM. I'm not sure why, since it seems clear
# that NVM and RVM are pre-installed (see below).
- sudo apt-get install python-software-properties
- sudo apt-add-repository -y ppa:chris-lea/node.js
- sudo apt-get update
- sudo apt-get install nodejs rubygems

# These are useful for debugging this mess.
#- env
#- gem env
#- rvm info

# Use non-http registry? https://github.com/n1k0/casperjs/issues/876
# Without this, installing doesn't work.
- sudo npm config set registry http://registry.npmjs.org/
- npm install -g postcss-cli autoprefixer

# Now install the external filter binaries, finally.
# Now install the external filter binaries, finally.
# If we use sudo for this, ruby gems will not work: it seems they are
# then installed globally, but are then searched for in a RVM location.
# (Clearing GEM_HOME might be a way to fix this, if sudo where necessary).
Expand Down
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.12 (2016-08-18)
- Babel filter (JDeuce).
- NodeSASS filter (Luke Benstead).
- Autoprefixer 6 filter (Eugeniy Kuznetsov).
- Many other small changes and improvements by various contributors.

0.11.1 (2015-08-26)
- Fix compass filter bug (Pablo Aguiar).

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Asset management application for Python web development - use it to
merge and compress your JavaScript and CSS files.

Documentation: |travis|
http://webassets.readthedocs.org/
https://webassets.readthedocs.io/

Since releases aren't exactly happening on a regular schedule, you are
encouraged to use the latest code. ``webassets`` is pretty well tested,
Expand Down
29 changes: 29 additions & 0 deletions docs/builtin_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ external tools.

You can also write :doc:`custom filters <custom_filters>`.

Javascript cross-compilers
--------------------------

.. autoclass:: webassets.filter.babel.Babel


Javascript compressors
----------------------
Expand Down Expand Up @@ -143,6 +148,24 @@ JS/CSS compilers
.. autoclass:: webassets.filter.pyscss.PyScss


``libsass``
~~~~~~~~~~~

.. autoclass:: webassets.filter.libsass.LibSass


``node-sass``
~~~~~~~~~~~~~

.. autoclass:: webassets.filter.node_sass.NodeSass


``node-scss``
~~~~~~~~~~~~~

.. autoclass:: webassets.filter.node_sass.NodeSCSS


``stylus``
~~~~~~~~~~

Expand All @@ -155,6 +178,12 @@ JS/CSS compilers
.. autoclass:: webassets.filter.coffeescript.CoffeeScript


``typescript``
~~~~~~~~~~~~~~

.. autoclass:: webassets.filter.typescript.TypeScript


``requirejs``
~~~~~~~~~~~~~

Expand Down
19 changes: 15 additions & 4 deletions docs/custom_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ transformation depends on the source file's filename. For example,
the :ref:`cssrewrite <filters-cssrewrite>` filter needs to know the
location of the source file relative to the final output file, so it
can properly update relative references. Another example
are CSS converters like :ref:`less <filters-less>`, which support
include mechanisms that work relative to the input filename.
are CSS converters like :ref:`less <filters-less>`, which
work relative to the input filename.
With that in mind...
The very easy way
-----------------
In the simplest case, a filter is simply a function what takes two
In the simplest case, a filter is simply a function that takes two
arguments, an input stream and an output stream.
.. code-block:: python
Expand Down Expand Up @@ -112,7 +112,7 @@ Class-based filters have a ``name`` attribute, which you need to set if you
want to register your filter globally.
The ``input`` method will be called for every source file, the ``output``
method will be applied once after a bundle's contents have been concated.
method will be applied once after a bundle's contents have been concatenated.
Among the ``kwargs`` you currently receive are:
Expand All @@ -139,6 +139,17 @@ the filter. First, you need to register the class with the system though:
from webassets.filter import register_filter
register_filter(NoopFilter)
Or if you are using yaml then use the filters key for the environment:
.. code-block:: yaml
directory: .
url: /
debug: True
updater: timestamp
filters:
- my_custom_package.my_filter
After that, you can use the filter like you would any of the built-in ones:
.. code-block:: django
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ For URL expiry functionality, you need to use a manifest that holds version
information. See :doc:`/expiring`.

There is a barebone Google App Engine example in the
`examples/appengine/ <https://github.com/miracle2k/webassets/blob/master/tests/>`_
`examples/appengine/ <https://github.com/miracle2k/webassets/blob/master/examples/appengine/>`_
folder.
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ the respective page:
.. toctree::
:maxdepth: 1

With Django <http://django-assets.readthedocs.org/en/latest/>
With Flask <http://flask-assets.readthedocs.org/en/latest/>
With Django <https://django-assets.readthedocs.io/en/latest/>
With Flask <https://flask-assets.readthedocs.io/en/latest/>
With Pyramid <https://github.com/sontek/pyramid_webassets>
Other or no framework <generic/index>

Expand Down
4 changes: 2 additions & 2 deletions docs/script.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Command Line Interface
======================

While it's often convienient to have webassets automatically rebuild
While it's often convenient to have webassets automatically rebuild
your bundles on access, you sometimes may prefer to build manually,
for example for performance reasons in larger deployments.

Expand All @@ -19,7 +19,7 @@ within your framework. If that is not the case, read on.
Build a custom command line client
----------------------------------

In most cases, you can simple wrap around the ``webassets.script.main``
In most cases, you can simply wrap around the ``webassets.script.main``
function. For example, the command provided by Flask-Assets looks like
this:

Expand Down
4 changes: 1 addition & 3 deletions requirements-dev-2.x.pip
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ clevercss
pyScss==1.1.5
slimmer
cssmin

# Default rsmin package is not installable via pip
http://michael.elsdoerfer.name/rjsmin/rjsmin-1.0.1-webassets.tar.gz
rjsmin>=1.0.12
1 change: 1 addition & 0 deletions requirements-dev.pip
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ closure
slimit==0.8.1
ply==3.4 # https://github.com/rspivak/slimit/issues/76
libsass==0.8.3
zope.dottedname

# Python libs that requiring manual installation
#cssprefixer
4 changes: 4 additions & 0 deletions requirements-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ npm install -g stylus
npm install -g handlebars
npm install -g typescript
npm install -g [email protected]
npm install -g babel-cli
# Don't install the babel-preset globally because
# there's a bug with older verisons of node
npm install babel-preset-es2015 --save
2 changes: 1 addition & 1 deletion src/webassets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = (0, 11, 1)
__version__ = (0, 12, 0)


# Make a couple frequently used things available right here.
Expand Down
9 changes: 7 additions & 2 deletions src/webassets/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ class FilesystemCache(BaseCache):

V = 2 # We have changed the cache format once

def __init__(self, directory):
def __init__(self, directory, new_file_mode=None):
self.directory = directory
self.new_file_mode = new_file_mode

def __eq__(self, other):
"""Return equality with the config values
Expand Down Expand Up @@ -205,6 +206,10 @@ def set(self, key, data):
with os.fdopen(fd, 'wb') as f:
pickle.dump(data, f)
f.flush()
# If a non default mode is specified, then chmod the file to
# it before renaming it into place
if self.new_file_mode is not None:
os.chmod(temp_filename, self.new_file_mode)
if os.path.isfile(filename):
os.unlink(filename)
os.rename(temp_filename, filename)
Expand All @@ -231,4 +236,4 @@ def get_cache(option, ctx):
os.makedirs(directory)
else:
directory = option
return FilesystemCache(directory)
return FilesystemCache(directory, ctx.cache_file_mode)
21 changes: 20 additions & 1 deletion src/webassets/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ def add(self, *bundles):
# filter setting might be CSSMIN_BIN.
env_options = [
'directory', 'url', 'debug', 'cache', 'updater', 'auto_build',
'url_expire', 'versions', 'manifest', 'load_path', 'url_mapping']
'url_expire', 'versions', 'manifest', 'load_path', 'url_mapping',
'cache_file_mode' ]


class ConfigurationContext(object):
Expand Down Expand Up @@ -432,6 +433,23 @@ def _get_debug(self):
Merge the source files, but do not apply filters.
""")

def _set_cache_file_mode(self, mode):
self._storage['cache_file_mode'] = mode
def _get_cache_file_mode(self):
return self._storage['cache_file_mode']
cache_file_mode = property(_get_cache_file_mode, _set_cache_file_mode, doc=
"""Controls the mode of files created in the cache. The default mode
is 0600. Follows standard unix mode.
Possible values are any unix mode, e.g.:
``0660``
Enable the group read+write bits
``0666``
Enable world read+write bits
""")

def _set_cache(self, enable):
self._storage['cache'] = enable
def _get_cache(self):
Expand Down Expand Up @@ -708,6 +726,7 @@ def __init__(self, **config):
self.config.setdefault('load_path', [])
self.config.setdefault('url_mapping', {})
self.config.setdefault('resolver', self.resolver_class())
self.config.setdefault('cache_file_mode', None)

self.config.update(config)

Expand Down
Loading

0 comments on commit ae94534

Please sign in to comment.