Use a query string for URL

This commit is contained in:
Yohan Boniface 2014-04-19 12:28:24 +02:00
parent 39f672641c
commit 9bf587a765
4 changed files with 7 additions and 5 deletions

2
fabfile.py vendored
View file

@ -231,7 +231,7 @@ def collect_remote_statics(name=None):
'i18n': 'git://github.com/yohanboniface/Leaflet.i18n.git@master', 'i18n': 'git://github.com/yohanboniface/Leaflet.i18n.git@master',
'csv2geojson': 'git://github.com/mapbox/csv2geojson.git@gh-pages', 'csv2geojson': 'git://github.com/mapbox/csv2geojson.git@gh-pages',
'togeojson': 'git://github.com/mapbox/togeojson.git@gh-pages#v0.4.2', 'togeojson': 'git://github.com/mapbox/togeojson.git@gh-pages#v0.4.2',
'osmtogeojson': 'git://github.com/aaronlidman/osm-and-geojson.git@master', 'osmtogeojson': 'git://github.com/aaronlidman/osm-and-geojson.git@gh-pages',
'loading': 'git://github.com/ebrelsford/Leaflet.loading.git@master#v0.1.6', 'loading': 'git://github.com/ebrelsford/Leaflet.loading.git@master#v0.1.6',
'contextmenu': 'git://github.com/aratcliffe/Leaflet.contextmenu.git@master', 'contextmenu': 'git://github.com/aratcliffe/Leaflet.contextmenu.git@master',
'markercluster': 'git://github.com/Leaflet/Leaflet.markercluster.git@master#0.4', 'markercluster': 'git://github.com/Leaflet/Leaflet.markercluster.git@master#0.4',

View file

@ -149,7 +149,7 @@ AUTHENTICATION_BACKENDS += (
LEAFLET_STORAGE_ALLOW_ANONYMOUS = False LEAFLET_STORAGE_ALLOW_ANONYMOUS = False
LEAFLET_STORAGE_EXTRA_URLS = { LEAFLET_STORAGE_EXTRA_URLS = {
'routing': 'http://map.project-osrm.org/?loc={lat},{lng}&hl={locale}', 'routing': 'http://map.project-osrm.org/?loc={lat},{lng}&hl={locale}',
'ajax_proxy': '/ajax-proxy/{url}' 'ajax_proxy': '/ajax-proxy/?url={url}'
} }
SITE_URL = "http://umap.org" SITE_URL = "http://umap.org"
UMAP_DEMO_SITE = False UMAP_DEMO_SITE = False

View file

@ -17,7 +17,7 @@ urlpatterns = patterns(
(r'^admin/', include(admin.site.urls)), (r'^admin/', include(admin.site.urls)),
url('', include('social.apps.django_app.urls', namespace='social')), url('', include('social.apps.django_app.urls', namespace='social')),
url(r'^m/(?P<pk>\d+)/$', MapShortUrl.as_view(), name='umap_short_url'), url(r'^m/(?P<pk>\d+)/$', MapShortUrl.as_view(), name='umap_short_url'),
url(r'^ajax-proxy/(?P<url>.+)$', cache_page(60)(views.ajax_proxy), name='ajax-proxy'), url(r'^ajax-proxy/$', cache_page(60)(views.ajax_proxy), name='ajax-proxy'),
) )
urlpatterns += i18n_patterns( urlpatterns += i18n_patterns(
'', '',

View file

@ -9,7 +9,7 @@ from django.db.models import Q
from django.contrib.gis.measure import D from django.contrib.gis.measure import D
from django.conf import settings from django.conf import settings
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.http import HttpResponse from django.http import HttpResponse, HttpResponseBadRequest
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -181,7 +181,9 @@ class AjaxProxy(View):
def get(self, *args, **kwargs): def get(self, *args, **kwargs):
# You should not use this in production (use Nginx or so) # You should not use this in production (use Nginx or so)
url = kwargs['url'] url = self.request.GET.get('url')
if not url:
return HttpResponseBadRequest('Missing URL')
try: try:
proxied_request = urllib2.urlopen(url) proxied_request = urllib2.urlopen(url)
status_code = proxied_request.code status_code = proxied_request.code