Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Setup modern static files handling.

  • Loading branch information...
commit c5b01e7b0b15fcdd2de49687f97f06b516d7d17d 1 parent daf3ed0
Aymeric Augustin authored February 06, 2013

Showing 81 changed files with 19 additions and 32 deletions. Show diff stats Hide diff stats

  1. 2  .gitignore
  2. 7  django_docs/urls.py
  3. 13  django_www/settings.py
  4. 7  django_www/urls.py
  5. 4  docs/management/commands/update_docs.py
  6. 6  docs/templates/docs/doc.html
  7. 4  docs/templates/docs/index.html
  8. 0  {media → static}/css/admin.css
  9. 0  {media → static}/css/base.css
  10. 0  {media → static}/css/community.css
  11. 0  {media → static}/css/docs/docs.css
  12. 0  {media → static}/css/docs/index.css
  13. 0  {media → static}/css/documentation.css
  14. 0  {media → static}/css/download.css
  15. 0  {media → static}/css/homepage.css
  16. 0  {media → static}/css/print.css
  17. 0  {media → static}/css/pygments.css
  18. 0  {media → static}/css/weblog.css
  19. 0  {media → static}/favicon.ico
  20. 0  {media → static}/img/badges/djangodonated126x54.gif
  21. 0  {media → static}/img/badges/djangodonated126x54_grey.png
  22. 0  {media → static}/img/badges/djangojoint107x25.gif
  23. 0  {media → static}/img/badges/djangojoint107x25_grey.gif
  24. 0  {media → static}/img/badges/djangomade124x25.gif
  25. 0  {media → static}/img/badges/djangomade124x25_grey.gif
  26. 0  {media → static}/img/badges/djangopowered126x54.gif
  27. 0  {media → static}/img/badges/djangopowered126x54_grey.gif
  28. 0  {media → static}/img/badges/djangoproject120x24.gif
  29. 0  {media → static}/img/badges/djangoproject120x25.gif
  30. 0  {media → static}/img/badges/djangoproject120x25_grey.gif
  31. 0  {media → static}/img/badges/djangosite100x25.gif
  32. 0  {media → static}/img/badges/djangosite100x25_grey.gif
  33. 0  {media → static}/img/badges/djangosite124x25.gif
  34. 0  {media → static}/img/badges/djangosite80x15.gif
  35. 0  {media → static}/img/badges/djangosite80x15_grey.gif
  36. 0  {media → static}/img/badges/djangosponsor113x25.gif
  37. 0  {media → static}/img/badges/djangosponsor113x25_grey.gif
  38. 0  {media → static}/img/badges/djangowish126x70.gif
  39. 0  {media → static}/img/badges/djangowish126x70_grey.gif
  40. 0  {media → static}/img/desktops/desktop-43_t.jpg
  41. 0  {media → static}/img/desktops/desktop-wide_t.jpg
  42. 0  {media → static}/img/desktops/djangodesktop-1024x768.jpg
  43. 0  {media → static}/img/desktops/djangodesktop-1152x864.jpg
  44. 0  {media → static}/img/desktops/djangodesktop-1280x1024.jpg
  45. 0  {media → static}/img/desktops/djangodesktop-1600x1200.jpg
  46. 0  {media → static}/img/desktops/djangodesktop-1680x1050.jpg
  47. 0  {media → static}/img/desktops/djangodesktop-800x600.jpg
  48. 0  {media → static}/img/doc/icons/docicons-behindscenes.gif
  49. 0  {media → static}/img/doc/icons/docicons-note.gif
  50. 0  {media → static}/img/doc/icons/docicons-philosophy.gif
  51. 0  {media → static}/img/logos/django-logo-negative.eps
  52. 0  {media → static}/img/logos/django-logo-negative.png
  53. 0  {media → static}/img/logos/django-logo-negative.svg
  54. 0  {media → static}/img/logos/django-logo-positive.eps
  55. 0  {media → static}/img/logos/django-logo-positive.png
  56. 0  {media → static}/img/logos/django-logo-positive.svg
  57. 0  {media → static}/img/site/arrow-head-left.gif
  58. 0  {media → static}/img/site/bbd_bg.gif
  59. 0  {media → static}/img/site/bbd_blogroll.gif
  60. 0  {media → static}/img/site/bbd_code.gif
  61. 0  {media → static}/img/site/bbd_community.gif
  62. 0  {media → static}/img/site/bbd_documentation.gif
  63. 0  {media → static}/img/site/bbd_download.gif
  64. 0  {media → static}/img/site/bbd_homepage.gif
  65. 0  {media → static}/img/site/bbd_overview.gif
  66. 0  {media → static}/img/site/bbd_weblog.gif
  67. 0  {media → static}/img/site/bbdsm_bg.gif
  68. 0  {media → static}/img/site/bbdsm_bg.gif.1
  69. 0  {media → static}/img/site/djangoapi-logo.gif
  70. 0  {media → static}/img/site/download_bg-left.gif
  71. 0  {media → static}/img/site/download_bg-right.gif
  72. 0  {media → static}/img/site/hdr_logo.gif
  73. 0  {media → static}/img/site/hdr_meetdjango.gif
  74. 0  {media → static}/img/site/invisible.gif
  75. 0  {media → static}/img/site/mt.png
  76. 0  {media → static}/img/site/nav_bg.gif
  77. 0  {media → static}/img/site/screencast-back.gif
  78. 0  {media → static}/img/site/screencast-next.gif
  79. 0  {media → static}/img/site/somerights20.png
  80. 6  templates/base.html
  81. 2  templates/base_code.html
2  .gitignore
... ...
@@ -1,5 +1,5 @@
1 1
 *.pyc
2 2
 *.db
3 3
 local_settings.py
4  
-media/docs
  4
+static_root
5 5
 src/
7  django_docs/urls.py
@@ -51,10 +51,3 @@
51 51
         name = 'document-detail',
52 52
     ),
53 53
 )
54  
-
55  
-if settings.DEBUG:
56  
-    urlpatterns += patterns('',
57  
-        url(r'^media/(?P<path>.*)$',
58  
-            'django.views.static.serve',
59  
-            {'document_root': settings.MEDIA_ROOT}),
60  
-    )
13  django_www/settings.py
@@ -40,21 +40,21 @@
40 40
 USE_I18N = False
41 41
 USE_L10N = False
42 42
 
43  
-TEMPLATE_DIRS = [BASE.parent.child('templates')]
44 43
 MEDIA_ROOT = BASE.parent.child('media')
  44
+MEDIA_URL = '/m/'
  45
+TEMPLATE_DIRS = [BASE.parent.child('templates')]
  46
+STATICFILES_DIRS = [BASE.parent.child('static')]
  47
+STATIC_ROOT = BASE.parent.child('static_root')
  48
+STATIC_URL = '/s/'
45 49
 
46 50
 if PRODUCTION:
47 51
     DEBUG = False
48 52
     PREPEND_WWW = True
49 53
     CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
50  
-    MEDIA_URL = "https://www.djangoproject.com/m/"
51  
-    ADMIN_MEDIA_PREFIX = "https://www.djangoproject.com/m/admin/"
52 54
 else:
53 55
     DEBUG = True
54 56
     PREPEND_WWW = False
55 57
     CACHE_BACKEND = "dummy:///"
56  
-    MEDIA_URL = "/media/"
57  
-    ADMIN_MEDIA_PREFIX = '/admin_media/'
58 58
     EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
59 59
 
60 60
 SITE_ID = 1
@@ -70,6 +70,7 @@
70 70
     'django.contrib.messages',
71 71
     'django.contrib.redirects',
72 72
     'django.contrib.sessions',
  73
+    'django.contrib.staticfiles',
73 74
     'django.contrib.sitemaps',
74 75
     'django_push.subscriber',
75 76
     'blog',
@@ -113,7 +114,7 @@
113 114
     "django.contrib.auth.context_processors.auth",
114 115
     "django.core.context_processors.debug",
115 116
     "django.core.context_processors.i18n",
116  
-    "django.core.context_processors.media",
  117
+    "django.core.context_processors.static",
117 118
     "django_website.context_processors.recent_release",
118 119
     "django.contrib.messages.context_processors.messages",
119 120
     ]
7  django_www/urls.py
@@ -63,10 +63,3 @@
63 63
     url(r'^svntogit/', include('svntogit.urls')),
64 64
     url(r'', include('legacy.urls')),
65 65
 )
66  
-
67  
-if not settings.PRODUCTION:
68  
-    urlpatterns += patterns("django.views",
69  
-        url(r"^media/(?P<path>.*)", "static.serve", {
70  
-            "document_root": settings.MEDIA_ROOT,
71  
-        }),
72  
-    )
4  docs/management/commands/update_docs.py
@@ -84,11 +84,11 @@ def handle_noargs(self, **kwargs):
84 84
 
