Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved default admin from media to django/conf/admin_media, so Django …

…is able to introspect their location, in preparation for #76

git-svn-id: http://code.djangoproject.com/svn/django/trunk@185 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a7506973af918e177d102328c6db52bc9e0f43b4 1 parent 34f749e
@adrianholovaty adrianholovaty authored
Showing with 48 additions and 3 deletions.
  1. +2 −2 django/bin/django-admin.py
  2. 0  {media → django/conf/admin_media}/css/base.css
  3. 0  {media → django/conf/admin_media}/css/changelists.css
  4. 0  {media → django/conf/admin_media}/css/global.css
  5. 0  {media → django/conf/admin_media}/img/admin/arrow-down.gif
  6. 0  {media → django/conf/admin_media}/img/admin/arrow-up.gif
  7. 0  {media → django/conf/admin_media}/img/admin/changelist-bg.gif
  8. 0  {media → django/conf/admin_media}/img/admin/chooser-bg.gif
  9. 0  {media → django/conf/admin_media}/img/admin/chooser_stacked-bg.gif
  10. 0  {media → django/conf/admin_media}/img/admin/default-bg-reverse.gif
  11. 0  {media → django/conf/admin_media}/img/admin/default-bg.gif
  12. 0  {media → django/conf/admin_media}/img/admin/icon-no.gif
  13. 0  {media → django/conf/admin_media}/img/admin/icon-yes.gif
  14. 0  {media → django/conf/admin_media}/img/admin/icon_addlink.gif
  15. 0  {media → django/conf/admin_media}/img/admin/icon_alert.gif
  16. 0  {media → django/conf/admin_media}/img/admin/icon_calendar.gif
  17. 0  {media → django/conf/admin_media}/img/admin/icon_changelink.gif
  18. 0  {media → django/conf/admin_media}/img/admin/icon_clock.gif
  19. 0  {media → django/conf/admin_media}/img/admin/icon_deletelink.gif
  20. 0  {media → django/conf/admin_media}/img/admin/icon_error.gif
  21. 0  {media → django/conf/admin_media}/img/admin/icon_searchbox.png
  22. 0  {media → django/conf/admin_media}/img/admin/icon_success.gif
  23. 0  {media → django/conf/admin_media}/img/admin/nav-bg-grabber.gif
  24. 0  {media → django/conf/admin_media}/img/admin/nav-bg-reverse.gif
  25. 0  {media → django/conf/admin_media}/img/admin/nav-bg.gif
  26. 0  {media → django/conf/admin_media}/img/admin/selector-add.gif
  27. 0  {media → django/conf/admin_media}/img/admin/selector-addall.gif
  28. 0  {media → django/conf/admin_media}/img/admin/selector-remove.gif
  29. 0  {media → django/conf/admin_media}/img/admin/selector-removeall.gif
  30. 0  {media → django/conf/admin_media}/img/admin/selector-search.gif
  31. 0  {media → django/conf/admin_media}/img/admin/selector_stacked-add.gif
  32. 0  {media → django/conf/admin_media}/img/admin/selector_stacked-remove.gif
  33. 0  {media → django/conf/admin_media}/img/admin/tool-left.gif
  34. 0  {media → django/conf/admin_media}/img/admin/tool-left_over.gif
  35. 0  {media → django/conf/admin_media}/img/admin/tool-right.gif
  36. 0  {media → django/conf/admin_media}/img/admin/tool-right_over.gif
  37. 0  {media → django/conf/admin_media}/img/admin/tooltag-add.gif
  38. 0  {media → django/conf/admin_media}/img/admin/tooltag-add_over.gif
  39. 0  {media → django/conf/admin_media}/img/admin/tooltag-arrowright.gif
  40. 0  {media → django/conf/admin_media}/img/admin/tooltag-arrowright_over.gif
  41. 0  {media → django/conf/admin_media}/js/SelectBox.js
  42. 0  {media → django/conf/admin_media}/js/SelectFilter.js
  43. 0  {media → django/conf/admin_media}/js/SelectFilter2.js
  44. 0  {media → django/conf/admin_media}/js/admin/CollapsedFieldsets.js
  45. 0  {media → django/conf/admin_media}/js/admin/DateTimeShortcuts.js
  46. 0  {media → django/conf/admin_media}/js/admin/RelatedObjectLookups.js
  47. 0  {media → django/conf/admin_media}/js/admin/add_calendars.js
  48. 0  {media → django/conf/admin_media}/js/admin/ordering.js
  49. 0  {media → django/conf/admin_media}/js/calendar.js
  50. 0  {media → django/conf/admin_media}/js/core.js
  51. 0  {media → django/conf/admin_media}/js/dateparse.js
  52. 0  {media → django/conf/admin_media}/js/getElementsBySelector.js
  53. 0  {media → django/conf/admin_media}/js/timeparse.js
  54. 0  {media → django/conf/admin_media}/js/urlify.js
  55. +42 −0 django/core/handlers/wsgi.py
  56. +4 −1 setup.py
