Skip to content

Hi! I cleaned up your code for you! #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
django-compress was originally created by Andreas Pelme <[email protected]> in
django-compress was originally created by Andreas Pelme <[email protected]> in
2008.

These people have provided bug fixes, new features, improved the documentation
These people have provided bug fixes, new features, improved the documentation
or just made django-compress more awesome.

* Alexander Artemenko <svetlyak40wt>
Expand All @@ -11,6 +11,6 @@ or just made django-compress more awesome.
* Remco Wendt <[email protected]>
* Patrick Altman <[email protected]>

The Python-version of jsmin (http://www.crockford.com/javascript/jsmin.html)
is included in django-compress. It was translated from to Python by Baruch
The Python-version of jsmin (http://www.crockford.com/javascript/jsmin.html)
is included in django-compress. It was translated from to Python by Baruch
Evan, from the original jsmin implementation by Douglas Crockford.
20 changes: 10 additions & 10 deletions README
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
django-compress provides an automated system for compressing CSS and
JavaScript files. By default, it only outputs compressed files while not in
DEBUG-mode. That means you can still debug and edit your source files while
coding, and when going to production, the compressed files will be
django-compress provides an automated system for compressing CSS and
JavaScript files. By default, it only outputs compressed files while not in
DEBUG-mode. That means you can still debug and edit your source files while
coding, and when going to production, the compressed files will be
automatically generated.

Support for jsmin and CSSTidy is included and enabled by default (but can
easily be disabled). Support for YUI Compressor is also supported out of the
Support for jsmin and CSSTidy is included and enabled by default (but can
easily be disabled). Support for YUI Compressor is also supported out of the
box.

django-compress includes template tags for outputting the URLs to the
CSS/JavaScript?-files and some other goodies to improve the performance of
django-compress includes template tags for outputting the URLs to the
CSS/JavaScript?-files and some other goodies to improve the performance of
serving static media.

django-compress is available at github[1] and Google Code[2]. You can always
django-compress is available at github[1] and Google Code[2]. You can always
access the latest and greatest code from both git and Subversion.

The documentation is available online at Github[3], or under docs/ in the
The documentation is available online at Github[3], or under docs/ in the
source.

[1] http://github.com/pelme/django-compress/tree/master
Expand Down
6 changes: 3 additions & 3 deletions docs/BackwardsIncompatibleChanges.textile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bump_filename was broken because a lot of caches does not properly cache files w
* The `bump_filename` option was removed from the group settings. There is no need specifying it for ALL groups, if you actually use it, you most likely want to use it on all your compressed files.
* The bump_filename options is replaced by the setting COMPRESS_VERSION, and is completely ignored.
* The querystring is no longer used to determine a files version, since it was use
* If COMPRESS_VERSION is used, you specify the version part of the `output_filename` file with '?'. This placeholder can be changed with COMPRESS_VERSION_PLACEHOLDER.
* If COMPRESS_VERSION is used, you specify the version part of the `output_filename` file with '?'. This placeholder can be changed with COMPRESS_VERSION_PLACEHOLDER.

E.g.:
<pre>
Expand All @@ -30,9 +30,9 @@ E.g.:
</code></pre>
</pre>

* COMPRESS_VERSION requires COMPRESS_AUTO to be enabled. COMPRESS_AUTO is enabled by default, but if you explicitly set it to `False` an ImproperlyConfiguredError exception will be thrown.
* COMPRESS_VERSION requires COMPRESS_AUTO to be enabled. COMPRESS_AUTO is enabled by default, but if you explicitly set it to `False` an ImproperlyConfiguredError exception will be thrown.

COMPRESS_AUTO changes

* The CSS/Javascript files are not checked during Django's initialization anymore. It was not really useful and did not make sense. The automatic part is now handled by the templatetags (i.e. what used to be COMPRESS_TEMPLATE_AUTO).
* COMPRESS_AUTO is replaced by COMPRESS_AUTO_TEMPLATE, and the old behavior of COMPRESS_AUTO is removed. This might be really confusing, the Configuration should make it clear.
* COMPRESS_AUTO is replaced by COMPRESS_AUTO_TEMPLATE, and the old behavior of COMPRESS_AUTO is removed. This might be really confusing, the Configuration should make it clear.
18 changes: 9 additions & 9 deletions docs/Configuration.textile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COMPRESS_CSS = {
'media': 'screen,projection',
},
},

# other CSS groups goes here
}

Expand Down Expand Up @@ -87,19 +87,19 @@ In this example, the template tags will render _http://cdn.example.com/css/one_c

h4. CSS URL Replace Filter

This is a really simple filter for doing Python string replacements on your CSS. The use case for this is when you have root relative
This is a really simple filter for doing Python string replacements on your CSS. The use case for this is when you have root relative
urls defined in your css:

<pre><code>
body {background-image:url(/media/images/background.gif);}
</code></pre>

If you are compiling your media to live on another server, for example if you are deploying the compiled resources to Amazon S3, these
root relative urls will break. That is of course unless you also deploy all the media so they stay relative. However, then you limit yourself
If you are compiling your media to live on another server, for example if you are deploying the compiled resources to Amazon S3, these
root relative urls will break. That is of course unless you also deploy all the media so they stay relative. However, then you limit yourself
from being able to prefix the source with a date or version number. Ideally, you should be able to control where the images are deployed
and those might be different from where your js/css media are being served from.

