Skip to content
No description, website, or topics provided.
CSS JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
assets/images
data
styles
tests
.babelrc
.editorconfig
.eslintrc
.gitattributes
.gitignore
.htmlhintrc
.stylelintrc
LICENSE.code
README.md
browserlist
index.html
package.json

README.md

2017 Election Guide

Election guide for 2017 Twin Cities elections

Data

Boundary data from the following sources and stored in the data/ folder for easy access and processing.

Candidate information is managed in this spreadsheet.

Processing

For use int he browser and to optimize performance, the data files need to be converted:

  • Minneapolis city council districts: ogr2ogr -f "GeoJSON" data/minneapolis-council.geo.json data/sources/Minneapolis-City_Council_Wards/City_Council_Wards.shp -t_srs "EPSG:4326" -sql "SELECT BDNUM AS id FROM City_Council_Wards"
  • Minneapolis city boundarys: ogr2ogr -f "GeoJSON" data/minneapolis-city.geo.json data/sources/Minneapolis-City_Council_Wards/City_Council_Wards.shp -t_srs "EPSG:4326" -dialect sqlite -sql "SELECT ST_Union(Geometry) FROM City_Council_Wards"
  • Minneapolis park board districts: ogr2ogr -f "GeoJSON" data/minneapolis-park.geo.json "data/sources/Minneapolis-park-board-districts/2017 Commissioner Districts-edited.shp" -t_srs "EPSG:4326" -sql "SELECT OBJECTID AS id FROM '2017 Commissioner Districts-edited'"
  • St. Paul city boundary: ogr2ogr -f "GeoJSON" data/st-paul-city.geo.json "data/sources/St-Paul-Council Ward - Shapefile - Map/st-paul-city-council.shp" -t_srs "EPSG:4326" -dialect sqlite -sql "SELECT ST_Union(Geometry) FROM 'st-paul-city-council'"
    • Note: Had issue with ogr2ogr so this was manually done in QGIS.

Easy command line option to get new data from the spread sheet.

wget "https://docs.google.com/spreadsheets/d/e/2PACX-1vQW3uF1XBcCsp02d61siYLGUA_As8IRKu4daH9Aqt6WQ7fc83uzcObUb2v0fm0nYSWMU1Zfab8aqLgL/pub?output=csv" -O data/candidates.csv

Embed

This project is best used as an embed. The best way to embed the piece is with the following code:

<div id="2017-election-guide-embed" class="size-l">Loading...</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pym/1.3.1/pym.v1.min.js" type="text/javascript">
</script> <script type="text/javascript">
  (function(){
    var pymParent = new pym.Parent(
      "2017-election-guide-embed",
      "http://static.startribune.com/projects/2017-election-guide/index.html"
    );
  })();
</script>

Unsure why, but this hackery is needed for the Star Tribune CMS.

<div id="2017-election-guide-embed" class="size-l">Loading...</div>

<script type="text/javascript">
  (function(){
    window.pym = undefined;

    var el = document.createElement('script');
    el.src = 'https://cdnjs.cloudflare.com/ajax/libs/pym/1.3.1/pym.v1.min.js';
    document.getElementsByTagName('head')[0].appendChild(el);

    setTimeout(function() {
      var pymParent = new window.pym.Parent(
        "2017-election-guide-embed",
        "http://static.startribune.com/projects/2017-election-guide/index.html"
      );
    }, 1000);
  })();
</script>

Development

Local

This project is a static HTML page, so serve it locally with your preferred web server. For instance:

  • With Python: python -m SimpleHTTPServer
  • With Node: npm install -g http-server && http-server
  • Or try Served

Publish and deploy

This project should be published to: static.startribune.com/projects/2017-election-guide

With AWS command line: aws s3 sync ./ s3://static.startribune.com/projects/2017-election-guide --exclude="*" --include="*.html" --include="assets/*" --include="styles/*" --include="app/*" --include="data/*.json" --include="data/*.csv" --acl="public-read" --cache-control="public, max-age=60"

License

Code is licensed under the MIT license included here. Content (such as images, video, audio, copy, fonts) can only be reused with express permission by Star Tribune.

You can’t perform that action at this time.