Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Use django compressor for CSS and JS files

Roland Geider9e05a23911fe
diff --git a/requirements.txt b/requirements.txt
index 19a65d976..879c5379e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,3 +11,4 @@ django-tastypie==0.9.16
python-mimeparse
pillow
easy-thumbnails
+django_compressor
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 943b27655..581dd34e0 100644
--- a/setup.py
+++ b/setup.py
@@ -56,6 +56,7 @@ setup(
'python-mimeparse',
'pillow',
'easy-thumbnails',
+ 'django_compressor',
],
entry_points={
'console_scripts': [
diff --git a/wger/exercises/templates/view.html b/wger/exercises/templates/view.html
index 7a367a99e..e3b38dd0f 100644
--- a/wger/exercises/templates/view.html
+++ b/wger/exercises/templates/view.html
@@ -8,7 +8,6 @@
{% block header %}
<script src="{% static 'js/tinymce/tiny_mce.js' %}"></script>
-<script src="{% static 'js/exercises.js' %}"></script>
<script>
function custom_modal_init()
diff --git a/wger/manager/static/css/yaml401/demos/css/flexible-grids.css b/wger/manager/static/css/yaml401/demos/css/flexible-grids.css
deleted file mode 100644
index d35c4bae7..000000000
--- a/wger/manager/static/css/yaml401/demos/css/flexible-grids.css
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * "Yet Another Multicolumn Layout" - YAML CSS Framework
- *
- * central stylesheet - layout example "flexible-grids"
- *
- * @copyright Copyright 2005-2012, Dirk Jesse
- * @license CC-BY 2.0 (http://creativecommons.org/licenses/by/2.0/),
- * YAML-CDL (http://www.yaml.de/license.html)
- * @link http://www.yaml.de
- * @package yaml
- * @version v4.0.1
- * @lastmodified $Date: 2012-03-03 11:45:41 +0100 (Sa, 03 Mrz 2012) $
- */
-
-/* import core styles | Basis-Stylesheets einbinden */
-@import url(../../yaml/core/base.min.css);
-
-/* import screen layout | Screen-Layout einbinden */
-@import url(../../yaml/navigation/hlist.css);
-@import url(../../yaml/forms/gray-theme.css);
-
-@import url(../../yaml/screen/typography.css);
-@import url(../../yaml/screen/screen-FULLPAGE-layout.css);
-
-/* import print layout | Druck-Layout einbinden */
-@import url(../../yaml/print/print.css);
diff --git a/wger/manager/templates/mobile/template.html b/wger/manager/templates/mobile/template.html
index b43f1225c..82604e93e 100644
--- a/wger/manager/templates/mobile/template.html
+++ b/wger/manager/templates/mobile/template.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-{% load i18n %}{% load staticfiles %}{% load cache %}{% load browserid %}
+{% load i18n %}{% load staticfiles %}{% load cache %}{% load browserid %}{% load compress %}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@@ -29,12 +29,15 @@
<link rel="icon" href="{% static 'images/favicon.png' %}" type="image/png">
+ {% compress css %}
<link rel="stylesheet" type="text/css" href="{% static 'css/jquery-mobile.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/jquery-mobile.structure.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager-common.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager-mobile.css' %}">
+ {% endcompress %}
{% browserid_css %}
+ {% compress js %}
<script src="{% static 'js/jquery.js' %}" type="text/javascript"></script>
<script src="{% static 'js/jquery-ui.js' %}" type="text/javascript"></script>
<script src="{% static 'js/jquery-mobile.js' %}" type="text/javascript"></script>
@@ -44,8 +47,11 @@
<script src="{% static 'js/exercises.js' %}"></script>
<script src="{% static 'js/weight.js' %}"></script>
<script src="{% static 'js/nutrition.js' %}"></script>
+ <script src="{% static 'js/browserid.js' %}" type="text/javascript"></script>
+ {% endcompress %}
{% block header %}{% endblock %}
+
</head>
<body>
{% browserid_info %}
@@ -127,6 +133,6 @@
</div><!-- /page -->
<script src="https://login.persona.org/include.js" type="text/javascript"></script>
-<script src="{% static 'js/browserid.js' %}" type="text/javascript"></script>
+
</body>
</html>
diff --git a/wger/manager/templates/template.html b/wger/manager/templates/template.html
index 7664d6341..b248ac559 100644
--- a/wger/manager/templates/template.html
+++ b/wger/manager/templates/template.html
@@ -4,6 +4,7 @@
{% load url from future %}
{% load staticfiles %}
{% load wger_extras %}
+{% load compress %}
<html lang="{{language.short_name}}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@@ -27,20 +28,38 @@
along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.
-->
- <link rel="stylesheet" type="text/css" href="{% static 'css/yaml401/demos/css/flexible-grids.css' %} ">
+ {% compress css %}
+ <link rel="stylesheet" type="text/css" href="{% static 'css/yaml401/yaml/core/base.min.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/yaml401/yaml/navigation/hlist.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/yaml401/yaml/forms/gray-theme.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/yaml401/yaml/screen/typography.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/yaml401/yaml/screen/screen-FULLPAGE-layout.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/yaml401/yaml/print/print.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/yaml401/custom-yaml.css' %}">
+
<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager-common.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/jquery-ui.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/jquery-ui-custom.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-custom.css' %}">
+ {% endcompress %}
<link rel="icon" href="{% static 'images/favicon.png' %}" type="image/png">
+ {% compress js %}
<script src="{% static 'js/jquery.js' %}" type="text/javascript"></script>
<script src="{% static 'js/jquery-ui.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/d3.js' %}" type="text/javascript"></script>
<script src="{% static 'js/workout-manager.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/browserid.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/ubuntu-unity.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/bootstrap.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/exercises.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/weight.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/nutrition.js' %}" type="text/javascript"></script>
+ {% endcompress %}
+
<script src="{% static datepicker_i18n_path %}"></script>
{% block header %}{% endblock %}
@@ -170,9 +189,7 @@
</div>
</div>
</footer>
+
<script src="https://login.persona.org/include.js" type="text/javascript"></script>
-<script src="{% static 'js/browserid.js' %}" type="text/javascript"></script>
-<script src="{% static 'js/ubuntu-unity.js' %}" type="text/javascript"></script>
-<script src="{% static 'js/bootstrap.js' %}" type="text/javascript"></script>
</body>
</html>
diff --git a/wger/manager/templates/workout/log.html b/wger/manager/templates/workout/log.html
index bc6472594..165a5e74f 100644
--- a/wger/manager/templates/workout/log.html
+++ b/wger/manager/templates/workout/log.html
@@ -7,8 +7,6 @@
{% block title %}{% trans "Weight log for workout" %}{% endblock %}
{% block header %}
-<script src="{% static 'js/exercises.js' %}"></script>
-<script src="{% static 'js/d3.js' %}"></script>
<script type="text/javascript">
// Initialise the datepicker for the modal dialog
diff --git a/wger/nutrition/templates/bmi/form.html b/wger/nutrition/templates/bmi/form.html
index d8b6c0fcc..1ac07b3c9 100644
--- a/wger/nutrition/templates/bmi/form.html
+++ b/wger/nutrition/templates/bmi/form.html
@@ -4,10 +4,6 @@
{% load wger_extras %}
{% block header %}
-<script src="{% static 'js/d3.js' %}"></script>
-<script src="{% static 'js/nutrition.js' %}"></script>
-
-
<style>
div.table {
display:table;
diff --git a/wger/nutrition/templates/ingredient/view.html b/wger/nutrition/templates/ingredient/view.html
index 68b36f851..346f821d2 100644
--- a/wger/nutrition/templates/ingredient/view.html
+++ b/wger/nutrition/templates/ingredient/view.html
@@ -7,7 +7,6 @@
{% block title %}{{ingredient.name}}{% endblock %}
{% block header %}
-<script src="{% static 'js/nutrition.js' %}"></script>
<script>
$(document).ready(function() {
init_ingredient_detail("{% url 'ingredient-get-values' ingredient.id %}");
diff --git a/wger/nutrition/templates/meal_item/edit.html b/wger/nutrition/templates/meal_item/edit.html
index 5f5d525b5..b8e694c61 100644
--- a/wger/nutrition/templates/meal_item/edit.html
+++ b/wger/nutrition/templates/meal_item/edit.html
@@ -9,8 +9,6 @@
{% block header %}
-<script src="{% static 'js/nutrition.js' %}"></script>
-
<script type="text/javascript">
$(document).ready(function() {
// Init the autocompleter
diff --git a/wger/nutrition/templates/plan/view.html b/wger/nutrition/templates/plan/view.html
index dd19501cc..1c2e664eb 100644
--- a/wger/nutrition/templates/plan/view.html
+++ b/wger/nutrition/templates/plan/view.html
@@ -7,7 +7,6 @@
{% block header %}
-<script src="{% static 'js/nutrition.js' %}"></script>
<script>
function custom_modal_init()
{
diff --git a/wger/nutrition/templates/rate/form.html b/wger/nutrition/templates/rate/form.html
index cd0b113de..63aa36598 100644
--- a/wger/nutrition/templates/rate/form.html
+++ b/wger/nutrition/templates/rate/form.html
@@ -4,8 +4,6 @@
{% load wger_extras %}
{% block header %}
-<script src="{% static 'js/nutrition.js' %}"></script>
-
<script>
$(document).ready(function() {
init_calories_calculator();
diff --git a/wger/settings_global.py b/wger/settings_global.py
index 30f9e33b0..95db8d748 100644
--- a/wger/settings_global.py
+++ b/wger/settings_global.py
@@ -132,6 +132,7 @@ STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
+ 'compressor.finders.CompressorFinder',
)
# List of callables that know how to import templates from various sources.
@@ -217,7 +218,10 @@ INSTALLED_APPS = (
'tastypie',
# thumbnails
- 'easy_thumbnails'
+ 'easy_thumbnails',
+
+ # CSS/JS compressor
+ 'compressor',
)
@@ -320,3 +324,12 @@ THUMBNAIL_ALIASES = {
'large_cropped': {'size': (800, 800), 'crop': 'smart', 'quality': 90},
},
}
+
+
+#
+# Django compressor
+#
+
+# The default is not DEBUG, override if needed
+#COMPRESS_ENABLED = True
+COMPRESS_ROOT = STATIC_ROOT
\ No newline at end of file
diff --git a/wger/weight/templates/weight_overview.html b/wger/weight/templates/weight_overview.html
index 6b6accf68..c84c8b5e4 100644
--- a/wger/weight/templates/weight_overview.html
+++ b/wger/weight/templates/weight_overview.html
@@ -12,9 +12,7 @@
Header data
-->
{% block header %}
-<script src="{% static 'js/d3.js' %}"></script>
<script src="{% static 'js/jquery-globalize/lib/globalize.js' %}"></script>
-<script src="{% static 'js/weight.js' %}"></script>
<script type="text/javascript">