diff --git a/core/context_processors.py b/core/context_processors.py index b8f1fdb..42bbd3e 100644 --- a/core/context_processors.py +++ b/core/context_processors.py @@ -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() diff --git a/settings.py b/settings.py index 670adbb..f688f35 100644 --- a/settings.py +++ b/settings.py @@ -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/' diff --git a/templates/base.html b/templates/base.html index bbf6954..5b19d0a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -48,8 +48,8 @@ - - + +