diff --git a/fabfile.py b/fabfile.py
index f1a26c24..5be0e740 100644
--- a/fabfile.py
+++ b/fabfile.py
@@ -237,6 +237,7 @@ def collect_remote_statics(name=None):
'markercluster': 'git://github.com/Leaflet/Leaflet.markercluster.git@master#0.4',
'measure': 'git://github.com/makinacorpus/Leaflet.MeasureControl.git@gh-pages',
'label': 'git://github.com/Leaflet/Leaflet.label.git@master',
+ 'georsstogeojson': 'git://github.com/yohanboniface/GeoRSSToGeoJSON.git@master',
}
with cd(remote_static_dir):
for subdir, path in remote_repositories.iteritems():
diff --git a/umap/settings/base.py b/umap/settings/base.py
index 9b92d146..2a25b430 100644
--- a/umap/settings/base.py
+++ b/umap/settings/base.py
@@ -148,7 +148,8 @@ AUTHENTICATION_BACKENDS += (
#==============================================================================
LEAFLET_STORAGE_ALLOW_ANONYMOUS = False
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}'
}
SITE_URL = "http://umap.org"
UMAP_DEMO_SITE = False
diff --git a/umap/templates/leaflet_storage/js.html b/umap/templates/leaflet_storage/js.html
index e907af02..de18cbbb 100644
--- a/umap/templates/leaflet_storage/js.html
+++ b/umap/templates/leaflet_storage/js.html
@@ -14,12 +14,14 @@
+
{% endcompress %}
{% if locale %}
{% endif %}
{% compress js %}
+
diff --git a/umap/urls.py b/umap/urls.py
index 40651211..3bb27a97 100644
--- a/umap/urls.py
+++ b/umap/urls.py
@@ -17,6 +17,7 @@ urlpatterns = patterns(
(r'^admin/', include(admin.site.urls)),
url('', include('social.apps.django_app.urls', namespace='social')),
url(r'^m/(?P\d+)/$', MapShortUrl.as_view(), name='umap_short_url'),
+ url(r'^ajax-proxy/(?P.+)$', cache_page(60)(views.ajax_proxy), name='ajax-proxy'),
)
urlpatterns += i18n_patterns(
'',
diff --git a/umap/views.py b/umap/views.py
index a28c526f..ee59e079 100644
--- a/umap/views.py
+++ b/umap/views.py
@@ -1,4 +1,6 @@
import simplejson
+import mimetypes
+import urllib2
from django.views.generic import TemplateView
from django.contrib.auth.models import User
@@ -143,7 +145,7 @@ search = Search.as_view()
class MapsShowCase(View):
- def get(*args, **kargs):
+ def get(self, *args, **kwargs):
maps = Map.public.filter(center__distance_gt=(DEFAULT_CENTER, D(km=1))).order_by('-modified_at')[:2000]
def make(m):
@@ -173,3 +175,21 @@ class MapsShowCase(View):
return HttpResponse(simplejson.dumps(geojson))
showcase = MapsShowCase.as_view()
+
+
+class AjaxProxy(View):
+
+ def get(self, *args, **kwargs):
+ # You should not use this in production (use Nginx or so)
+ url = kwargs['url']
+ try:
+ proxied_request = urllib2.urlopen(url)
+ status_code = proxied_request.code
+ mimetype = proxied_request.headers.typeheader or mimetypes.guess_type(url)
+ content = proxied_request.read()
+ except urllib2.HTTPError as e:
+ return HttpResponse(e.msg, status=e.code, mimetype='text/plain')
+ else:
+ return HttpResponse(content, status=status_code, mimetype=mimetype)
+
+ajax_proxy = AjaxProxy.as_view()