Rufus Pollock avatar Rufus Pollock committed af9d77e

[app][s]: set dataset id for the embed code as you select different datasets on the home page.

Comments (0)

Files changed (4)

-from flask import Flask
+from flask import Flask, request
 from flaskext.genshi import Genshi, render_response
 app = Flask(__name__)
 genshi = Genshi(app)
 
 @app.route('/embed')
 def embed():
-    dataset_id = 'teina011'
+    dataset_id = request.args.get('datasetId', 'teina011')
     return render_response('embed.html', dict(dataset_id=dataset_id))
 
 
-
 if __name__ == '__main__':
     app.run(debug=True)
 

eurostat/static/app.js

 function plotDataset(datasetId, datasetTitle, cachedir) {
 	$('#chart-heading').text(datasetTitle);
+    var embedCode = new Array(
+      '<!-- Eurostat PEEE -->',
+      '<iframe style="padding:0;margin:0;" height="100px" frameborder="0" width="100%" scrolling="no" src="http://eurostat.dev.okfn.org/embed?datasetId=' + datasetId + '"></iframe>',
+      '<!-- /Eurostat PEEE -->'
+	  );
+	embedCode = embedCode.join(" \n ");
+	$("#embed-code").val(embedCode);
 	$.getJSON(cachedir + '/' + datasetId + '.json', null, plotItAll);
 }
 

eurostat/static/style.css

   display: none;
 }
 
-.embed .legend {
-  display: none;
-}
-
 /*************************
   * Index page
   */

eurostat/templates/index.html

     <xi:include href="flot.html" />
 
     <textarea id="embed-code">
-<!-- Eurostat PEEE -->
-<iframe style="padding:0;margin:0;" height="100px" frameborder="0" width="100%" scrolling="no" src="http://eurostat.dev.okfn.org/embed?id=${dataset_id}"></iframe>
-<!-- /Eurostat PEEE -->
     </textarea>
   </div>
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.