]> git.ozlabs.org Git - patchwork/commitdiff
Integrate 'django.contrib.staticfiles'
authorStephen Finucane <stephenfinucane@hotmail.com>
Tue, 7 Apr 2015 21:20:53 +0000 (22:20 +0100)
committerJeremy Kerr <jk@ozlabs.org>
Sun, 3 May 2015 05:46:52 +0000 (13:46 +0800)
Rather than providing a custom solution for serving static files, use
the solution provided in the upstream Django source.

This allows us to remove the top-level 'urls.py' file.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/urls.py
apps/settings.py
apps/urls.py [deleted file]
htdocs/css/style.css
templates/base.html
templates/patchwork/bundle.html
templates/patchwork/bundles.html
templates/patchwork/filters.html
templates/patchwork/list.html
templates/patchwork/patch-list.html

index 9b681f9f3da1ed0fb05c448539be77c2acac42e6..b28eb90ba6b03245d5a960e6df269bba305b649c 100644 (file)
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-from django.conf.urls import patterns, url
+from django.conf.urls import patterns, url, include
 from django.conf import settings
+from django.contrib import admin
 from django.contrib.auth import views as auth_views
 
+admin.autodiscover()
+
 urlpatterns = patterns('',
-    # Example:
+    url(r'^admin/', include(admin.site.urls)),
+
     (r'^$', 'patchwork.views.projects'),
     (r'^project/(?P<project_id>[^/]+)/list/$', 'patchwork.views.patch.list'),
     (r'^project/(?P<project_id>[^/]+)/$', 'patchwork.views.project.project'),
index dbe0544af34595f708e61f532e5988d9377e0925..01add3edaaf28e73a92450351c754a894c0b04e3 100644 (file)
@@ -19,6 +19,7 @@ INSTALLED_APPS = (
     'django.contrib.sessions',
     'django.contrib.sites',
     'django.contrib.admin',
+    'django.contrib.staticfiles',
     'patchwork',
 )
 
@@ -78,7 +79,7 @@ USE_I18N = True
 
 # URLs
 
-ROOT_URLCONF = 'urls'
+ROOT_URLCONF = 'patchwork.urls'
 
 # Security
 
@@ -99,8 +100,6 @@ TEMPLATE_DIRS = (
 # https://docs.djangoproject.com/en/1.6/ref/settings/#auth
 #
 
-ADMIN_MEDIA_PREFIX = '/media/'
-
 LOGIN_URL = '/user/login/'
 LOGIN_REDIRECT_URL = '/user/'
 
@@ -113,6 +112,18 @@ LOGIN_REDIRECT_URL = '/user/'
 SITE_ID = 1
 
 
+#
+# Static files settings
+# https://docs.djangoproject.com/en/1.6/ref/settings/#static-files
+#
+
+STATIC_URL = '/static/'
+
+STATICFILES_DIRS = [
+    os.path.join(ROOT_DIR, 'htdocs'),
+]
+
+
 #
 # Patchwork settings
 #
diff --git a/apps/urls.py b/apps/urls.py
deleted file mode 100644 (file)
index a8bd68c..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-# Patchwork - automated patch tracking system
-# Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
-#
-# This file is part of the Patchwork package.
-#
-# Patchwork is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Patchwork is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Patchwork; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-import os
-
-from django.conf.urls import patterns, include
-from django.conf import settings
-from django.contrib import admin
-
-admin.autodiscover()
-
-htdocs = os.path.join(settings.ROOT_DIR, 'htdocs')
-
-urlpatterns = patterns('',
-    # Example:
-    (r'^', include('patchwork.urls')),
-
-    # Uncomment this for admin:
-     (r'^admin/', include(admin.site.urls)),
-
-     (r'^css/(?P<path>.*)$', 'django.views.static.serve',
-        {'document_root': os.path.join(htdocs, 'css')}),
-     (r'^js/(?P<path>.*)$', 'django.views.static.serve',
-        {'document_root': os.path.join(htdocs, 'js')}),
-     (r'^images/(?P<path>.*)$', 'django.views.static.serve',
-        {'document_root': os.path.join(htdocs, 'images')}),
-)
-
index 87e0cd5d7f6f86ab795e72a447022d4ea36a3c0a..e5bbc755cf9659e7d161ad85fde87a5f64c815b7 100644 (file)
@@ -14,7 +14,7 @@ body {
 
 
 #title {
-       background: url('/images/title-background.png') top left repeat-x;
+       background: url('/static/images/title-background.png') top left repeat-x;
        background-color: #786fb4;
        margin: 0px;
        padding-top: 0.1em;
index f04d6e1e781df5b15a4d1fc227d56a0f880068ae..3d289fb226b21c279523719f1ccc33d533aec1b0 100644 (file)
@@ -1,12 +1,13 @@
-{% load pwurl %}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+{% load staticfiles %}
+{% load pwurl %}
+<!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">
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
   <title>{% block title %}Patchwork{% endblock %} - Patchwork</title>
-  <link rel="stylesheet" type="text/css" href="/css/style.css"/>
-  <script language="JavaScript" type="text/javascript" src="/js/common.js">
-  </script>
+  <link rel="stylesheet" type="text/css" href="{% static "css/style.css" %}"/>
+  <script type="text/javascript" src="{% static "js/common.js" %}"></script>
 {% block headers %}{% endblock %}
  </head>
  <body>
index d47cf1348333cfe3d145b264407ab8d124a3de9c..4a96b6bd3c48b5819ebffb1c9e596ed09da1006d 100644 (file)
@@ -1,17 +1,12 @@
 {% extends "base.html" %}
 
 {% load person %}
+{% load static %}
 
 {% block headers %}
-  <script language="JavaScript" type="text/javascript"
-   src="/js/jquery-1.10.1.min.js">
-  </script>
-  <script language="JavaScript" type="text/javascript"
-   src="/js/jquery.tablednd.js">
-  </script>
-  <script language="JavaScript" type="text/javascript"
-   src="/js/bundle.js">
-  </script>
+  <script type="text/javascript" src="{% static "js/jquery-1.10.1.min.js" %}"></script>
+  <script type="text/javascript" src="{% static "js/jquery.tablednd.js" %}"></script>
+  <script type="text/javascript" src="{% static "js/bundle.js" %}"></script>
 {% endblock %}
 {% block title %}{{project.name}}{% endblock %}
 {% block heading %}bundle: {{bundle.owner.username}} /
index a725d9552492dffb23dfc964e4814b0f88b8ec4f..11fb89dc47872d0f325e814204b038b17d584715 100644 (file)
@@ -1,5 +1,7 @@
 {% extends "base.html" %}
 
+{% load static %}
+
 {% block title %}Bundles{% endblock %}
 {% block heading %}Bundles{% endblock %}
 
@@ -27,7 +29,7 @@
   <td style="text-align: right">{{ bundle.n_patches }}</td>
   <td style="text-align: center;"><a
    href="{% url 'patchwork.views.bundle.mbox' username=bundle.owner.username bundlename=bundle.name %}"
-   ><img src="/images/16-em-down.png" width="16" height="16" alt="download"
+   ><img src="{% static "images/16-em-down.png" %}" width="16" height="16" alt="download"
    title="download"/></a></td>
   <td style="text-align: center;">
    <form method="post"
@@ -35,7 +37,7 @@
     {% csrf_token %}
     {{ bundle.delete_form.as_p }}
     <input type="image"
-     src="/images/16-em-cross.png" width="16" height="16" alt="delete"
+     src="{% static "images/patchwork/16-em-cross.png" %}" width="16" height="16" alt="delete"
      title="delete" border="0" style="border: none;"/>
    </form>
   </td>
index e2b7585404fe03b9ff240cb554088628e4309c52..10ca587ce7d089f383924299aa05d8b58b2e1ebc 100644 (file)
@@ -1,3 +1,4 @@
+{% load static %}
 
 <script type="text/javascript" language="JavaScript">
 var filterform_displayed = false;
@@ -150,7 +151,7 @@ function submitter_field_change(field)
     {% if not filter.forced %}
      <a href="{{ filter.url_without_me }}"><img
       width="16" height="16" alt="remove filter" title="remove filter"
-      src="/images/16-circle-blue-remove.png"></a>
+      src="{% static "images/16-circle-blue-remove.png" %}"></a>
     {% endif %}
    {% if not forloop.last %}&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;{% endif %}
   {% endfor %}
@@ -158,7 +159,7 @@ function submitter_field_change(field)
   none
   <a href="javascript:filter_click()"><img
   width="16" height="16" alt="add filter" title="add filter"
-  src="/images/16-circle-blue-add.png"></a>
+  src="{% static "images/16-circle-blue-add.png" %}"></a>
  {% endif %}
  </div>
  <div id="filterform" style="padding-top: 1em; display: none">
index 805406333a5f97fde73283d3b2210bda3e46b05c..654fe8c7ec3e74b34c99333576c14d4b90d98d6b 100644 (file)
@@ -1,6 +1,7 @@
 {% extends "base.html" %}
 
 {% load person %}
+{% load static %}
 
 {% block title %}{{project.name}}{% endblock %}
 {% block heading %}{{project.name}}{% endblock %}
index f8049f7bcabbad846cdc8e277ca84761cd08765e..675f67ff22885c7738d1b3235c3c360032c236f5 100644 (file)
@@ -1,5 +1,6 @@
 {% load person %}
 {% load listurl %}
+{% load static %}
 
 {% include "patchwork/pagination.html" %}
 
     {% ifequal order.name "name" %}
      <a class="colactive"
       href="{% listurl order=order.reversed_name %}"><img
-      src="/images/16-arrow-{% if order.reversed %}up{% else %}down{%endif%}.png"
+      {% if order.reversed %}
+      src="{% static "images/16-arrow-up.png" %}"
+      {% else %}
+      src="{% static "images/16-arrow-down.png" %}"
+      {%endif%}
       width="16" height="16"
      ></a> <a class="colactive"
       href="{% listurl order=order.reversed_name %}">Patch</a>
     {% ifequal order.name "date" %}
      <a class="colactive"
       href="{% listurl order=order.reversed_name %}"><img
-      src="/images/16-arrow-{% if order.reversed %}up{% else %}down{%endif%}.png"
+      {% if order.reversed %}
+      src="{% static "images/16-arrow-up.png" %}"
+      {% else %}
+      src="{% static "images/16-arrow-down.png" %}"
+      {%endif%}
       width="16" height="16"
      ></a> <a class="colactive"
       href="{% listurl order=order.reversed_name %}">Date</a>
     {% ifequal order.name "submitter" %}
      <a class="colactive"
       href="{% listurl order=order.reversed_name %}"><img
-      src="/images/16-arrow-{% if order.reversed %}up{% else %}down{%endif%}.png"
+      {% if order.reversed %}
+      src="{% static "images/16-arrow-up.png" %}"
+      {% else %}
+      src="{% static "images/16-arrow-down.png" %}"
+      {%endif%}
       width="16" height="16"
      ></a> <a class="colactive"
       href="{% listurl order=order.reversed_name %}">Submitter</a>
     {% ifequal order.name "delegate" %}
      <a class="colactive"
       href="{% listurl order=order.reversed_name %}"><img
-      src="/images/16-arrow-{% if order.reversed %}up{% else %}down{%endif%}.png"
+      {% if order.reversed %}
+      src="{% static "images/16-arrow-up.png" %}"
+      {% else %}
+      src="{% static "images/16-arrow-down.png" %}"
+      {%endif%}
       width="16" height="16"
      ></a> <a class="colactive"
       href="{% listurl order=order.reversed_name %}">Delegate</a>
     {% ifequal order.name "state" %}
      <a class="colactive"
       href="{% listurl order=order.reversed_name %}"><img
-      src="/images/16-arrow-{% if order.reversed %}up{% else %}down{%endif%}.png"
+      {% if order.reversed %}
+      src="{% static "images/16-arrow-up.png" %}"
+      {% else %}
+      src="{% static "images/16-arrow-down.png" %}"
+      {%endif%}
       width="16" height="16"
      ></a> <a class="colactive"
       href="{% listurl order=order.reversed_name %}">State</a>