summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dpmcgee@gmail.com>2013-02-04 22:00:43 -0600
committerDan McGee <dpmcgee@gmail.com>2013-02-04 22:00:43 -0600
commit1e74e60de946df18391b698eb4b2966d5b81d23d (patch)
tree8dda449e1bbfdd8a7d3ed84e8eeebdcf9dd5029e
parent1fea48a5d5337fdda3d6599d6daf806f9034cd46 (diff)
downloadwebsite-1e74e60de946df18391b698eb4b2966d5b81d23d.tar.gz
website-1e74e60de946df18391b698eb4b2966d5b81d23d.zip
Convert to using django.contrib.staticfilesdeployed
-rw-r--r--general/templatetags/cdn.py4
-rw-r--r--settings.py22
-rw-r--r--templates/base.html5
-rw-r--r--templates/blog/base.html6
-rw-r--r--templates/index.html3
-rw-r--r--urls.py6
6 files changed, 28 insertions, 18 deletions
diff --git a/general/templatetags/cdn.py b/general/templatetags/cdn.py
index 22771e2..0e979e5 100644
--- a/general/templatetags/cdn.py
+++ b/general/templatetags/cdn.py
@@ -17,9 +17,9 @@ class JQueryNode(template.Node):
elif oncdn:
jq = 'https://ajax.googleapis.com/ajax/libs/jquery/%s/jquery.js' % version
elif minified:
- jq = '/media/jquery-%s.min.js' % version
+ jq = '/static/jquery-%s.min.js' % version
else:
- jq = '/media/jquery-%s.js' % version
+ jq = '/static/jquery-%s.js' % version
return '<script type="text/javascript" src="%s"></script>' % jq
# vim: set ts=4 sw=4 et:
diff --git a/settings.py b/settings.py
index b5e00cc..86787a6 100644
--- a/settings.py
+++ b/settings.py
@@ -1,5 +1,9 @@
+import os
# Django settings for toofishes project.
+# Full path to the data directory
+DEPLOY_PATH = os.path.dirname(os.path.realpath(__file__))
+
# Import local settings for current deployment
from local_settings import *
@@ -32,10 +36,10 @@ USE_L10N = False
USE_ETAGS = True
-# URL to use for static files
-STATIC_URL = '/static/'
+TEMPLATE_DIRS = (
+ '%s/templates' % DEPLOY_PATH,
+)
-# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
@@ -53,8 +57,15 @@ MIDDLEWARE_CLASSES = (
ROOT_URLCONF = 'urls'
-TEMPLATE_DIRS = (
- '%s/templates' % DEPLOY_PATH,
+# URL to serve static files
+STATIC_URL = '/static/'
+
+# Location to collect static files
+STATIC_ROOT = os.path.join(DEPLOY_PATH, 'collected_static')
+
+# Look for more static files in these locations
+STATICFILES_DIRS = (
+ os.path.join(DEPLOY_PATH, 'sitestatic'),
)
# Static files backend that allows us to use far future Expires headers
@@ -79,6 +90,7 @@ INSTALLED_APPS = (
'django.contrib.admindocs',
'django.contrib.messages',
'django.contrib.sitemaps',
+ 'django.contrib.staticfiles',
'general',
'blog',
'django.contrib.comments',
diff --git a/templates/base.html b/templates/base.html
index e0f5ab4..65e859a 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -1,10 +1,11 @@
+{% load static from staticfiles %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=640" />
- <link rel="stylesheet" type="text/css" href="/media/style-14.css" />
+ <link rel="stylesheet" type="text/css" href="{% static "style.css" %}" />
<title>{% block title %}toofishes.net{% endblock %}</title>
{% block headdata %}{% endblock %}
</head>
@@ -40,7 +41,7 @@
</div>
{% block enddata %}
{% load cdn %}{% jquery %}
- <script type="text/javascript" src="/media/script-5.js"></script>
+ <script type="text/javascript" src="{% static "script.js" %}"></script>
{% block moreenddata %}
{% endblock %}
{% endblock %}
diff --git a/templates/blog/base.html b/templates/blog/base.html
index 29dbab7..b1928ac 100644
--- a/templates/blog/base.html
+++ b/templates/blog/base.html
@@ -1,14 +1,16 @@
{% extends "base.html" %}
+{% load static from staticfiles %}
+
{% block headdata %}
-<link rel="stylesheet" type="text/css" href="/media/prettify-min-20110601/prettify.css" />
+<link rel="stylesheet" type="text/css" href="{% static "prettify-min-20110601/prettify.css" %}" />
{% block blogheaddata %}{% endblock %}
{% endblock %}
{% block title %}toofishes.net - {% block subtitle %}Blog{% endblock %}{% endblock %}
{% block moreenddata %}
-<script type="text/javascript" src="/media/prettify-min-20110601/prettify-combined.js"></script>
+<script type="text/javascript" src="{% static "prettify-min-20110601/prettify-combined.js" %}"></script>
<script type="text/javascript">
$(document).ready(makePretty);
</script>
diff --git a/templates/index.html b/templates/index.html
index 793f372..2273673 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% load url from future %}
+{% load static from staticfiles %}
{% block headdata %}
<meta name="verify-v1" content="UDCMxyj13AopMD2Qsfr3So1nzShqDllJ86ySqsFQAGU=" />
@@ -37,7 +38,7 @@ ramblings.</p>
{% endblock %}
{% block moreenddata %}
-<script type="text/javascript" src="/media/jquery.tagcloud.min.js"></script>
+<script type="text/javascript" src="{% static "jquery.tagcloud.min.js" %}"></script>
<script type="text/javascript">
$(document).ready(makeTagCloud);
</script>
diff --git a/urls.py b/urls.py
index cb78004..7bcf28e 100644
--- a/urls.py
+++ b/urls.py
@@ -41,10 +41,4 @@ urlpatterns += patterns('django.contrib',
{'sitemaps': sitemaps}, "sitemap"),
)
-if settings.DEBUG:
- urlpatterns += patterns('',
- (r'^media/(?P<path>.*)$', 'django.views.static.serve',
- {'document_root': settings.MEDIA_ROOT}),
- )
-
# vim: set ts=4 sw=4 et: