Skip to content

Commit 588ab28

Browse files
committed
First step in cleaning up templates
1 parent b40046c commit 588ab28

File tree

3 files changed

+56
-183
lines changed

3 files changed

+56
-183
lines changed

folium/templates/base.html

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
<!DOCTYPE html>
22
<head>
3-
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
3+
{% block head %}
4+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
5+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
6+
7+
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
8+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
9+
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
10+
{% endblock head %}
11+
12+
<style>
13+
{% block style %}
14+
html, body {
15+
width: 100%;
16+
height: 100%;
17+
margin: 0;
18+
padding: 0;
19+
}
20+
{% endblock style %}
21+
</style>
522

6-
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
7-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
8-
9-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
10-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
11-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
12-
13-
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
1423
</head>
1524

1625
<body>
1726
{% block mapdiv %}
1827
<div class="folium-map" id="{{ map_id }}" {{ size }}></div>
19-
{% endblock %}
28+
{% endblock mapdiv %}
2029

2130
<script>
2231
{% block jscode %}
2332

33+
{{ dvf_js }}
34+
{{ d3 }}
35+
{{ vega }}
36+
{{ jquery }}
37+
2438
{{ vega_parse }}
2539

2640
var base_tile = L.tileLayer('{{ Tiles }}', {
@@ -116,8 +130,9 @@
116130

117131
{{ click_pop }}
118132

119-
{% if fit_bounds %}{{ fit_bounds }}{% endif %}
120-
{% endblock %}
133+
{% if fit_bounds %}{{ fit_bounds }}{% endif %}
134+
135+
{% endblock jscode %}
136+
121137
</script>
122-
{% endblock %}
123138
</body>

folium/templates/fol_template.html

Lines changed: 12 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,20 @@
1-
<!DOCTYPE html>
2-
<head>
3-
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
5-
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
6-
7-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
8-
9-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
10-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
11-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
12-
13-
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
14-
15-
<link rel="stylesheet" href="https://rawgit.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.css">
16-
<script src="https://rawi.8713187.xyz/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.js"></script>
17-
1+
{% extends "base.html" %}
2+
{% block head %}
3+
{{ super() }}
184

5+
<!-- Marker Clusters -->
196
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.Default.css">
207
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.css">
218
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster-src.js"></script>
229
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js"></script>
2310

11+
<!-- Awesome markers, needs cleanup -->
12+
<link rel="stylesheet" href="https://rawgit.com/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.css">
13+
<script src="https://rawi.8713187.xyz/lvoogdt/Leaflet.awesome-markers/2.0/develop/dist/leaflet.awesome-markers.js"></script>
14+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
15+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
16+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
17+
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
2418
<link rel="stylesheet" href="https://birdage.github.io/Leaflet.awesome-markers/dist/leaflet.awesome.rotate.css">
2519

26-
{{ dvf_js }}
27-
{{ d3 }}
28-
{{ vega }}
29-
{{ jquery }}
30-
31-
<style>
32-
33-
html, body {
34-
width: 100%;
35-
height: 100%;
36-
margin: 0;
37-
padding: 0;
38-
}
39-
40-
#map {
41-
position:absolute;
42-
top:0;
43-
bottom:0;
44-
right:0;
45-
left:0;
46-
}
47-
48-
</style>
49-
</head>
50-
51-
<body>
52-
53-
<div class="folium-map" id="{{ map_id }}" {{ size }}></div>
54-
55-
<script>
56-
57-
{{ vega_parse }}
58-
59-
var base_tile = L.tileLayer('{{ Tiles }}', {
60-
maxZoom: {{ max_zoom }},
61-
minZoom: {{ min_zoom }},
62-
attribution: '{{ attr }}'
63-
});
64-
65-
var baseLayer = {
66-
"Base Layer": base_tile
67-
};
68-
69-
/*
70-
addition of the wms layers
71-
*/
72-
73-
{% for wms in wms_layers %}
74-
{{ wms }}
75-
{% endfor %}
76-
77-
/*
78-
addition of the tile layers
79-
*/
80-
{% for tile in tile_layers %}
81-
{{ tile }}
82-
{% endfor %}
83-
84-
/*
85-
list of layers to be added
86-
*/
87-
var layer_list = {
88-
{% for data_string in data_layers %}
89-
{{ data_string }}
90-
{% endfor %}
91-
};
92-
93-
/*
94-
Bounding box.
95-
*/
96-
var southWest = L.latLng({{ min_lat }}, {{ min_lon }}),
97-
northEast = L.latLng({{ max_lat }}, {{ max_lon }}),
98-
bounds = L.latLngBounds(southWest, northEast);
99-
100-
/*
101-
Creates the map and adds the selected layers
102-
*/
103-
var map = L.map('{{ map_id }}', {
104-
center:[{{ lat }}, {{ lon }}],
105-
zoom: {{ zoom_level }},
106-
maxBounds: bounds,
107-
layers: [base_tile]
108-
});
109-
110-
L.control.layers(baseLayer, layer_list).addTo(map);
111-
112-
//cluster group
113-
var clusteredmarkers = L.markerClusterGroup();
114-
//section for adding clustered markers
115-
{% for icon, mark, popup, add_mark in cluster_markers %}
116-
{{ icon }}
117-
{{ mark }}
118-
{{ popup }}
119-
{{ add_mark }}
120-
{% endfor %}
121-
//add the clustered markers to the group anyway
122-
map.addLayer(clusteredmarkers);
123-
124-
{% for icon, mark, popup, add_mark in custom_markers %}
125-
{{ icon }}
126-
{{ mark }}
127-
{{ popup }}
128-
{{ add_mark }}
129-
{% endfor %}
130-
131-
{% for mark, popup, add_mark in markers %}
132-
{{ mark }}
133-
{{ popup }}
134-
{{ add_mark }}
135-
{% endfor %}
136-
137-
{% for line, popup, add_line in lines %}
138-
{{ line }}
139-
{{ popup }}
140-
{{ add_line }}
141-
{% endfor %}
142-
143-
{% for multiline, add_multiline in multilines %}
144-
{{ multiline }}
145-
{{ add_multiline }}
146-
{% endfor %}
147-
148-
{{ lat_lng_pop }}
149-
150-
{{ click_pop }}
151-
152-
{% if fit_bounds %}{{ fit_bounds }}{% endif %}
153-
154-
</script>
155-
156-
</body>
20+
{% endblock %}

folium/templates/geojson_template.html

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
<!DOCTYPE html>
2-
<head>
3-
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
5-
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
6-
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
1+
{% extends "base.html" %}
2+
{% block head %}
3+
{{ super() }}
74
<script src="https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script>
85

9-
{{ dvf_js }}
10-
{{ topojson }}
11-
{{ vega }}
12-
{{ jquery }}
13-
14-
<style>
15-
16-
html, body {
17-
width: 100%;
18-
height: 100%;
19-
margin: 0;
20-
padding: 0;
21-
}
6+
{% endblock head %}
227

8+
{% block style %}
9+
{{ super() }}
2310
.legend {
2411
padding: 0px 0px;
2512
font: 10px sans-serif;
@@ -33,14 +20,20 @@
3320
display: none;
3421
}
3522

36-
</style>
37-
</head>
23+
{% endblock style %}
3824

3925
<body>
4026

4127
<div id="map" {{ size }}></div>
4228

4329
<script>
30+
{% block jscode %}
31+
32+
{{ dvf_js }}
33+
{{ d3 }}
34+
{{ vega }}
35+
{{ jquery }}
36+
4437

4538
queue()
4639
{%- for load_path in json_paths %}
@@ -121,6 +114,7 @@
121114
{{ fit_bounds }}
122115

123116
};
117+
{% endblock jscode %}
124118

125119
</script>
126120
</body>

0 commit comments

Comments
 (0)