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

Commit

Permalink
[#853] Use share_button.html include
Browse files Browse the repository at this point in the history
Fixes absolute page url for Index and site title.
  • Loading branch information
brew committed Jan 25, 2017
1 parent f11ed30 commit a20c834
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 86 deletions.
45 changes: 3 additions & 42 deletions census/views/datasets.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ <h1>{{ gettext('Dataset overview') }} </h1>

<div class="container content">
<div class="row">

<div class="col-md-4">
<h5>{{ gettext("See other years") }}</h5>
<div class="btn-group">
Expand All @@ -21,47 +20,9 @@ <h5>{{ gettext("See other years") }}</h5>
</div>
</div>

{# <div class="col-md-4">
<h5>{{ gettext("Share this page") }}</h5>
<div class="btn-group">
<a href="http://twitter.com/share?url={{current_url}}&amp;text=Check out this data from the {{ site.settings.title }}"
class="btn btn-default twitter" target="_blank"><i class="fa fa-twitter"></i> Twitter </a>
<a href="http://www.facebook.com/sharer/sharer.php?u={{current_url}}"
class="btn btn-default facebook" target="_blank"><i class="fa fa-facebook"></i> Facebook </a>
<a href="https://plus.google.com/share?url={{current_url}}" class="btn btn-default google-plus"
target="_blank"><i class="fa fa-google-plus"></i> Google+ </a>
</div>
<div class="modal fade" id="embed-instructions" tabindex="-1" role="dialog" aria-labelledby="embedLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
class="sr-only">{{ gettext("Close") }}</span></button>
<h4 class="modal-title" id="embedLabel">{{ gettext("Map embed code") }}</h4>
</div>
<div class="modal-body">
<p>
{{ gettext("Use the following code to embed the map visualisation into your own website.") }}
</p>
<xmp contenteditable="true">
<iframe width="100%" height="300px"
src="http://index.okfn.org/vis/map/embed/?embed_width=100%&embed_height=300px&filter_year=2015&filter_dataset=all&panel_tools=true&panel_share=true&map_place="
frameBorder="0"></iframe>
</xmp>
<p>
{{ gettext("If you are a developer, you can read more about the embed options here:") }} <a
href="https://github.com/okfn/opendataindex/#choropleth-map" title="Embed options">{{ gettext("Embed options") }}</a>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ gettext("Close") }}</button>
</div>
</div>
</div>
</div>
</div> #}

<div class="col-md-4">
{% include 'includes/share_buttons.html' %}
</div>
</div>

<hr/>
Expand Down
11 changes: 9 additions & 2 deletions census/views/includes/share_buttons.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<h5 {% if is_index != "true" %}class="sr-only"{% endif %}>{{ gettext("Share this page") }}</h5>
{% if not current_url and paths and site_url %}
{% set current_url = site_url + paths.href %}
{% endif %}
{% if not site_title and site.settings.title %}
{% set site_title = site.settings.title %}
{% endif %}