85 85
             #
86 86
             # Create a zip file of the HTML build for offline reading.
87  
-            # This gets moved into MEDIA_ROOT for downloading.
  87
+            # This gets moved into STATIC_ROOT for downloading.
88 88
             #
89 89
             html_build_dir = destdir.child('_build', 'html')
90 90
             zipfile_name = 'django-docs-%s-%s.zip' % (release.version, release.lang)
91  
-            zipfile_path = Path(settings.MEDIA_ROOT).child('docs', zipfile_name)
  91
+            zipfile_path = Path(settings.STATIC_ROOT).child('docs', zipfile_name)
92 92
             if not zipfile_path.parent.exists():
93 93
                 zipfile_path.parent.mkdir(parents=True)
94 94
             if verbosity >= 2:
6  docs/templates/docs/doc.html
@@ -4,8 +4,8 @@
4 4
 
5 5
 {% block extrahead %}
6 6
   {{ block.super }}
7  
-  <link rel="stylesheet" href="{{ MEDIA_URL }}css/docs/docs.css" type="text/css" />
8  
-  <link rel="stylesheet" href="{{ MEDIA_URL }}css/pygments.css" type="text/css" />
  7
+  <link rel="stylesheet" href="{{ STATIC_URL }}css/docs/docs.css" type="text/css" />
  8
+  <link rel="stylesheet" href="{{ STATIC_URL }}css/pygments.css" type="text/css" />
9 9
 {% endblock %}
10 10
 
11 11
 {% block billboard %}
@@ -114,7 +114,7 @@ <h2 id="comments">Questions/Feedback</h2>
114 114
       <h2>Download:</h2>
115 115
       <p>
116 116
         Offline ({% if version == "dev" %}development version{% else %}Django {{ version }}{% endif %}):
117  
-        <a href="{{ MEDIA_URL }}docs/django-docs-{{ version }}-{{ lang }}.zip">HTML</a> |
  117
+        <a href="{{ STATIC_URL }}docs/django-docs-{{ version }}-{{ lang }}.zip">HTML</a> |
118 118
         <a href="http://media.readthedocs.org/pdf/django/{{ rtd_version }}/django.pdf">PDF</a> |
119 119
         <a href="http://media.readthedocs.org/epub/django/{{ rtd_version }}/django.epub">ePub</a>
120 120
       <br>
4  docs/templates/docs/index.html
@@ -2,7 +2,7 @@
2 2
 
3 3
 {% block extrahead %}
4 4
   {{ block.super }}
5  
-  <link rel="stylesheet" href="{{ MEDIA_URL }}css/docs/index.css" type="text/css" charset="utf-8">
  5
+  <link rel="stylesheet" href="{{ STATIC_URL }}css/docs/index.css" type="text/css" charset="utf-8">
6 6
 {% endblock %}
7 7
 
8  
-{% block toc-wrapper %}{% endblock %}
  8
