template : require 'kraken/template/graph-scaffold'
collectionType : GraphOptionList
subviewType : GraphOptionView
- $fields : '.fields'
+ fields : '.fields'
# GraphView will set this
ready : false
# console.log "#this.render() -> .isotope()"
# @__super__.render ...
return this unless @ready
- @$el.find '.options.control-group' .isotope do
+ container = if @fields then @$el.find @fields else @$el
+ container.isotope do
itemSelector : '.field.option'
layoutMode : 'masonry'
masonry : columnWidth : 10
# Load data files
Seq([ <[ CHART_OPTIONS_SPEC /graph/dygraph-options.json ]>,
- <[ ROOT_VIS_DATA /graph/root ]>
+ <[ ROOT_VIS_DATA /presets/root.json ]>
])
.parEach_ (next, [key, url]) ->
jQuery.ajax do
SubviewType = @subviewType
view = new SubviewType model:field
@subviews.push view
- el = if @$fields then @$el.find @$fields else @$el
- el.append view.render().el unless field.get 'ignore'
+ container = if @fields then @$el.find @fields else @$el
+ container.append view.render().el unless field.get 'ignore'
view.on 'update', @change.bind(this, field)
@render()
--- /dev/null
+_ = require 'underscore'
+url = require 'url'
+
+module.exports = exports = (options) ->
+ mw = new ReqInfoMiddleware options
+ mw.respond
+
+class exports.ReqInfoMiddleware
+
+ (@options={}) ->
+ _.bindAll this, 'respond'
+
+ parse : url.parse
+
+ respond : function reqinfo(req, res, next)
+ req.info = @parse req.url
+ next()
+
+
+
fs = require 'fs'
path = require 'path'
+{parse} = require 'url'
{existsSync:exists} = path
{exec, spawn} = require 'child_process'
_ = require 'underscore'
+_.str = require 'underscore.string'
+_.mixin _.str.exports()
+
Seq = require 'seq'
yaml = require 'js-yaml'
mime = require 'mime'
app.use express.logger() if LOG_LEVEL is 'DEBUG'
+ # Parse URL, fiddle
+ app.use require('./reqinfo')({})
+
# Parse form submits into req.params
app.use express.bodyParser()
showStack : true
-### Routes
+/* * * * Routes * * * {{{ */
app.get '/', (req, res) ->
res.render 'dashboard'
-app.get '/graph/:id', (req, res, next) ->
- {id} = req.params
- # console.log req.url
- if exists("#WWW/graph/#id.yaml") or exists("#WWW/graph/#id.json")
+app.get '/preset/:slug', (req, res, next) ->
+ if exists("#WWW/presets/#slug.yaml") or exists("#WWW/presets/#slug.json")
req.url += '.json'
next()
+app.get '/graph/:slug/?', (req, res, next) ->
+ {slug} = req.params
+ # console.log '/graph/:slug/?'
+ # console.log ' slug: ', slug
+ # console.log ' params:', req.params
+ unless _.str.include slug, '.'
+ {pathname, search} = req.info
+ req.url = "#pathname/view#search"
+ req.params.action = 'view'
+ next()
+
+app.get '/graph/:slug/:action/?', (req, res) ->
+ {slug, action} = req.params
+ res.render "graph/#action"
+
+app.get '/:type/:action/?', (req, res, next) ->
+ {type, action} = req.params
+ if path.existsSync "#WWW/#type/#action.jade"
+ res.render "#type/#action"
+ else
+ next()
+
+
+
+# }}}
+/* * * * Data Source Oracle * * * {{{ */
YAML_EXT_PAT = /\.ya?ml$/i
console.error that if err.stack
res.send { error:String(err), partial_data:data }
-
-app.get '/:type/:action', (req, res, next) ->
- {type, action} = req.params
- if path.existsSync "#WWW/#type/#action.jade"
- res.render "#type/#action"
- else
- next()
-
-
-
-
+# }}}
/**
* Handle webhook notification to pull from origin.
+++ /dev/null
-# The root graph, holding defaults inherited by all graphs.
-
-dataset : '/data/non_mobile_pageviews_by.timestamp.language.csv'
-width : 'auto'
-height : 400
-options :
- # visibility : true
- # stackedGraph : false
- # fillGraph : false
- colors : [ "#FF0097", "#EF8158", "#83BB32", "#182B53", "#4596FF", "#553DC9", "#AD3238", "#00FFBC", "#F1D950" ]
- # colorSaturation : 1.0
- # colorValue : 0.5
- rightGap : 20
- animatedZooms : true
- # labels : Array
- labelsSeparateLines : true
- xlabel : Date
- # logscale : false
- axisLineColor : '#333333'
- # axisTickSize : 3.0
- axisLabelColor : black
- # axisLabelFontSize : 14
- # labelsKMB : false
- # labelsKMG2 : false
- digitsAfterDecimal : 2
- maxNumberWidth : 6
- sigFigs : 3
- # valueFormatter : function(num or millis, opts, dygraph)
- # showRoller : false
- # rollPeriod : 1
- # sigma : 2.0
- # wilsonInterval : true
- # fillAlpha : 0.15
- # customBars : false
- # errorBars : false
- # fractions : false
- # delimiter : ','
- # xValueParser : function(str) -> number
- # drawXGrid : true
- # drawYGrid : true
- gridLineColor : '#eeeeee'
- # gridLineWidth : 0.3
- # showRangeSelector : false
- # rangeSelectorHeight : 40
- # rangeSelectorPlotFillColor : '#A7B1C4'
- # rangeSelectorPlotStrokeColor : '#808FAB'
- displayAnnotations : true
+++ /dev/null
-extends ../layout
-
-block title
- title Kraken: Graph Test Page
-
-append styles
- mixin css('forms.css')
- mixin css('graph.css')
- mixin css('isotope.css')
-
--- /dev/null
+include edit
\ No newline at end of file