Skip to content

Commit

Permalink
🚄 the kind of code one might write while on a train
Browse files Browse the repository at this point in the history
  • Loading branch information
zackmdavis committed Oct 26, 2014
1 parent 61efc44 commit 80ab4f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions core/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from django.conf import settings

from core.models import Tag
from core.views.view_utils import tag_cloud_context

def tag_cloud_context_processor(request):
return {'cloud': tag_cloud_context(Tag.objects.all())}

def contextual_static_serving_context_processor(request):
if settings.SERVE_STATIC_LIBS_LOCALLY:
jquery_url = "/static/libs/jquery-2.1.1.min.js"
underscore_url = "/static/libs/underscore-min.js"
else:
jquery_url = "//code.jquery.com/jquery-2.1.1.min.js"
underscore_url = "//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"
return locals()
2 changes: 2 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'core.context_processors.tag_cloud_context_processor',
'core.context_processors.contextual_static_serving_context_processor'
)

STATICFILES_DIRS = ('static',)
SERVE_STATIC_LIBS_LOCALLY = True

STATIC_URL = '/static/'

Expand Down
4 changes: 2 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
</div>
</div>

<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script src="{{ jquery_url }}"></script>
<script src="{{ underscore_url }}"></script>
<script src="/static/finetooth.js"></script>
</body>

Expand Down

0 comments on commit 80ab4f8

Please sign in to comment.