Skip to content

Commit

Permalink
Merge pull request #58 from lionleaf/compressor
Browse files Browse the repository at this point in the history
Use django-compressor to compress and combine js and css
  • Loading branch information
lionleaf authored Aug 17, 2016
2 parents 220532a + 009b68c commit e2b61f0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.pyc
.*
dwitter/settings/local.py
dwitter/static/CACHE/*
*.db
.gitignore
.*.sw*
Expand Down
7 changes: 7 additions & 0 deletions dwitter/feed/templates/feed/feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

{% block head %}
{% load staticfiles %}
{% load compress %}

{% compress js %}
<script src="{% static "libs/jquery.min.js" %}"></script>
<script src="{% static "libs/jquery.waypoints.min.js" %}"></script>
<script src="{% static "libs/inview.min.js" %}"></script>
<script src="{% static "libs/infinite.min.js" %}"></script>
{% endcompress %}
{% endblock %}

{% block body_class %}{{sort}}{% endblock %}
Expand All @@ -33,11 +37,14 @@
{% block fullcontent %}

{% load staticfiles %}
{% load compress %}
{% compress js %}
<script src="{% static "js/scrolling.js" %}"></script>
<script src="{% static "js/editor-preview.js" %}"></script>
<script src="{% static "js/ajax-handling.js" %}"></script>
<script src="{% static "js/feed.js" %}"></script>
<!--<script src="{% static 'js/submit-view.js' %}"></script> -->
{% endcompress %}



Expand Down
9 changes: 8 additions & 1 deletion dwitter/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'dwitter.dweet',
'subdomains',
'anymail',
'compressor',
]

REST_FRAMEWORK = {
Expand Down Expand Up @@ -158,6 +159,12 @@
# https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "dwitter/static/")
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)


6 changes: 6 additions & 0 deletions dwitter/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<meta charset="utf-8" />
<title>{% block title %} Dwitter {% endblock %} </title>
<meta name="viewport" content="width=device-width, initial-scale=1">
{% load compress %}

{% compress js %}
<!-- Google Analytics! -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand All @@ -15,9 +17,13 @@
ga('send', 'pageview');

</script>
{% endcompress %}

{% load staticfiles %}
{% compress css %}
<link rel=stylesheet href='{% static "main.css" %}' >
{% endcompress %}

{% block head %}
{% endblock %}
</head>
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ django-subdomains==2.1.0rc0
djangorestframework==3.3.3
django-anymail==0.3.1
django-filter==0.13
django-compressor==2.1
flake8

0 comments on commit e2b61f0

Please sign in to comment.