Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
Merge branch '967/map-other'
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Mar 30, 2017
2 parents 6f23805 + eb6fcf2 commit 75bee17
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 45 deletions.
10 changes: 5 additions & 5 deletions census/static/scripts/map/ui.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable */
define(['leaflet', 'proj4', 'proj4leaflet', 'leaflet_zoommin', 'leaflet_label', 'jquery', 'pubsub',
'lodash', 'chroma', 'marked', 'data'],
function(leaflet, proj4, proj4leaflet, leaflet_zoommin, leaflet_label, $, pubsub, _, chroma,
function(leaflet, proj4, proj4leaflet, leaflet_zoommin, leaflet_label, $, pubsub, _, chroma,
marked, data) {

proj4.defs("EPSG:3410", "+proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +a=6371228 +b=6371228 +units=m +no_defs");

var $container = $('.odi-vis.odi-vis-choropleth'),
var $container = $('.odi-vis.odi-vis-choropleth'),
$tools = $('.odi-vis-tools'),
$miniLegend = $('.odi-vis-legend ul'),
$fullLegend = $('.odi-vis-legend-full ul'),
Expand Down Expand Up @@ -397,7 +397,7 @@ define(['leaflet', 'proj4', 'proj4leaflet', 'leaflet_zoommin', 'leaflet_label',
// calculate for this dataset/year/place from entries data
match = _.find(dataStore.entries, {
'place': feature.properties.iso_a2.toLowerCase(),
'year': uiState.filter.year,
'year': parseInt(uiState.filter.year, 10),
'dataset': uiState.filter.dataset
});
if (match) {
Expand Down Expand Up @@ -606,7 +606,7 @@ define(['leaflet', 'proj4', 'proj4leaflet', 'leaflet_zoommin', 'leaflet_label',
// calculate for this dataset/year/place from entries data
match = _.find(dataStore.entries, {
'place': place.id,
'year': uiState.filter.year,
'year': parseInt(uiState.filter.year, 10),
'dataset': uiState.filter.dataset
});
if (match) {
Expand Down Expand Up @@ -672,7 +672,7 @@ define(['leaflet', 'proj4', 'proj4leaflet', 'leaflet_zoommin', 'leaflet_label',
// calculate for this dataset/year/place from entries data
match = _.find(dataStore.entries, {
'place': properties.iso_a2.toLowerCase(),
'year': uiState.filter.year,
'year': parseInt(uiState.filter.year, 10),
'dataset': uiState.filter.dataset
});
previousMatch = _.find(dataStore.entries, {
Expand Down
24 changes: 1 addition & 23 deletions census/views/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,29 +191,7 @@
</script>
<script data-main="/scripts/site" src="/bower_components/requirejs/require.js"></script>

{% if site.settings.google_analytics_key or google_analytics_key %}
<!-- configured google analytics specific to this deployment -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ site.settings.google_analytics_key or google_analytics_key}}']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
{% endif %}
<!-- common tracking code for all -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
{% include 'includes/analytics.html' %}

ga('create', 'UA-33874954-24', 'okfn.org');
ga('send', 'pageview');
</script>
</body>
</html>
8 changes: 3 additions & 5 deletions census/views/embed/embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@
previousYear = 2015,
// years = {{ scope.odi.years|dump|safe }},
years = {{ map.years|dump|safe }},
// sitename = {{ SITENAME|dump|safe }},
sitename = 'placeholder for site name',
// sponsor = {{ scope.odi.sponsor.name|dump|safe }};
sponsor = 'placeholder for sponsor';
sitename = {{ site_title|dump|safe }},
sponsor = {{ map.sponsor.name|dump|safe }};
</script>
{% block head_scripts %}{% endblock head_scripts %}
</head>
<body>
{% block content %}{% endblock content %}
{% block body_scripts %}
{# {% include '_analytics.html' %} #}
{% include 'includes/analytics.html' %}
{% endblock body_scripts %}
</body>
</html>
6 changes: 2 additions & 4 deletions census/views/embed/map_embed.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends 'embed/embed.html' %}

{#{% from '_scope.html' import scope with context %}#}

{% block head_css %}
{{ super() }}
<link rel="stylesheet" type="text/css" href="{{ site_url }}/css/map.css" />
Expand All @@ -17,11 +15,11 @@
<div class="odi-vis-meta">
<div class="odi-vis-meta-left">
<div class="odi-vis-icon">
<a target="_parent" href="{{ scope.odi.sponsor.domain }}" title="{{ gettext('Go to the %(sitename)s website', sitename=scope.odi.sponsor.name) }}">
<a target="_parent" href="{{ map.sponsor.domain }}" title="{{ gettext('Go to the %(sitename)s website', sitename=map.sponsor.name) }}">
<img src="{{ site_url }}/css/images/logo.png" />
</a>
</div>
<a class="odi-vis-name" target="_parent" href="{{ scope.odi.sponsor.domain }}" title="{{ gettext('Go to the %(sitename)s website', sitename=scope.odi.sponsor.name) }}">{{ scope.odi.sponsor.name }}</a>
<a class="odi-vis-name" target="_parent" href="{{ map.sponsor.domain }}" title="{{ gettext('Go to the %(sitename)s website', sitename=map.sponsor.name) }}">{{ map.sponsor.name }}</a>
</div>
<div class="odi-vis-meta-right">

Expand Down
2 changes: 1 addition & 1 deletion census/views/entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h6>{{ gettext("See other years") }}</h6>
{% if is_index %}
<div class="col-md-6">
<div id="map-container">
<iframe width="100%" height="360px" src="http://index.okfn.org/vis/map/embed/?embed_width=100%&amp;embed_height=360px&amp;filter_year=2015&amp;filter_dataset=companies&amp;panel_tools=false&amp;panel_share=false&amp;embed_title=United Kingdom ; Company Register ; 2015&amp;map_place=gb" frameborder="0"></iframe>
{% include 'includes/dataviews/embed_map.html' %}
</div>
</div>
{% endif %}
Expand Down
24 changes: 24 additions & 0 deletions census/views/includes/analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% if site.settings.google_analytics_key or google_analytics_key %}
<!-- configured google analytics specific to this deployment -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ site.settings.google_analytics_key or google_analytics_key}}']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
{% endif %}
<!-- common tracking code for all -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-33874954-24', 'okfn.org');
ga('send', 'pageview');
</script>
13 changes: 7 additions & 6 deletions index/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,19 @@ Metalsmith(__dirname)
// format function needs to be available in templates
format: i18n.format,
site_url: baseUrl,
map: { // Initial map presets.
map: { // Initial map presets. May be overridden in godiDataFiles.
embed_width: '100%',
embed_height: '300px',
// filter_year: filter_year,
filter_year: year,
// filter_dataset: filter_dataset,
filter_dataset: 'all',
years: [year],
panel_tools: 'true',
panel_share: 'true',
// map_place: map_place
map_place: ''
map_place: '',
sponsor: {
name: 'Open Knowledge',
domain: 'https://okfn.org/'
}
}
})
.source('./src')
Expand All @@ -218,7 +219,7 @@ Metalsmith(__dirname)
questionsApi: `${surveyUrl}/api/questions.json`,
placesApi: `${surveyUrl}/api/places/score/${year}.json`
}, {json: true}))
.use(godiApiDataToFiles()) // Set api stored on metaddata, retrieved using metalsmith-request above, to files.
.use(godiApiDataToFiles()) // Set api stored on metadata, retrieved using metalsmith-request above, to files.
.use(godiGetData({domain: domain, year: year})) // Populate metadata with data from Survey
.use(jsonToFiles({use_metadata: true}))
.use(paths({property: 'paths', directoryIndex: 'index.html'}))
Expand Down
23 changes: 22 additions & 1 deletion index/metalsmith-godi-updatedatafiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,39 @@ function plugin(options) {
file.place.id);
}

file.map = _.clone(metadata.map);
file.map.map_place = file.place.id;
file.map.filter_dataset = file.dataset.id;
file.map.panel_tools = false;
file.map.panel_share = false;
file.map.embed_title = `${file.place.name} ; ${file.dataset.name} ; ${file.map.filter_year}`;

delete file.data;
}

if (file.metadata_key === 'places') {
file.place = file.data;
file.stats = file.data.stats;

file.map = _.clone(metadata.map);
file.map.map_place = file.place.id;
file.map.panel_tools = false;
file.map.panel_share = false;
file.map.embed_title = `${file.place.name} ; ${file.map.filter_year}`;

delete file.data;
}

if (file.metadata_key === 'datasets') {
file.dataset = file.data;
file.stats = file.data.datas;
file.stats = file.data.stats;

file.map = _.clone(metadata.map);
file.map.filter_dataset = file.dataset.id;
file.map.panel_tools = false;
file.map.panel_share = false;
file.map.embed_title = `${file.dataset.name} ; ${file.map.filter_year}`;

delete file.data;
}
}
Expand Down

0 comments on commit 75bee17

Please sign in to comment.