Commits

David Bennett  committed 3580a15 Merge

Merged in goodtune/django-gmapi/django_staticfiles (pull request #1)

Updates for staticfiles compatibility

  • Participants
  • Parent commits 154f448, 497127f

Comments (0)

Files changed (5)

-recursive-include gmapi/media *.js
+recursive-include gmapi/static *.js
 include AUTHORS
 include LICENSE
 
 
 urlpatterns = patterns('',
-    (r'', include('gmapi.urls.media')), # Use for debugging only.
     (r'^$', 'myapp.views.index'),
 )
 
 
+"""settings.py"""
+INSTALLED_APPS = (
+    ...
+    'gmapi',
+    ...
+)
+
+
 Then in your template put this somewhere:
 
 {{ form.map }}
 </div>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js"></script>
 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
-<script type="text/javascript" src="gmapi/js/jquery.gmapi.js"></script>
+<script type="text/javascript" src="/static/gmapi/js/jquery.gmapi.js"></script>
 
 
 Your map will be displayed as an image, and once/if javascript loads, it will be converted to a javascript map.

File gmapi/forms/widgets.py

 MAPS_URL = getattr(settings, 'GMAPI_MAPS_URL',
                    'http://maps.google.com/maps/api/js?sensor=false')
 
-# Same rules apply as ADMIN_MEDIA_PREFIX.
-# Omit leading slash to make relative to MEDIA_URL.
-MEDIA_PREFIX = getattr(settings, 'GMAPI_MEDIA_PREFIX', 'gmapi/')
-
 
 class GoogleMap(Widget):
     def __init__(self, attrs=None):
             js.append(JQUERY_URL)
         if not self.nomapsjs:
             js.append(MAPS_URL)
-        js.append(urljoin(MEDIA_PREFIX, 'js/jquery.gmapi%s.js' % JSMIN))
+        js.append('gmapi/js/jquery.gmapi%s.js' % JSMIN)
         return Media(js=js)
 
     media = property(_media)

File gmapi/urls/__init__.py

Empty file removed.

File gmapi/urls/media.py

-"""URL pattern for serving static media. Use only to DEBUG!
-
-Add something like the following to the bottom of your urls.py:
-
-from django.conf import settings
-if settings.DEBUG:
-    urlpatterns = patterns('',
-        (r'', include('gmapi.urls.media')),
-    ) + urlpatterns
-"""
-from os import path
-from django.conf import settings
-from django.conf.urls.defaults import *
-from urlparse import urljoin
-
-
-# Same rules apply as regular MEDIA_ROOT.
-MEDIA_ROOT = getattr(settings, 'GMAPI_MEDIA_ROOT',
-                     path.abspath(path.join(path.dirname(
-                     path.dirname(__file__)), 'media', 'gmapi')))
-
-# Same rules apply as ADMIN_MEDIA_PREFIX.
-# Omit leading slash to make relative to MEDIA_URL.
-MEDIA_PREFIX = getattr(settings, 'GMAPI_MEDIA_PREFIX', 'gmapi/')
-
-
-if MEDIA_PREFIX.startswith('http://') or MEDIA_PREFIX.startswith('https://'):
-    urlpatterns = []
-else:
-    urlpatterns = patterns('',
-        (r'^%s(?P<path>.*)$' %
-         urljoin(settings.MEDIA_URL, MEDIA_PREFIX).lstrip('/'),
-         'django.views.static.serve', {'document_root': MEDIA_ROOT}),
-    )