Skip to content

Commit 545315a

Browse files
committed
Popups allow unicode.
1 parent f3374b5 commit 545315a

File tree

10 files changed

+42
-25
lines changed

10 files changed

+42
-25
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
0.1.4.dev
22
~~~~~~~~~
3+
- Popups allow unicode. @apatil
34
- Custom popup width width. @ocefpaf
45
- Support multiPolyLine. @scari
56
- Added max and min zoom keywords. @Paradoxeuh
67

8+
79
Bug Fixes
810

911
- Remove margins from leaflet-tiles (Fixes #64). @lennart0901

folium/folium.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
from folium import utilities
2323
from folium.six import text_type, binary_type, iteritems
2424

25+
import sys
26+
2527

2628
ENV = Environment(loader=PackageLoader('folium', 'templates'))
2729

@@ -616,10 +618,21 @@ def _popup_render(self, popup=None, mk_name=None, count=None,
616618
if not popup_on:
617619
return 'var no_pop = null;'
618620
else:
619-
if isinstance(popup, str):
621+
if sys.version_info >= (3,0):
622+
utype, stype = str, bytes
623+
else:
624+
utype, stype = unicode, str
625+
626+
if isinstance(popup, (utype, stype)):
620627
popup_temp = self.env.get_template('simple_popup.js')
628+
if isinstance(popup, utype):
629+
popup_txt = popup.encode('ascii', 'xmlcharrefreplace')
630+
else:
631+
popup_txt = popup
632+
if sys.version_info >= (3,0):
633+
popup_txt = popup_txt.decode()
621634
return popup_temp.render({'pop_name': mk_name + str(count),
622-
'pop_txt': json.dumps(popup),
635+
'pop_txt': json.dumps(str(popup_txt)),
623636
'width': width})
624637
elif isinstance(popup, tuple):
625638
#Update template with JS libs
@@ -653,6 +666,8 @@ def _popup_render(self, popup=None, mk_name=None, count=None,
653666
'max_width': max_width,
654667
'json_out': json_out,
655668
'vega_id': vega_id})
669+
else:
670+
raise TypeError("Unrecognized popup type: {!r}".format(popup))
656671

657672
@iter_obj('geojson')
658673
def geo_json(self, geo_path=None, geo_str=None, data_out='data.json',

folium/iconTest.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
22
<head>
33
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4-
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
5-
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
4+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
5+
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
66

7-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
7+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
88

99
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
1010
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">

folium/templates/d3_ref.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
1+
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>

folium/templates/fol_template.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<!DOCTYPE html>
22
<head>
33
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4-
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
5-
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
4+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
5+
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
66

7-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
7+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
88

99
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
1010
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
1111
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
1212

1313
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
1414

15-
<link rel="stylesheet" href="https://rawgit.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.css">
16-
<script src="https://rawgithub.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.js"></script>
15+
<link rel="stylesheet" href="//rawgit.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.css">
16+
<script src="//rawgithub.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.js"></script>
1717

1818

1919
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.Default.css">
2020
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.css">
2121
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster-src.js"></script>
2222
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js"></script>
2323

24-
<link rel="stylesheet" href="http://birdage.github.io/Leaflet.awesome-markers/dist/leaflet.awesome.rotate.css">
24+
<link rel="stylesheet" href="//birdage.github.io/Leaflet.awesome-markers/dist/leaflet.awesome.rotate.css">
2525

2626
{{ dvf_js }}
2727
{{ d3 }}

folium/templates/geojson_template.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
22
<head>
33
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4-
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
5-
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
6-
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
7-
<script src="http://d3js.org/queue.v1.min.js"></script>
4+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
5+
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
6+
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
7+
<script src="//cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script>
88

99
{{ dvf_js }}
1010
{{ topojson }}

folium/templates/ipynb_init_css.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
1+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
22
<style>
33
.leaflet-popup-content {
44
color: black !important;

folium/templates/ipynb_init_js.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
var load_folium_libs = function(){
1313
console.log('Loading all Folium libraries...')
14-
$.getScript("http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js", function(){
15-
$.getScript('https://wrobstory.github.io/leaflet-dvf/leaflet-dvf.markers.min.js', function(){
14+
$.getScript("//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js", function(){
15+
$.getScript('//cdnjs.cloudflare.com/ajax/libs/leaflet-dvf/0.2/leaflet-dvf.markers.min.js', function(){
1616
if (window['vg'] === undefined){
17-
$.getScript("http://wrobstory.github.io/vega/vega.v1.3.3.js", function(){
17+
$.getScript("//cdnjs.cloudflare.com/ajax/libs/vega/1.4.3/vega.min.js", function(){
1818
load_folium_charts();
1919
});
2020
} else {
@@ -27,9 +27,9 @@
2727
if(typeof define === "function" && define.amd){
2828
var load_paths = {
2929
paths: {
30-
topojson:'http://d3js.org/topojson.v1.min',
31-
queue: 'http://d3js.org/queue.v1.min',
32-
d3: 'http://d3js.org/d3.v3.min'
30+
topojson:'https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.9/topojson.min.js',
31+
queue: 'https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js',
32+
d3: 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js'
3333
}
3434
};
3535
var libs = ['d3', 'queue', 'topojson'];

folium/templates/topojson_ref.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<script src="http://d3js.org/topojson.v1.min.js"></script>
1+
<script src="//cdnjs.cloudflare.com/ajax/libs/topojson/1.6.9/topojson.min.js"></script>

folium/templates/vega_ref.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<script src="http://trifacta.github.io/vega/vega.js"></script>
1+
<script src="//cdnjs.cloudflare.com/ajax/libs/vega/1.4.3/vega.min.js"></script>

0 commit comments

Comments
 (0)