+{% block toc-wrapper %}{% endblock %}
0  media/css/admin.css → static/css/admin.css
File renamed without changes
0  media/css/base.css → static/css/base.css
File renamed without changes
0  media/css/community.css → static/css/community.css
File renamed without changes
0  media/css/docs/docs.css → static/css/docs/docs.css
File renamed without changes
0  media/css/docs/index.css → static/css/docs/index.css
File renamed without changes
0  media/css/documentation.css → static/css/documentation.css
File renamed without changes
0  media/css/download.css → static/css/download.css
File renamed without changes
0  media/css/homepage.css → static/css/homepage.css
File renamed without changes
0  media/css/print.css → static/css/print.css
File renamed without changes
0  media/css/pygments.css → static/css/pygments.css
File renamed without changes
0  media/css/weblog.css → static/css/weblog.css
File renamed without changes
0  media/favicon.ico → static/favicon.ico
File renamed without changes
0  media/img/badges/djangodonated126x54.gif → static/img/badges/djangodonated126x54.gif
File renamed without changes
0  media/img/badges/djangodonated126x54_grey.png → static/img/badges/djangodonated126x54_grey.png
File renamed without changes
0  media/img/badges/djangojoint107x25.gif → static/img/badges/djangojoint107x25.gif
File renamed without changes
0  media/img/badges/djangojoint107x25_grey.gif → static/img/badges/djangojoint107x25_grey.gif
File renamed without changes
0  media/img/badges/djangomade124x25.gif → static/img/badges/djangomade124x25.gif
File renamed without changes
0  media/img/badges/djangomade124x25_grey.gif → static/img/badges/djangomade124x25_grey.gif
File renamed without changes
0  media/img/badges/djangopowered126x54.gif → static/img/badges/djangopowered126x54.gif
File renamed without changes
0  media/img/badges/djangopowered126x54_grey.gif → static/img/badges/djangopowered126x54_grey.gif
File renamed without changes
0  media/img/badges/djangoproject120x24.gif → static/img/badges/djangoproject120x24.gif
File renamed without changes
0  media/img/badges/djangoproject120x25.gif → static/img/badges/djangoproject120x25.gif
File renamed without changes
0  media/img/badges/djangoproject120x25_grey.gif → static/img/badges/djangoproject120x25_grey.gif
File renamed without changes
0  media/img/badges/djangosite100x25.gif → static/img/badges/djangosite100x25.gif
File renamed without changes
0  media/img/badges/djangosite100x25_grey.gif → static/img/badges/djangosite100x25_grey.gif
File renamed without changes
0  media/img/badges/djangosite124x25.gif → static/img/badges/djangosite124x25.gif
File renamed without changes
0  media/img/badges/djangosite80x15.gif → static/img/badges/djangosite80x15.gif
File renamed without changes
0  media/img/badges/djangosite80x15_grey.gif → static/img/badges/djangosite80x15_grey.gif
File renamed without changes
0  media/img/badges/djangosponsor113x25.gif → static/img/badges/djangosponsor113x25.gif
File renamed without changes
0  media/img/badges/djangosponsor113x25_grey.gif → static/img/badges/djangosponsor113x25_grey.gif
File renamed without changes
0  media/img/badges/djangowish126x70.gif → static/img/badges/djangowish126x70.gif
File renamed without changes
0  media/img/badges/djangowish126x70_grey.gif → static/img/badges/djangowish126x70_grey.gif
File renamed without changes
0  media/img/desktops/desktop-43_t.jpg → static/img/desktops/desktop-43_t.jpg
File renamed without changes
0  media/img/desktops/desktop-wide_t.jpg → static/img/desktops/desktop-wide_t.jpg
File renamed without changes
0  media/img/desktops/djangodesktop-1024x768.jpg → static/img/desktops/djangodesktop-1024x768.jpg
File renamed without changes
0  media/img/desktops/djangodesktop-1152x864.jpg → static/img/desktops/djangodesktop-1152x864.jpg
File renamed without changes
0  media/img/desktops/djangodesktop-1280x1024.jpg → static/img/desktops/djangodesktop-1280x1024.jpg
File renamed without changes
0  media/img/desktops/djangodesktop-1600x1200.jpg → static/img/desktops/djangodesktop-1600x1200.jpg
File renamed without changes
0  media/img/desktops/djangodesktop-1680x1050.jpg → static/img/desktops/djangodesktop-1680x1050.jpg
File renamed without changes
0  media/img/desktops/djangodesktop-800x600.jpg → static/img/desktops/djangodesktop-800x600.jpg
File renamed without changes
0  media/img/doc/icons/docicons-behindscenes.gif → static/img/doc/icons/docicons-behindscenes.gif
File renamed without changes
0  media/img/doc/icons/docicons-note.gif → static/img/doc/icons/docicons-note.gif
File renamed without changes
0  media/img/doc/icons/docicons-philosophy.gif → static/img/doc/icons/docicons-philosophy.gif
File renamed without changes
0  media/img/logos/django-logo-negative.eps → static/img/logos/django-logo-negative.eps
File renamed without changes
0  media/img/logos/django-logo-negative.png → static/img/logos/django-logo-negative.png
File renamed without changes
0  media/img/logos/django-logo-negative.svg → static/img/logos/django-logo-negative.svg
File renamed without changes
0  media/img/logos/django-logo-positive.eps → static/img/logos/django-logo-positive.eps
File renamed without changes
0  media/img/logos/django-logo-positive.png → static/img/logos/django-logo-positive.png
File renamed without changes
0  media/img/logos/django-logo-positive.svg → static/img/logos/django-logo-positive.svg
File renamed without changes
0  media/img/site/arrow-head-left.gif → static/img/site/arrow-head-left.gif
File renamed without changes
0  media/img/site/bbd_bg.gif → static/img/site/bbd_bg.gif
File renamed without changes
0  media/img/site/bbd_blogroll.gif → static/img/site/bbd_blogroll.gif
File renamed without changes
0  media/img/site/bbd_code.gif → static/img/site/bbd_code.gif
File renamed without changes
0  media/img/site/bbd_community.gif → static/img/site/bbd_community.gif
File renamed without changes
0  media/img/site/bbd_documentation.gif → static/img/site/bbd_documentation.gif
File renamed without changes
0  media/img/site/bbd_download.gif → static/img/site/bbd_download.gif
File renamed without changes
0  media/img/site/bbd_homepage.gif → static/img/site/bbd_homepage.gif
File renamed without changes
0  media/img/site/bbd_overview.gif → static/img/site/bbd_overview.gif
File renamed without changes
0  media/img/site/bbd_weblog.gif → static/img/site/bbd_weblog.gif
File renamed without changes
0  media/img/site/bbdsm_bg.gif → static/img/site/bbdsm_bg.gif
File renamed without changes
0  media/img/site/bbdsm_bg.gif.1 → static/img/site/bbdsm_bg.gif.1
File renamed without changes
0  media/img/site/djangoapi-logo.gif → static/img/site/djangoapi-logo.gif
File renamed without changes
0  media/img/site/download_bg-left.gif → static/img/site/download_bg-left.gif
File renamed without changes
0  media/img/site/download_bg-right.gif → static/img/site/download_bg-right.gif
File renamed without changes
0  media/img/site/hdr_logo.gif → static/img/site/hdr_logo.gif
File renamed without changes
0  media/img/site/hdr_meetdjango.gif → static/img/site/hdr_meetdjango.gif
File renamed without changes
0  media/img/site/invisible.gif → static/img/site/invisible.gif
File renamed without changes
0  media/img/site/mt.png → static/img/site/mt.png
File renamed without changes
0  media/img/site/nav_bg.gif → static/img/site/nav_bg.gif
File renamed without changes
0  media/img/site/screencast-back.gif → static/img/site/screencast-back.gif
File renamed without changes
0  media/img/site/screencast-next.gif → static/img/site/screencast-next.gif
File renamed without changes
0  media/img/site/somerights20.png → static/img/site/somerights20.png
File renamed without changes
6  templates/base.html
@@ -11,14 +11,14 @@
11 11
     <meta name="Copyright" content="Django Software Foundation" />
