Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing frontend dependencies for leaflet. #3128

Merged
merged 1 commit into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ geonode/static/lib/css/multi-select.css
geonode/static/lib/css/qunit.css
geonode/static/lib/css/select2.css
geonode/static/lib/css/assets.min.css
geonode/static/lib/css/Control.Opacity.css
geonode/static/lib/css/leaflet.fullscreen.css
geonode/static/lib/css/Leaflet.NavBar.css
geonode/static/lib/css/leaflet-measure.css
geonode/static/lib/css/leaflet-plugins.min.css
geonode/static/lib/css/bootstrap-tokenfield.css
geonode/static/lib/js/assets.min.js
geonode/static/lib/js/Control.Opacity.js
geonode/static/lib/js/Leaflet.fullscreen.min.js
geonode/static/lib/js/Leaflet.NavBar.js
geonode/static/lib/js/leaflet-measure.js
geonode/static/lib/js/leaflet-plugins.min.js
geonode/static/lib/js/bootstrap-datepicker.js
geonode/static/lib/js/bootstrap.js
geonode/static/lib/js/jquery-ui.custom.js
Expand Down
44 changes: 13 additions & 31 deletions geonode/layers/templates/layers/layer_leaflet_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
{% leaflet_js %}
{% leaflet_css %}


<link rel="stylesheet" href="/static/lib/opacity/lib/opacity/Control.Opacity.css" />
<script src="/static/lib/opacity/lib/opacity/Control.Opacity.js"></script>

<script src="/static/lib/opacity/lib/jquery/jquery-1.9.1.js"></script>
<script src="/static/lib/opacity/lib/jquery/jquery-ui-1.10.3.custom.min.js"></script>
<link rel="stylesheet" href="/static/lib/opacity/lib/jquery/jquery-ui-1.10.3.custom.min.css" />

<link rel="stylesheet" href="/static/lib/navbar/Leaflet.NavBar.css" />
<script src="/static/lib/navbar/Leaflet.NavBar.js"></script>

<link rel="stylesheet" href="/static/lib/measure/leaflet.measure.css" />
<script src="/static/lib/measure/leaflet.measure.js"></script>
Copy link
Contributor Author

@lucernae lucernae Jun 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted these so it can be included from {% leaflet_js %} tags



<style>
.leaflet-container { /* all maps */
height: 400px;
Expand Down Expand Up @@ -166,7 +151,8 @@
onAdd: function(map) {
var img = L.DomUtil.create('img');

img.src = '../static/img/logo.png';
// Default to Geonode logo
img.src = '{{ STATIC_URL }}/geonode/img/logo.png';
img.style.width = '120px';

return img;
Expand Down Expand Up @@ -222,30 +208,26 @@
overlay_layer["{{ resource.title }}"] = tile_layer;
map.addLayer(tile_layer);
}
layerControl = L.control.layers(
var layerControl = L.control.layers(
base_maps, overlay_layer
).addTo(map);

if (L.control.hasOwnProperty('fullscreen')) {
L.control.fullscreen().addTo(map);
}

if(L.Control.hasOwnProperty('opacitySlider')) {
//adjust opacity
var opacitySlider = new L.Control.opacitySlider();
map.addControl(opacitySlider);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow fullscreen plugin pattern. Only add when the plugin is resolved.


//ajout opacity

var higherOpacity = new L.Control.higherOpacity();
//map.addControl(higherOpacity);
var lowerOpacity = new L.Control.lowerOpacity();
//map.addControl(lowerOpacity);
var opacitySlider = new L.Control.opacitySlider();
map.addControl(opacitySlider);

var opacitySlider = new L.Control.opacitySlider();
opacitySlider.setOpacityLayer(tile_layer);

//ajout info
opacitySlider.setOpacityLayer(tile_layer);
}

L.control.navbar().addTo(map);
if(L.control.hasOwnProperty('navbar')){
//adjust info
L.control.navbar().addTo(map);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow fullscreen plugin pattern. Only add when the plugin is resolved.

}
});
function zoom_to_box(map, bbox) {
var bounds = [
Expand Down
25 changes: 25 additions & 0 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,11 +932,36 @@
'js': 'lib/js/Leaflet.fullscreen.min.js',
'auto-include': True,
},
'leaflet-opacity': {
'css': 'lib/css/Control.Opacity.css',
'js': 'lib/js/Control.Opacity.js',
'auto-include': True,
},
'leaflet-navbar': {
'css': 'lib/css/Leaflet.NavBar.css',
'js': 'lib/js/Leaflet.NavBar.js',
'auto-include': True,
},
'leaflet-measure': {
'css': 'lib/css/leaflet-measure.css',
'js': 'lib/js/leaflet-measure.js',
'auto-include': True,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add these 3 plugins with each css and js when DEBUG_STATIC = True

},
'SRID': 3857,
'RESET_VIEW': False
}

