From: dsc Date: Wed, 22 Feb 2012 02:26:54 +0000 (-0800) Subject: Dynamically serve YAML -> JSON. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=7b23f8f0573ef263c68e9879703f8c8fbc18b83e;p=limn.git Dynamically serve YAML -> JSON. --- diff --git a/lib/graph.co b/lib/graph.co index 7b8c845..680b29c 100644 --- a/lib/graph.co +++ b/lib/graph.co @@ -93,6 +93,7 @@ Graph = exports.Graph = Backbone.View.extend do # {{{ initialize : (o={}) -> + {graph_spec} = o @model or= new GraphModel @$el.data { model:@model, view:this } @@ -102,7 +103,7 @@ Graph = exports.Graph = Backbone.View.extend do # {{{ @viewport = @$el.find '.viewport' @scaffold = new GraphOptionsScaffold do el: @$el.find 'form.settings' - @scaffold.collection.reset CHART_OPTIONS_SPEC + @scaffold.collection.reset graph_spec @render() diff --git a/lib/main.co b/lib/main.co index a6e9b10..0e385fa 100644 --- a/lib/main.co +++ b/lib/main.co @@ -10,9 +10,18 @@ _ = require 'kraken/underscore' root = do -> this main = -> - graph = root.graph = new Graph do el : $ 'section.graph' .eq 0 + graph_spec : CHART_OPTIONS_SPEC + + +jQuery.ajax do + url : '/graph/dygraph-options.json', + dataType : 'json' + + success : (data) -> + CHART_OPTIONS_SPEC = data + jQuery main + error : (err) -> console.error err -jQuery main \ No newline at end of file diff --git a/www/graph/test.jade b/www/graph/test.jade index b66d268..579a64a 100644 --- a/www/graph/test.jade +++ b/www/graph/test.jade @@ -17,7 +17,8 @@ append styles //- mixin text_field('data', 'data/page_views_by_project.csv') block page-scripts - script - var CHART_OPTIONS_SPEC = !{ fs.readFileSync('www/graph/dygraph-options.json', 'utf8') }; + //- + script + var CHART_OPTIONS_SPEC = !{ fs.readFileSync('www/graph/dygraph-options.json', 'utf8') };