Dynamically serve YAML -> JSON.
authordsc <dsc@less.ly>
Wed, 22 Feb 2012 02:26:54 +0000 (18:26 -0800)
committerdsc <dsc@less.ly>
Wed, 22 Feb 2012 02:26:54 +0000 (18:26 -0800)
lib/graph.co
lib/main.co
www/graph/test.jade

index 7b8c845..680b29c 100644 (file)
@@ -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()
     
index a6e9b10..0e385fa 100644 (file)
@@ -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
index b66d268..579a64a 100644 (file)
@@ -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') };