My favorites | Sign in
Project Home
Search
for
Usage  
Describes how to use django-compress when it is installed and configured
Updated Nov 2, 2011 by andreas....@gmail.com

django-compress is no longer maintained

Please consider switching to [django-pipeline http://django-pipeline.readthedocs.org/]!

This page is kept for historical reasons.


Automated generation

If COMPRESS and COMPRESS_AUTO is enabled (True), 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.

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

./manage.py synccompress

(assuming you are in you project-folder that contains manage.py). To force all files to be re-generated, use the argument --force (e.g. ./manage.py synccompress --force)

Templatetags

django-compress includes two template tags: compressed_css and compressed_js, in a template library called compressed

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 COMPRESS setting, if you do not specify the COMPRESS setting, the source files will be used in DEBUG-mode, and compressed files in non-DEBUG-mode.

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:

{% load compressed %}
{% compressed_css 'my_screen_css' %}
{% compressed_css 'my_print_css' %}
{% compressed_js 'my_scripts' %}

Far future Expires

Far future Expires can be used with the bump_filename-option, see the FarFutureExpires page for more information.

Comment by dezodezo...@gmail.com, Nov 24, 2009

var searchData; var searchLimit = 0; var searchCount = 0; var searchQ = ""; var toogleDivs = new Array();

function StartSearch?() {

clearMarkers(); hideMarkerInfoWindows(); showDiv('vysledkyDiv', 'resultImage', 1, false);
var sel = document.getElementById("typzarizeni"); var sel2 = document.getElementById("typpece"); var typZariz = sel.options[sel.selectedIndex].value; var typPece = sel2.options[sel2.selectedIndex].value; var okres = document.getElementById('okres').value; var psc = document.getElementById('psc').value; if(typPece == "special_all") {
typPece = "";
} if(typZariz == "
special_all") {
typZariz = "";
} var obec = document.getElementById('obec').value; var ulice = document.getElementById('ulice').value;
searchQ = "typpece=" + typPece + "&typzariz=" + typZariz + "&ulice=" +ulice + "&obec=" +obec + "&psc=" + psc + "&okres=" + okres;

$.ajax({
type: "GET", url: "feeds/getFacilities.php", data: "typpece=" + typPece + "&typzariz=" + typZariz + "&ulice=" +ulice + "&obec=" +obec + "&psc=" + psc + "&okres=" + okres + "&limit=0", success: function(result) {
FillData?(result); SetSearchCounter?(result);
}, error: function(msg) {
alert('Error in AJAX');
}
});

}

function SetSearchCounter?(xmlResponse) {

var fac = xmlResponse.getElementsByTagName('Data'); var count = -1; if(fac.length > 0) {
count = parseInt(getNodeValue(fac0?, 'count')); searchLimit = parseInt(getNodeValue(fac0?, 'limit'));
}
if(count > 0) {
var i = 0; while(count > 0) {
count -= 10; i++;
} searchCount = i; document.getElementById('searchresulterro').innerHTML =""; document.getElementById('pagertr').style.display = "block"; $(document.getElementById("vysledky_th")).show("", { direction: "vertical" }, 1); document.getElementById('pager_text').innerHTML = "Zobrazena "+ (searchLimit + 1) +". stránka z " + i ;
} else {
document.getElementById('pagertr').style.display = "none"; $(document.getElementById("vysledky_th")).hide("", { direction: "vertical" }, 1); document.getElementById('searchresulterro').innerHTML = "Podle Vašich kritérií se nám nepodařilo vyhledat žádné zařízení. Změňte prosím vyhledávací kritéria.";
}
}

function doPagerAjax() {

clearMarkers(); hideMarkerInfoWindows();
$.ajax({
type: "GET", url: "feeds/getFacilities.php", data: searchQ + "&limit=" + searchLimit, success: function(result) {
FillData?(result); SetSearchCounter?(result);
}, error: function(msg) {
alert('Error in AJAX');
}
});
}

function pagerNext() {

if((searchLimit + 1) < searchCount)
{
searchLimit++;
doPagerAjax();
}

}

function pagerPrevious() {

if(searchLimit > 0)
{
searchLimit--;
doPagerAjax();
}
}

function pagerFirst() {

searchLimit = 0;
doPagerAjax();
}

function pagerLast() {

searchLimit = (searchCount - 1); doPagerAjax();
}

function FillData?(xmlResponse) {

var tbody = document.getElementById('seznamTbody'); removeChildNodes(tbody); var fac = xmlResponse.getElementsByTagName('facility');

if(fac.length > 0) {
searchData = fac;
for (var i = 0; i < fac.length; i++) {
var tr = document.createElement('tr'); var fNazev = getNodeValue(faci?,'nazev'); var fId = getNodeValue(faci?,'id'); var a = document.createElement('a'); if(fNazev != null) {
var td = document.createElement('td'); if(a.attachEvent ) {
a.attachEvent('onclick', evtShowInfoIe);
}
else
{
a.setAttribute('onclick', 'evtShowInfoOther('+ fId +');');
}
a.href = "javascript:voidx();"; a.name = fId; a.innerHTML = fNazev; td.appendChild(a); tr.appendChild(td);
}
var tdLoc = document.createElement('td'); tdLoc.className = "valign_top"; var aLoc = document.createElement('a'); aLoc.href = "javascript:voidx();"; aLoc.title = "Lokalizace na mapě"; aLoc.className = "lokalizace image_link_16"; aLoc.innerHTML = " "; aLoc.style.marginLeft = "5px"; if(getNodeValue(faci?,'x') != "-1") {
tdLoc.appendChild(aLoc); var lat = new google.maps.LatLng?(getNodeValue(faci?,'y'),getNodeValue(faci?,'x')) addMarkerToMap(lat, getNodeValue(faci?,'nazev'), "some title", aLoc, a); bounds.extend(lat);
} tr.appendChild(tdLoc);

var tdTrac = document.createElement('td'); tdTrac.className = "valign_top"; var aTrac = document.createElement('a'); aTrac.href = "#"; aTrac.name = fId; aTrac.title = "Najít trasu"; aTrac.className = "najit_trasu image_link_16"; aTrac.innerHTML = " "; aTrac.style.marginLeft = "5px";
if(aTrac.attachEvent )
{
aTrac.attachEvent('onclick', evtTraceDialogIe);
}
else
{
aTrac.setAttribute('onclick', 'evtTraceDialogOther('+ fId +');');
}
tdTrac.appendChild(aTrac); tr.appendChild(tdTrac); tbody.appendChild(tr);
}

gMapa.setZoom(16); gMapa.fitBounds(bounds);
}
}

function showTraceDialog(id) {

var node = getXmlNodeFromSearchDataById(id); if(node != null) {
document.getElementById("traceDialogFa").value = ""; var adr = getNodeValue(node,'ulice') ? getNodeValue(node,'ulice') : "";
adr += (getNodeValue(node,'obec') ? (", " + getNodeValue(node,'obec')) : ""); adr += getNodeValue(node,'psc') ? (", " + getNodeValue(node,'psc')) : "";
document.getElementById("traceDialogTa").value = adr;
} $("#tracedialog").dialog('open');
}

function showInfo(id) {

clearTimeData(); showDiv('detailInfoC', 'detailImage', 2, false); hideMarkerInfoWindows();
var elNazev = document.getElementById('info_nazev'); var elAdresa = document.getElementById('info_adresa'); var elKontakt = document.getElementById('info_kontakt'); var elMail = document.getElementById('info_mail'); var elTel = document.getElementById('info_telefon'); var elLokalizace = document.getElementById('A2'); var elTrasa = document.getElementById('A1'); if(searchData.length > 0) {
for (var i = 0; i < searchData.length; i++) {
var fId = getNodeValue(searchDatai?,'id'); if(fId != null) {
if(fId == id) {
elNazev.innerHTML = getNodeValue(searchDatai?,'nazev') ? getNodeValue(searchDatai?,'nazev') : ""; var adr = getNodeValue(searchDatai?,'ulice') ? getNodeValue(searchDatai?,'ulice') : ""; adr += "<br>" + (getNodeValue(searchDatai?,'obec') ? getNodeValue(searchDatai?,'obec') : ""); adr += getNodeValue(searchDatai?,'psc') ? (", " + getNodeValue(searchDatai?,'psc')) : ""; elAdresa.innerHTML = adr; elKontakt.innerHTML = getNodeValue(searchDatai?,'kontakt') ? getNodeValue(searchDatai?,'kontakt') : ""; elMail.innerHTML = getNodeValue(searchDatai?,'email') ? ("<a href = 'mailto:" + getNodeValue(searchDatai?,'email') + "'>" + getNodeValue(searchDatai?,'email') + "</a>") : ""; elTel.innerHTML = getNodeValue(searchDatai?,'telefon') ? getNodeValue(searchDatai?,'telefon') : ""; elTrasa.name = id; if(elTrasa.attachEvent ) {
elTrasa.attachEvent('onclick', evtTraceDialogIe);
}
else
{
elTrasa.setAttribute('onclick', 'evtTraceDialogOther('+ id +');');
}
var x = getNodeValue(searchDatai?,'x'); var y = getNodeValue(searchDatai?,'y'); if(x != "-1") {
elLokalizace.style.display = "block"; $(elLokalizace).click(
function() {
setCenter(x,y);
}
);
} else {
elLokalizace.style.display = "none";
}

$.ajax({
type: "GET", url: "feeds/getTime.php", data: "id=" + fId, success: function(result) {
getTimeData(result);
}, error: function(msg) {
alert('Error in AJAX');
}
});
}
}
}
}

}

function getTimeData(xmlResponse) {

var time = xmlResponse.getElementsByTagName('time'); if(time.length > 0) {
for(var i = 0; i < time.length; i++) {
var day = getNodeValue(timei?, 'day'); document.getElementById('t' + day + '1').innerHTML = gnc(getNodeValue(timei?, 'od1')) + " - " + gnc(getNodeValue(timei?, 'do1')); document.getElementById('t' + day + '2').innerHTML = gnc(getNodeValue(timei?, 'od2')) + " - " + gnc(getNodeValue(timei?, 'do2')); document.getElementById('t' + day + '3').innerHTML = gnc(getNodeValue(timei?, 'od3')) + " - " + gnc(getNodeValue(timei?, 'do3'));
}
}
}

function gnc(x) {

return x ? x : "";
}

function clearTimeData() {

document.getElementById('t11').innerHTML = ""; document.getElementById('t12').innerHTML = ""; document.getElementById('t13').innerHTML = ""; document.getElementById('t21').innerHTML = ""; document.getElementById('t22').innerHTML = ""; document.getElementById('t23').innerHTML = ""; document.getElementById('t31').innerHTML = ""; document.getElementById('t32').innerHTML = ""; document.getElementById('t33').innerHTML = "";

}

function getXmlNodeFromSearchDataById(id) {

if(searchData.length > 0)
{
for (var i = 0; i < searchData.length; i++)
{
if(getNodeValue(searchDatai?,'id') == id) {
return searchDatai?;
}
} }

return null;
}

function getNodeValue(obj,tag) {

if (obj != null) {
if (obj.getElementsByTagName(tag)0? != null)
if (obj.getElementsByTagName(tag)0?.firstChild != null)
return obj.getElementsByTagName(tag)0?.firstChild.nodeValue;
else
return null;
else
return null;
} else
return null;
}

Comment by CPR.AL....@gmail.com, Jan 14, 2010

What the hell was that?

Comment by arka...@gmail.com, Sep 4, 2010

That guy apparently thought this box was the JS compressor, lolz

Comment by i...@reinaris.nl, Aug 16, 2011

hahaha

Comment by tjgu...@gmail.com, Sep 13, 2011

This is working great for my JS, but it seems to not do anything for the CSS. Actually I take that back, it's doing something: it creates my aggregated, minified, version file name. But there is nothing inside the file.

Any ideas?


Sign in to add a comment
Powered by Google Project Hosting