Datafable / gbif-data-licenses

Interpreting licenses of GBIF registered data
http://datafable.github.io/gbif-data-licenses/charts/index.html
Other
2 stars 1 forks source link

Let `analysis.py` generate js files instead of json #29

Closed bartaelterman closed 11 years ago

bartaelterman commented 11 years ago

Currently, the script analysis.py generates json files with data for visualisation. These files are loaded by the javascript that creates the charts. A neat solution, but this prevents dynamically loading the charts from another place, say, a blog, because of http restrictions.

Loading the charts from a blog could be done in 2 ways:

  1. Let the blog html load the javascript that creates the charts and let this javascript fetch the json data. (we should tweak the javascript that it first tries to read the data from a local file - because that's what we do while developing - and download it from the github repository if it can't find the file locally - because those files woudn't exist on the blogs server). However, github does not allow other javascript to read files, even from its served branches like gh-pages.
  2. Copy the json files to the blogs server so that the javascript can find these files locally. However, that way those charts won't get updates unless we push them from the github repo to the blog once in a while.

Therefore, we'll go for a hack: let the analysis.py script generate a javascript source file instead of a json data file. In this file, a couple of global variables are declared that contain the data. Instead of letting the javascript file that creates the charts read the json data, we let the html file load 2 javascript files: one that sets variables containing the data, and one that uses those variables downsteam for creating the charts.

peterdesmet commented 11 years ago

I looked at the code, and I think it is better if you do this, great Python master. :bow:

Can you write the variables to /charts/js/data.js ?

bartaelterman commented 11 years ago

I'm flattered...

I'll get right onto it my son.