12 12
     <meta name="keywords" content="Python, Django, framework, open-source" />
13 13
     <meta name="description" content="Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design." />
14  
-    <link href="{{ MEDIA_URL }}css/{% block cssid %}base{% endblock %}.css" rel="stylesheet" type="text/css" media="screen" />
15  
-    <link href="{{ MEDIA_URL }}css/print.css" rel="stylesheet" type="text/css" media="print" />
  14
+    <link href="{{ STATIC_URL }}css/{% block cssid %}base{% endblock %}.css" rel="stylesheet" type="text/css" media="screen" />
  15
+    <link href="{{ STATIC_URL }}css/print.css" rel="stylesheet" type="text/css" media="print" />
16 16
     {% block extrahead %}{% endblock %}
17 17
   </head>
18 18
   <body id="{% block sectionid %}generic{% endblock %}" class="{% block coltype %}default{% endblock %}">
19 19
   <div id="container">
20 20
     <div id="header">
21  
-      <h1 id="logo"><a href="https://www.djangoproject.com/"><img src="{{ MEDIA_URL }}img/site/hdr_logo.gif" alt="Django" /></a></h1>
  21
+      <h1 id="logo"><a href="https://www.djangoproject.com/"><img src="{{ STATIC_URL }}img/site/hdr_logo.gif" alt="Django" /></a></h1>
22 22
       <ul id="nav-global">
23 23
         <li id="nav-homepage"><a href="https://www.djangoproject.com/">Home</a></li>
24 24
         <li id="nav-download"><a href="https://www.djangoproject.com/download/">Download</a></li>
2  templates/base_code.html
@@ -4,4 +4,4 @@
4 4
 
5 5
 {% block title %}Code{% endblock %}
6 6
 
7  
-{% block billboard %}<h2><a href="https://code.djangoproject.com/"><img src="{{ MEDIA_URL }}img/site/bbd_code.gif" alt="Django source code" /></a></h2>{% endblock %}
  7
+{% block billboard %}<h2><a href="https://code.djangoproject.com/"><img src="{{ STATIC_URL }}img/site/bbd_code.gif" alt="Django source code" /></a></h2>{% endblock %}

0 notes on commit c5b01e7

Please sign in to comment.
Something went wrong with that request. Please try again.