View
4 django/bin/django-admin.py
@@ -365,13 +365,13 @@ def startapp(app_name, directory):
def runserver(port):
"Starts a lightweight Web server for development."
from django.core.servers.basehttp import run, WSGIServerException
- from django.core.handlers.wsgi import WSGIHandler
+ from django.core.handlers.wsgi import AdminMediaHandler, WSGIHandler
if not port.isdigit():
sys.stderr.write("Error: %r is not a valid port number.\n" % port)
sys.exit(1)
print "Starting server on port %s. Go to http://127.0.0.1:%s/ for Django." % (port, port)
try:
- run(int(port), WSGIHandler())
+ run(int(port), AdminMediaHandler(WSGIHandler()))
except WSGIServerException, e:
# Use helpful error messages instead of ugly tracebacks.
ERRORS = {
View
0  media/css/base.css → django/conf/admin_media/css/base.css
File renamed without changes
View
0  media/css/changelists.css → django/conf/admin_media/css/changelists.css
File renamed without changes
View
0  media/css/global.css → django/conf/admin_media/css/global.css
File renamed without changes
View
0  media/img/admin/arrow-down.gif → django/conf/admin_media/img/admin/arrow-down.gif
File renamed without changes
View
0  media/img/admin/arrow-up.gif → django/conf/admin_media/img/admin/arrow-up.gif
File renamed without changes
View
0  media/img/admin/changelist-bg.gif → django/conf/admin_media/img/admin/changelist-bg.gif
File renamed without changes
View
0  media/img/admin/chooser-bg.gif → django/conf/admin_media/img/admin/chooser-bg.gif
File renamed without changes
View
0  media/img/admin/chooser_stacked-bg.gif → ...conf/admin_media/img/admin/chooser_stacked-bg.gif
File renamed without changes
View
0  media/img/admin/default-bg-reverse.gif → ...conf/admin_media/img/admin/default-bg-reverse.gif
File renamed without changes
View
0  media/img/admin/default-bg.gif → django/conf/admin_media/img/admin/default-bg.gif
File renamed without changes
View
0  media/img/admin/icon-no.gif → django/conf/admin_media/img/admin/icon-no.gif
File renamed without changes
View
0  media/img/admin/icon-yes.gif → django/conf/admin_media/img/admin/icon-yes.gif
File renamed without changes
View
0  media/img/admin/icon_addlink.gif → django/conf/admin_media/img/admin/icon_addlink.gif
File renamed without changes
View
0  media/img/admin/icon_alert.gif → django/conf/admin_media/img/admin/icon_alert.gif
File renamed without changes
View
0  media/img/admin/icon_calendar.gif → django/conf/admin_media/img/admin/icon_calendar.gif
File renamed without changes
View
0  media/img/admin/icon_changelink.gif → ...go/conf/admin_media/img/admin/icon_changelink.gif
File renamed without changes
View
0  media/img/admin/icon_clock.gif → django/conf/admin_media/img/admin/icon_clock.gif
File renamed without changes
View
0  media/img/admin/icon_deletelink.gif → ...go/conf/admin_media/img/admin/icon_deletelink.gif
File renamed without changes
View
0  media/img/admin/icon_error.gif → django/conf/admin_media/img/admin/icon_error.gif
File renamed without changes
View
0  media/img/admin/icon_searchbox.png → django/conf/admin_media/img/admin/icon_searchbox.png
File renamed without changes
View
0  media/img/admin/icon_success.gif → django/conf/admin_media/img/admin/icon_success.gif
File renamed without changes
View
0  media/img/admin/nav-bg-grabber.gif → django/conf/admin_media/img/admin/nav-bg-grabber.gif
File renamed without changes
View
0  media/img/admin/nav-bg-reverse.gif → django/conf/admin_media/img/admin/nav-bg-reverse.gif
File renamed without changes
View
0  media/img/admin/nav-bg.gif → django/conf/admin_media/img/admin/nav-bg.gif
File renamed without changes
View
0  media/img/admin/selector-add.gif → django/conf/admin_media/img/admin/selector-add.gif
File renamed without changes
View
0  media/img/admin/selector-addall.gif → ...go/conf/admin_media/img/admin/selector-addall.gif
File renamed without changes
View
0  media/img/admin/selector-remove.gif → ...go/conf/admin_media/img/admin/selector-remove.gif
File renamed without changes
View
0  media/img/admin/selector-removeall.gif → ...conf/admin_media/img/admin/selector-removeall.gif
File renamed without changes
View
0  media/img/admin/selector-search.gif → ...go/conf/admin_media/img/admin/selector-search.gif
Diff not rendered
View
0  media/img/admin/selector_stacked-add.gif → ...nf/admin_media/img/admin/selector_stacked-add.gif
Diff not rendered
View
0  media/img/admin/selector_stacked-remove.gif → ...admin_media/img/admin/selector_stacked-remove.gif
Diff not rendered
View
0  media/img/admin/tool-left.gif → django/conf/admin_media/img/admin/tool-left.gif
Diff not rendered
View
0  media/img/admin/tool-left_over.gif → django/conf/admin_media/img/admin/tool-left_over.gif
Diff not rendered
View
0  media/img/admin/tool-right.gif → django/conf/admin_media/img/admin/tool-right.gif
Diff not rendered
View
0  media/img/admin/tool-right_over.gif → ...go/conf/admin_media/img/admin/tool-right_over.gif
Diff not rendered
View
0  media/img/admin/tooltag-add.gif → django/conf/admin_media/img/admin/tooltag-add.gif
Diff not rendered
View
0  media/img/admin/tooltag-add_over.gif → ...o/conf/admin_media/img/admin/tooltag-add_over.gif
Diff not rendered
View
0  media/img/admin/tooltag-arrowright.gif → ...conf/admin_media/img/admin/tooltag-arrowright.gif
Diff not rendered
View
0  media/img/admin/tooltag-arrowright_over.gif → ...admin_media/img/admin/tooltag-arrowright_over.gif
Diff not rendered
View
0  media/js/SelectBox.js → django/conf/admin_media/js/SelectBox.js
File renamed without changes
View
0  media/js/SelectFilter.js → django/conf/admin_media/js/SelectFilter.js
File renamed without changes
View
0  media/js/SelectFilter2.js → django/conf/admin_media/js/SelectFilter2.js
File renamed without changes
View
0  media/js/admin/CollapsedFieldsets.js → ...o/conf/admin_media/js/admin/CollapsedFieldsets.js
File renamed without changes
View
0  media/js/admin/DateTimeShortcuts.js → ...go/conf/admin_media/js/admin/DateTimeShortcuts.js
File renamed without changes
View
0  media/js/admin/RelatedObjectLookups.js → ...conf/admin_media/js/admin/RelatedObjectLookups.js
File renamed without changes
View
0  media/js/admin/add_calendars.js → django/conf/admin_media/js/admin/add_calendars.js
File renamed without changes
View
0  media/js/admin/ordering.js → django/conf/admin_media/js/admin/ordering.js
File renamed without changes
View
0  media/js/calendar.js → django/conf/admin_media/js/calendar.js
File renamed without changes
View
0  media/js/core.js → django/conf/admin_media/js/core.js
File renamed without changes
View
0  media/js/dateparse.js → django/conf/admin_media/js/dateparse.js
File renamed without changes
View
0  media/js/getElementsBySelector.js → django/conf/admin_media/js/getElementsBySelector.js
File renamed without changes
View
0  media/js/timeparse.js → django/conf/admin_media/js/timeparse.js
File renamed without changes
View
0  media/js/urlify.js → django/conf/admin_media/js/urlify.js
File renamed without changes
View
42 django/core/handlers/wsgi.py
@@ -240,3 +240,45 @@ def _get_traceback(self):
"Helper function to return the traceback as a string"
import sys, traceback
return '\n'.join(traceback.format_exception(*sys.exc_info()))
+
+class AdminMediaHandler:
+ """
+ WSGI middleware that intercepts calls to the admin media directory, as
+ defined by the ADMIN_MEDIA_PREFIX setting, and serves those images.
+ Use this ONLY LOCALLY, for development! This hasn't been tested for
+ security and is not super efficient.
+ """
+ def __init__(self, application):
+ from django.conf import settings
+ import django
+ self.application = application
+ self.media_dir = django.__path__[0] + '/conf/admin_templates'
+ self.media_url = settings.ADMIN_MEDIA_PREFIX
+
+ def __call__(self, environ, start_response):
+ import os.path
+
+ # Ignore requests that aren't under ADMIN_MEDIA_PREFIX.
+ if not environ['PATH_INFO'].startswith(self.media_url):
+ return self.application(environ, start_response)
+
+ # Find the admin file and serve it up, if it exists and is readable.
+ file_path = os.path.join(self.media_dir, environ['PATH_INFO'][1:])
+ if not os.path.exists(file_path):
+ status = '404 NOT FOUND'
+ headers = {'Content-type': 'text/plain'}
+ output = ['Page not found: %s' % file_path]
+ else:
+ try:
+ fp = open(file_path, 'r')
+ except IOError:
+ status = '401 UNAUTHORIZED'
+ headers = {'Content-type': 'text/plain'}
+ output = ['Permission denied: %s' % file_path]
+ else:
+ status = '200 OK'
+ headers = {}
+ output = [fp.read()]
+ fp.close()
+ start_response(status, headers.items())
+ return output
View
5 setup.py
@@ -13,7 +13,10 @@
license = 'BSD',
packages = find_packages(),
package_data = {
- 'django.conf': ['admin_templates/*.html', 'admin_templates/doc/*.html'],
+ 'django.conf': ['admin_templates/*.html', 'admin_templates/doc/*.html',
+ 'admin_media/css/*.css', 'admin_media/img/admin/*.gif',
+ 'admin_media/img/admin/*.png', 'admin_media/js/*.js',
+ 'admin_media/js/admin/*js'],
},
scripts = ['django/bin/django-admin.py'],
)
Please sign in to comment.
Something went wrong with that request. Please try again.