From 4510f01a780403230b91891525565097f2a59627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Schl=C3=BCter?= Date: Sun, 8 Feb 2015 17:09:44 +0100 Subject: [PATCH 1/2] Use OverlappingMarkerSpiderfier --- static/js/visualization.js | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/static/js/visualization.js b/static/js/visualization.js index 94c8d2a..32ce025 100644 --- a/static/js/visualization.js +++ b/static/js/visualization.js @@ -1,5 +1,8 @@ 'use strict'; import $ from 'jquery' + +import './lib/oms.min' + import filter from './filter' import colorUtils from './colors' @@ -17,6 +20,20 @@ class Visualization { this.data = data this.colors = colors + // set up OMS + this.oms = new OverlappingMarkerSpiderfier(map, { + keepSpiderfied: true, + circleSpiralSwitchover: 12, + }) + + var popup = new L.Popup(); + this.oms.addListener('click', function (marker) { + popup.setContent(marker.description.replace(/\n/g, '
')) + popup.setLatLng(marker.getLatLng()) + map.openPopup(popup) + }) + + // set up markers this._markers = new Map() this.setupMarkers() } @@ -123,16 +140,19 @@ class Visualization { var marker = L.marker([incident.lat, incident.lng], options) .addTo(this.map) + marker.description = incident.description + var color = colorUtils.hexToRGB(this._pickColor(incident)) $(marker._icon).css({ borderColor: `rgba(${color[0]},${color[1]},${color[2]},.5)`, backgroundColor: `rgba(${color[0]},${color[1]},${color[2]},.2)` }) + this.oms.addMarker(marker) this._markers.set(incident, marker) }) - return this; + return this } /** @@ -146,12 +166,13 @@ class Visualization { incidents = this.data for (var [incident, marker] of this._markers) - if (incidents.indexOf(incident) == -1) + if (incidents.indexOf(incident) == -1) { this.map.removeLayer(marker) - else - marker - .addTo(this.map) - .bindPopup(incident.description.replace(/\n/g, '
')) + this.oms.removeMarker(marker) + } else { + this.map.addLayer(marker) + this.oms.addMarker(marker) + } return this } From 88e0b27285937fe943c903dfd708049179ceea79 Mon Sep 17 00:00:00 2001 From: Joshua Widmann Date: Mon, 9 Feb 2015 09:49:31 +0100 Subject: [PATCH 2/2] autoprefix style.css and better categorizing. --- analyze.py | 17 +++++++++++++---- static/css/style.css | 11 ++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/analyze.py b/analyze.py index 251a843..7063cf2 100644 --- a/analyze.py +++ b/analyze.py @@ -87,12 +87,21 @@ def get_categories(article_body): """ bad_words = { 'antisemit': 'antisemitism', - 'homophob': 'homophobia', + 'jud': 'antisemitism', + 'jüd': 'antisemitism', + 'homo': 'homophobia', + 'schwul': 'homophobia', + 'lesb': 'homophobia', + 'trans': 'homophobia', 'sexis': 'sexism', - 'rassis': 'racism' + 'frauenfeind': 'sexism', + 'rassis': 'racism', + 'fremdenfeind': 'racism', + 'flüchtling': 'racism', + 'migrant': 'racism' } - found_categories = [bad_words[key] for key in bad_words - if key in article_body.lower()] + found_categories = set([bad_words[key] for key in bad_words + if key in article_body.lower()]) return found_categories def get_geoloc(query): diff --git a/static/css/style.css b/static/css/style.css index 4fdb580..ed795c3 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -90,7 +90,8 @@ a { text-decoration: none; color: #ddd; text-align: center; - transition: background .3s ease; + -webkit-transition: background .3s ease; + transition: background .3s ease; } .year-filter a:hover { @@ -108,7 +109,8 @@ a { .category-filter li { margin: 12px 0; opacity: .5; - transition: opacity .3s ease; + -webkit-transition: opacity .3s ease; + transition: opacity .3s ease; } .category-filter li.active { @@ -166,6 +168,7 @@ a { width: 100%; top: 0; left: 0; + background: -webkit-linear-gradient(top right, rgba(255,255,255,.2), white 50%); background: linear-gradient(to bottom left, rgba(255,255,255,.2), white 50%); display: table-cell; vertical-align: center; @@ -177,7 +180,9 @@ a { left: 50%; width: 90%; max-width: 1024px; - transform: translate(-50%,-50%); + -webkit-transform: translate(-50%,-50%); + -ms-transform: translate(-50%,-50%); + transform: translate(-50%,-50%); } #overlay h1 {