<h5 {% if not is_index %}class="sr-only"{% endif %}>{{ gettext("Share this page") }}</h5>
<div class="btn-group">
{# <a href="" class="btn btn-default btn-sm embed" data-toggle="modal" data-target="#embed-instructions">
<i class="fa fa-code"></i> {{ gettext("Embed") }}
</a> #}
<a href="http://twitter.com/share?url={{current_url}}&amp;text=Check out this data from the {{ site.settings.title }}" class="btn btn-default btn-sm twitter" target="_blank">
<a href="http://twitter.com/share?url={{current_url}}&amp;text=Check out this data from the {{ site_title }}" class="btn btn-default btn-sm twitter" target="_blank">
<i class="fa fa-twitter"></i> Twitter </a>
<a href="http://www.facebook.com/sharer/sharer.php?u={{current_url}}" class="btn btn-default btn-sm facebook" target="_blank">
<i class="fa fa-facebook"></i> Facebook </a>
Expand Down
39 changes: 1 addition & 38 deletions census/views/places.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,44 +69,7 @@ <h5>{{ gettext("See other years") }}</h5>
</div>

<div class="col-md-4">
<h5>{{ gettext("Share this page") }}</h5>
<div class="btn-group">
<a href="http://twitter.com/share?url={{current_url}}&amp;text=Check out this data from the {{ site.settings.title }}"
class="btn btn-default twitter" target="_blank"><i class="fa fa-twitter"></i> Twitter </a>
<a href="http://www.facebook.com/sharer/sharer.php?u={{current_url}}"
class="btn btn-default facebook" target="_blank"><i class="fa fa-facebook"></i> Facebook </a>
<a href="https://plus.google.com/share?url={{current_url}}" class="btn btn-default google-plus"
target="_blank"><i class="fa fa-google-plus"></i> Google+ </a>
</div>
<div class="modal fade" id="embed-instructions" tabindex="-1" role="dialog" aria-labelledby="embedLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
class="sr-only">{{ gettext("Close") }}</span></button>
<h4 class="modal-title" id="embedLabel">{{ gettext("Map embed code") }}</h4>
</div>
<div class="modal-body">
<p>
{{ gettext("Use the following code to embed the map visualisation into your own website.") }}
</p>
<xmp contenteditable="true">
<iframe width="100%" height="300px"
src="http://index.okfn.org/vis/map/embed/?embed_width=100%&embed_height=300px&filter_year=2015&filter_dataset=all&panel_tools=true&panel_share=true&map_place="
frameBorder="0"></iframe>
</xmp>
<p>
{{ gettext("If you are a developer, you can read more about the embed options here:") }} <a
href="https://github.com/okfn/opendataindex/#choropleth-map" title="Embed options">{{ gettext("Embed options") }}</a>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ gettext("Close") }}</button>
</div>
</div>
</div>
</div>
{% include 'includes/share_buttons.html' %}
</div>

</div>
Expand Down
17 changes: 14 additions & 3 deletions index/generate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const path = require('path');
// const util = require('util');

const _ = require('lodash');
const Metalsmith = require('metalsmith');
Expand All @@ -9,6 +10,7 @@ const assets = require('metalsmith-assets');
const markdown = require('metalsmith-markdown');
const permalinks = require('metalsmith-permalinks');
const debug = require('metalsmith-debug');
const paths = require('metalsmith-paths');

const templateFilters = require('../census/filters');
const nunjucks = require('nunjucks');
Expand All @@ -18,13 +20,19 @@ const godiGetData = require('./metalsmith-godi-getdata');
const jsonToFiles = require('metalsmith-json-to-files');

const templatePath = path.join(__dirname, '../census/views/');
// const templatePath = path.join(__dirname, './layouts/');

const env = nunjucks.configure(templatePath,
{watch: false, autoescape: false});
_.each(templateFilters, function(value, key, list) {
env.addFilter(key, value);
});

const domain = 'global-test';
const baseUrlPattern = 'http://localhost:8000';
// const baseUrl = util.format(baseUrlPattern, domain);
const baseUrl = baseUrlPattern;
const siteTitle = 'Global Open Data Index';

Metalsmith(__dirname)
.metadata({
is_index: true,
Expand All @@ -33,16 +41,19 @@ Metalsmith(__dirname)
return str;
},
// format function needs to be available in templates
format: i18n.format
format: i18n.format,
site_url: baseUrl,
site_title: siteTitle
})
.source('./src')
.destination('./build')
.clean(true)
// Populate metadata with data from Survey
.use(godiGetData({domain: 'global-test', year: 2016}))
.use(godiGetData({domain: domain, year: 2016}))
.use(jsonToFiles({use_metadata: true}))
.use(markdown())
.use(permalinks())
.use(paths({property: 'paths', directoryIndex: 'index.html'}))
.use(layouts({
engine: 'nunjucks',
rename: true,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"metalsmith-json-to-files": "brew/metalsmith-json-to-files#json-from-metadata",
"metalsmith-layouts": "^1.7.0",
"metalsmith-markdown": "^0.2.1",
"metalsmith-paths": "^3.0.1",
"metalsmith-permalinks": "^0.5.0",
"method-override": "^2.3.3",
"moment": "^2.10.3",
Expand Down Expand Up @@ -107,7 +108,7 @@
},
"scripts": {
"entry-admin": "node scripts/entry-admin.js",
"ms_generate_dev": "DEBUG=metalsmith-godi-* node index/generate.js",
"ms_generate_dev": "DEBUG=metalsmith:* node index/generate.js",
"migrate_users": "node scripts/users.js",
"start": "node server.js",
"debug": "node-debug debug-server.js --no-preload --hidden='node_modules'",
Expand Down

0 comments on commit a20c834

Please sign in to comment.