mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-21 05:45:13 +00:00
41 lines
No EOL
2 KiB
Text
41 lines
No EOL
2 KiB
Text
h1. Usage
|
|
|
|
_Describes how to use django-compress when it is installed and configured_
|
|
|
|
h3. Automated generation
|
|
|
|
If <tt>COMPRESS</tt> and <tt>COMPRESS_AUTO</tt> is enabled (<tt>True</tt>), the source files will be automatically updated, and re-generated IF NEEDED when invoked from the templatetags. The last modified time of the files will be compared, and if any of the source-files is newer than the output-file, the file will be re-generated.
|
|
|
|
h3. Management command
|
|
|
|
You can update and force updates of the compressed file(s) with the management command “synccompress”. This makes it possible to keep the files updated manually.
|
|
|
|
The command is
|
|
<pre><code>
|
|
./manage.py synccompress
|
|
</code></pre>
|
|
|
|
(assuming you are in you project-folder that contains <tt>manage.py</tt>). To force all files to be re-generated, use the argument <tt>--force</tt> (e.g. <tt>./manage.py synccompress --force</tt>)
|
|
|
|
h3. Templatetags
|
|
|
|
django-compress includes two template tags: <tt>compressed_css</tt> and <tt>compressed_js</tt>, in a template library called <tt>compressed</tt>
|
|
|
|
They are used to output the <link> and <script>-tags for the specified CSS/JavaScript-groups (as specified in the settings). The first argument must be the name of the CSS/JavaScript group.
|
|
|
|
The templatetags will either output the source filenames or the compressed filenames, depending on the <tt>COMPRESS</tt> setting, if you do not specify the <tt>COMPRESS</tt> setting, the source files will be used in DEBUG-mode, and compressed files in non-DEBUG-mode.
|
|
|
|
h4. Example
|
|
|
|
If you have specified the CSS-groups “my_screen_css” and “my_print_css” and a JavaScript-group with the name “my_scripts”, you would use the following code to output them all:
|
|
|
|
<pre><code>
|
|
{% load compressed %}
|
|
{% compressed_css 'my_screen_css' %}
|
|
{% compressed_css 'my_print_css' %}
|
|
{% compressed_js 'my_scripts' %}
|
|
</code></pre>
|
|
|
|
h3. Far future Expires
|
|
|
|
Far future Expires can be used with the bump_filename-option, see the FarFutureExpires page for more information. |