This filter offers a very simple solution. Really too simple. One could make the argument for just doing this search and replace manually
This filter offers a very simple solution. Really too simple. One could make the argument for just doing this search and replace manually
after the fact, however, I like for my build process to be as automated as possible. Therefore, I want to write down the rules/settings
once and be able to repeat the build process when needed without thinking about the find and replace.

Expand All @@ -113,7 +113,7 @@ Enough babbling, here is an example settings.py section:

This will run the CSSURLReplace filter after the CSS is compressed (it is safe to do this in any order, at least for this filter). The URL_REPLACE_HOST
is not required, just a variable I defined in my settings file to keep things clean (and to override in other environments -- this is obviously my dev
settings file).
settings file).

The COMPRESS_CSS_URL_REPLACE is the only required setting by this filter. It takes a list of tuples, each tuple being exactly two strings.

Expand Down Expand Up @@ -164,7 +164,7 @@ Output in when <tt>settings.COMPRESS = True</tt>
<script type="text/javascript" src="/media/js/all.js" charset="utf-8"></script>
</code></pre>

Now why is this good you ask? The more script sources the more impact on performence according to http://developer.yahoo.com/performance/rules.html#num_http
Now why is this good you ask? The more script sources the more impact on performence according to http://developer.yahoo.com/performance/rules.html#num_http
which is true but if you are low bandwidth or superbig you may want to offload
some horsepower to google which leads us as hinted in the example above to the next topic.

Expand All @@ -173,9 +173,9 @@ currently no reason to have external css files (Yes there are css frameworks asw

h4. Google AJAX Libraries API

So the reason for adding external urls support to django-compress is google ajax libraries api support (example above) but you may want to use it however you want.
So the reason for adding external urls support to django-compress is google ajax libraries api support (example above) but you may want to use it however you want.

The advantages for offloading huge javascript libraries to google cdn is of course that your site will need a lot less bandwidth, even if you use far futures expires headers. But the superior reason is of course that the more sites that uses it, the bigger the chance is that your favorite js framework is already cached in your visitors browser.
The advantages for offloading huge javascript libraries to google cdn is of course that your site will need a lot less bandwidth, even if you use far futures expires headers. But the superior reason is of course that the more sites that uses it, the bigger the chance is that your favorite js framework is already cached in your visitors browser.

Google also uses far future expires headers so don't worry about that. Don't worry about latency outside the US either. Here in sweden I measuerd a latencey of 39ms.

Expand Down
4 changes: 2 additions & 2 deletions docs/FarFutureExpires.textile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Most modern browser implement "Heuristic expiration", so it will actually not be

This technique obviously has a drawback, when you want to change your files, you need to change their names, since their URLs will be cached... that's right: forever! The solution to that is pretty obvious too: change the URLs.

h3. django-compress with COMPRESS_VERSION
h3. django-compress with COMPRESS_VERSION

If you specify <tt>COMPRESS_VERSION</tt> in your configuration, you can add a placeholder to the filenames to output the version number of the different files. See [Configuration]) for more information. The filename itself will be changed when any of the source files are updated.

Expand Down Expand Up @@ -66,7 +66,7 @@ h4. nginx
nginx's <tt>ngx_http_headers_module</tt> provides the <tt>expires</tt> option, which control the <tt>Expires</tt> and <tt>Cache-Control</tt> HTTP headers.
* [http://wiki.codemongers.com/NginxHttpHeadersModule ngx_http_headers_module in nginx documentation]

h4. Example
h4. Example

This will set expiration to the maximum expiration:
<pre><code>
Expand Down
6 changes: 3 additions & 3 deletions docs/Installation.textile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ h3. Install instructions

# Get the code from svn: svn co http://django-compress.googlecode.com/svn/trunk/ django-compress
** Use the setup.py script to install: python setup.py install
** OR manually put the compress-directory somewhere on your PYTHONPATH
# Add 'compress' to your INSTALLED_APPS
** OR manually put the compress-directory somewhere on your PYTHONPATH
# Add 'compress' to your INSTALLED_APPS

h3. Using git?

The main source repository is now available at github: http://github.com/pelme/django-compress/tree/master

The Subversion repository at Google Code will still be updated, though.

If you want to grab django-compress via git, use: git clone git://github.com/pelme/django-compress.git
If you want to grab django-compress via git, use: git clone git://github.com/pelme/django-compress.git
4 changes: 2 additions & 2 deletions docs/Usage.textile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
h1. Usage

_Describes how to use django-compress when it is installed and configured_
_Describes how to use django-compress when it is installed and configured_

h3. Automated generation

Expand Down Expand Up @@ -38,4 +38,4 @@ If you have specified the CSS-groups “my_screen_css” and “my_print_css”

h3. Far future Expires

Far future Expires can be used with the bump_filename-option, see the FarFutureExpires page for more information.
Far future Expires can be used with the bump_filename-option, see the FarFutureExpires page for more information.
2 changes: 1 addition & 1 deletion docs/Versioning.textile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ from compress.versioning.hash import SHA1Versioning

class ShortSHA1Versioning(SHA1Versioning):
"""Custom SHA1Versioning class"""

def get_version(self, source_files):
"""Return the first 10 characters of the SHA-1 version string"""
version = super(ShortSHA1Versioning, self).get_version(source_files)
Expand Down