if not DEBUG_STATIC:
# if not DEBUG_STATIC, use minified css and js
LEAFLET_CONFIG['PLUGINS'] = {
'leaflet-plugins': {
'js': 'lib/js/leaflet-plugins.min.js',
'css': 'lib/css/leaflet-plugins.min.css',
'auto-include': True,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use minified plugins, when not in DEBUG_STATIC

}
}

# option to enable/disable resource unpublishing for administrators
RESOURCE_PUBLISHING = False

Expand Down
3 changes: 3 additions & 0 deletions geonode/static/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"angular-leaflet-directive": "0.7.9",
"zeroclipboard": "2.1.5",
"leaflet-fullscreen": "https://github.com/Leaflet/Leaflet.fullscreen.git",
"leaflet-opacity": "https://github.com/lizardtechblog/Leaflet.OpacityControls.git#master",
"leaflet-navbar": "1.0.1",
"leaflet-measure": "2.1.7",
Copy link
Contributor Author

@lucernae lucernae Jun 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added leaflet plugins reference in bower.
This will install the plugin to .components when doing bower install

"eonasdan-bootstrap-datetimepicker": "4.17.43",
"bootstrap-treeview": "1.2.0",
"bootstrap-tokenfield": "0.12.1",
Expand Down
123 changes: 100 additions & 23 deletions geonode/static/gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ module.exports = function(grunt) {
'jquery-tree-multiselect/dist/jquery.tree-multiselect.min.css',
'bootstrap/dist/css/bootstrap.min.css',
'leaflet-fullscreen/dist/leaflet.fullscreen.css',
'leaflet-fullscreen/dist/[email protected]',
'leaflet-fullscreen/dist/fullscreen.png',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move fullscreen*.png to lib/img

'leaflet-opacity/lib/opacity/Control.Opacity.css',
'leaflet-measure/dist/leaflet-measure.css',
'leaflet-navbar/src/Leaflet.NavBar.css',
'eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
'bootstrap-treeview/dist/bootstrap-treeview.min.css',
'bootstrap-tokenfield/dist/css/bootstrap-tokenfield.min.css',
Expand All @@ -100,8 +101,15 @@ module.exports = function(grunt) {
dest: 'lib/img',
src: [
'bootstrap/img/*.png',
'select2*.png', 'select2-spinner.gif',
'select2/select2*.png',
'select2/select2*.gif',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use proper select2 namespace/folder.

'raty/lib/img/*.png',
'jquery-ui/themes/base/images/*',
'leaflet-fullscreen/dist/*.png',
'leaflet-opacity/lib/opacity/images/*',
'leaflet-opacity/lib/jquery/images/*',
'leaflet-measure/dist/images/*',
'leaflet-navbar/src/img/*',
'multi-select/img/switch.png',
'datatables/media/images/*.png',
'jquery-ui/themes/smoothness/images/animated-overlay.gif',
Expand All @@ -117,11 +125,11 @@ module.exports = function(grunt) {
'datatables/media/js/jquery.dataTables.js',
'jquery-timeago/jquery.timeago.js',
'tinysort/src/jquery.tinysort.js',
'raty/lib/jquery.raty.min.js',
'jquery-waypoints/waypoints.min.js',
'jquery-ui/ui/minified/jquery-ui.custom.min.js',
'raty/lib/jquery.raty.js',
'jquery-waypoints/waypoints.js',
'jquery-ui/ui/jquery-ui.custom.js',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to change these, because it is what being referenced in base.html when DEBUG_STATIC = True.
The developers probably need the unminified version for debugging.

'jquery-ajaxprogress/jquery.ajaxprogress.js',
'jquery.ajaxQueue/dist/jquery.ajaxQueue.min.js',
'jquery.ajaxQueue/dist/jquery.ajaxQueue.js',
'multi-select/js/jquery.multi-select.js',
'jquery-tree-multiselect/dist/jquery.tree-multiselect.min.js',
'json2/json2.js',
Expand All @@ -130,11 +138,14 @@ module.exports = function(grunt) {
'requirejs-text/text.js',
'underscore/underscore-min.js',
'qunit/qunit/qunit.js',
'angular/angular.min.js',
'angular/angular.js',
'angular-leaflet-directive/dist/angular-leaflet-directive.min.js',
'bootstrap/dist/js/bootstrap.min.js',
'zeroclipboard/dist/ZeroClipboard.min.js',
'leaflet-fullscreen/dist/Leaflet.fullscreen.min.js',
'leaflet-opacity/lib/opacity/Control.Opacity.js',
'leaflet-measure/dist/leaflet-measure.js',
'leaflet-navbar/src/Leaflet.NavBar.js',
'moment/min/moment-with-locales.min.js',
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
'bootstrap-treeview/dist/bootstrap-treeview.min.js',
Expand Down Expand Up @@ -173,13 +184,68 @@ module.exports = function(grunt) {
development: {
src: ['lib/css/*.css'],
overwrite: true,
replacements: [{
from: /url\((("?images\/)|('(?!(images|\.)))|(?!('|"))|('\.\.\/images\/))/g,
to: 'url(\'../img/'
}, {
from: /(png|gif|jpg)+(\)|'\)|"\))/g,
to: '$1\')'
}]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the pattern in the hope that it will be more readable and understandable.
I also had some issues with the previous pattern didn't replace the text properly for Leaflet.NavBar.css

/*
* We separate each pattern so it will be easy for us to read
* and recognize
*/
replacements: [
/*
* Pattern:
* url('img/image _.png') or url("img/image _.png")
*/
{
from: /url\([\"\']?(img\/)([\w-\.\s@]+)[\"\']?\)/g,
to: 'url("../img/$2")'
},
/*
* Pattern:
* url('images/image _.png') or url("images/image _.png")
*/
{
from: /url\([\"\']?(images\/)([\w-\.\s@]+)[\"\']?\)/g,
to: 'url("../img/$2")'
},
/*
* Pattern:
* url('image/image _.png') or url("image/image _.png")
*/
{
from: /url\([\"\']?(image\/)([\w-\.\s@]+)[\"\']?\)/g,
to: 'url("../img/$2")'
},
/*
* Pattern:
* url('./image _.png') or url("./image _.png")
*/
{
from: /url\([\"\']?(\.\/)([\w-\.\s@]+)[\"\']?\)/g,
to: 'url("../img/$2")'
},
/*
* Pattern:
* url('image _.png') or url("image _.png")
*/
{
from: /url\([\"\']?([\w-\.\s@]+)[\"\']?\)/g,
to: 'url("../img/$1")'
},
/*
* Pattern:
* url('../images/image _.png') or url("../images/image _.png")
*/
{
from: /url\([\"\']?(\.\.\/images\/)([\w-\.\s@]+)[\"\']?\)/g,
to: 'url("../img/$1")'
},
/*
* Pattern:
* url('../image/image _.png') or url("../image/image _.png")
*/
{
from: /url\([\"\']?(\.\.\/image\/)([\w-\.\s@]+)[\"\']?\)/g,
to: 'url("../img/$1")'
}
]
}
},

Expand All @@ -202,10 +268,15 @@ module.exports = function(grunt) {
'lib/css/jquery.dataTables.css',
'lib/css/jquery.tree-multiselect.min.css',
'lib/css/jquery.treefilter.css',
'lib/css/leaflet.fullscreen.css',
'lib/css/L.Control.Pan.css',
'lib/css/multi-select.css',
'lib/css/select2.css'
],
'lib/css/leaflet-plugins.min.css': [
'lib/css/leaflet.fullscreen.css',
'lib/css/Leaflet.NavBar.css',
'lib/css/leaflet-measure.css',
'lib/css/Control.Opacity.css'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minified all used leaflet-plugins.

]
}
}
Expand All @@ -220,12 +291,12 @@ module.exports = function(grunt) {
files: {
'lib/js/assets.min.js': [
'lib/js/jquery.min.js',
'lib/js/jquery-ui.custom.min.js',
'lib/js/jquery-ui.custom.js',
'lib/js/jquery.dataTables.js',
'lib/js/jquery.raty.min.js',
'lib/js/jquery.raty.js',
'lib/js/jquery.timeago.js',
'lib/js/json2.js',
'lib/js/waypoints.min.js',
'lib/js/waypoints.js',
'lib/js/select2.min.js',
'lib/js/moment-with-locales.min.js',
'lib/js/fastselect.standalone.min.js',
Expand All @@ -235,19 +306,25 @@ module.exports = function(grunt) {
'lib/js/bootstrap-treeview.min.js',
'lib/js/bootstrap-select.min.js',
'lib/js/bootstrap-wysihtml5-0.0.2.min.js',
'lib/js/angular.min.js',
'lib/js/jquery.ajaxprogress.js',
'lib/js/jquery.ajaxQueue.min.js',
'lib/js/jquery.ajaxQueue.js',
'lib/js/jquery.multi-select.js',
'lib/js/jquery.tree-multiselect.min.js',
'lib/js/jquery.treefilter-min.js',
'lib/js/angular.js',
'lib/js/angular-leaflet-directive.min.js',
'lib/js/ZeroClipboard.min.js'
],
'lib/js/jquery.js': ['lib/js/jquery.min.js'],
'lib/js/require.js': ['lib/js/require.js'],
'lib/js/text.js': ['lib/js/text.js'],
'lib/js/underscore.js': ['lib/js/underscore-min.js']
'lib/js/underscore.js': ['lib/js/underscore-min.js'],
'lib/js/leaflet-plugins.min.js': [
'lib/js/Leaflet.fullscreen.min.js',
'lib/js/Leaflet.NavBar.js',
'lib/js/leaflet-measure.js',
'lib/js/Control.Opacity.js'
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minified all used leaflet-plugins.

}
}
},
Expand Down Expand Up @@ -278,6 +355,6 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['jshint', 'less:development', 'concat:bootstrap', 'copy', 'replace']);

// build production
grunt.registerTask('production', ['jshint', 'less:production', 'concat:bootstrap', 'copy', 'cssmin', 'uglify' ]);
grunt.registerTask('production', ['jshint', 'less:production', 'concat:bootstrap', 'copy', 'replace', 'cssmin', 'uglify' ]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include replace task for production task


};
2 changes: 1 addition & 1 deletion geonode/static/lib/css/assets.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions geonode/static/lib/css/leaflet-plugins.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 0 additions & 40 deletions geonode/static/lib/css/leaflet.fullscreen.css

This file was deleted.

Binary file added geonode/static/lib/img/arrow-left_000000_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/arrow-left_bbbbbb_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/arrow-right_000000_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/arrow-right_bbbbbb_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/cancel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/higherOpacity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/higherOpacity64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/home_000000_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/home_bbbbbb_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/lowerOpacity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/lowerOpacity64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/rulers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added geonode/static/lib/img/trash.png
Binary file added geonode/static/lib/img/[email protected]
Loading