riemann-dash 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.gitignore +9 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +52 -0
  4. data/README.markdown +29 -5
  5. data/Rakefile.rb +11 -0
  6. data/bin/riemann-dash +2 -2
  7. data/example/config.rb +17 -0
  8. data/lib/riemann/dash/app.rb +32 -0
  9. data/lib/riemann/dash/config.rb +154 -0
  10. data/lib/riemann/dash/controller/css.rb +1 -1
  11. data/lib/riemann/dash/controller/index.rb +6 -36
  12. data/lib/riemann/dash/public/dash.js +44 -18
  13. data/lib/riemann/dash/public/format.js +3 -3
  14. data/lib/riemann/dash/public/persistence.js +2 -2
  15. data/lib/riemann/dash/public/subs.js +63 -48
  16. data/lib/riemann/dash/public/util.js +37 -44
  17. data/lib/riemann/dash/public/vendor/backbone.js +1571 -0
  18. data/lib/riemann/dash/public/vendor/jquery/jquery-1.9.1.min.js +5 -0
  19. data/lib/riemann/dash/public/{jquery-ui-1.9.0.custom.min.js → vendor/jquery/jquery-ui-1.9.0.custom.min.js} +0 -0
  20. data/lib/riemann/dash/public/{jquery.quickfit.js → vendor/jquery/jquery.quickfit.js} +0 -0
  21. data/lib/riemann/dash/public/vendor/jquery/jquery.simplemodal.1.4.4.min.js +26 -0
  22. data/lib/riemann/dash/public/vendor/lodash.min.js +40 -0
  23. data/lib/riemann/dash/public/vendor/smoothie.js +376 -0
  24. data/lib/riemann/dash/public/{toastr.css → vendor/toastr/toastr.css} +1 -1
  25. data/lib/riemann/dash/public/{toastr.js → vendor/toastr/toastr.js} +0 -0
  26. data/lib/riemann/dash/public/views/gauge.js +8 -5
  27. data/lib/riemann/dash/public/views/grid.js +138 -67
  28. data/lib/riemann/dash/public/views/timeseries.js +230 -0
  29. data/lib/riemann/dash/public/views/title.js +6 -3
  30. data/lib/riemann/dash/version.rb +2 -2
  31. data/lib/riemann/dash/views/css.scss +52 -2
  32. data/lib/riemann/dash/views/index.erubis +38 -192
  33. data/lib/riemann/dash.rb +3 -97
  34. data/riemann-dash.gemspec +28 -0
  35. data/sh/c +1 -0
  36. data/sh/env.rb +2 -0
  37. data/sh/test +1 -0
  38. data/test/config_test.rb +114 -0
  39. data/test/fixtures/config/basic_config.rb +2 -0
  40. data/test/fixtures/config/ws_config.rb +1 -0
  41. data/test/fixtures/ws_config/dummy_config.json +1 -0
  42. data/test/fixtures/ws_config/pretty_printed_config.json +6 -0
  43. data/test/test_helper.rb +10 -0
  44. metadata +43 -18
  45. data/lib/riemann/dash/public/jquery-1.7.2.min.js +0 -4
  46. data/lib/riemann/dash/public/jquery.json-2.2.min.js +0 -31
  47. data/lib/riemann/dash/public/jquery.simplemodal.1.4.3.min.js +0 -26
  48. data/lib/riemann/dash/public/mustache.js +0 -597
  49. data/lib/riemann/dash/public/underscore-min.js +0 -5
@@ -1,597 +0,0 @@
1
- /*!
2
- * mustache.js - Logic-less {{mustache}} templates with JavaScript
3
- * http://github.com/janl/mustache.js
4
- */
5
- var Mustache = (typeof module !== "undefined" && module.exports) || {};
6
-
7
- (function (exports) {
8
-
9
- exports.name = "mustache.js";
10
- exports.version = "0.5.1-dev";
11
- exports.tags = ["{{", "}}"];
12
-
13
- exports.parse = parse;
14
- exports.clearCache = clearCache;
15
- exports.compile = compile;
16
- exports.compilePartial = compilePartial;
17
- exports.render = render;
18
-
19
- exports.Scanner = Scanner;
20
- exports.Context = Context;
21
- exports.Renderer = Renderer;
22
-
23
- // This is here for backwards compatibility with 0.4.x.
24
- exports.to_html = function (template, view, partials, send) {
25
- var result = render(template, view, partials);
26
-
27
- if (typeof send === "function") {
28
- send(result);
29
- } else {
30
- return result;
31
- }
32
- };
33
-
34
- var whiteRe = /\s*/;
35
- var spaceRe = /\s+/;
36
- var nonSpaceRe = /\S/;
37
- var eqRe = /\s*=/;
38
- var curlyRe = /\s*\}/;
39
- var tagRe = /#|\^|\/|>|\{|&|=|!/;
40
-
41
- // Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
42
- // See https://github.com/janl/mustache.js/issues/189
43
- function testRe(re, string) {
44
- return RegExp.prototype.test.call(re, string);
45
- }
46
-
47
- function isWhitespace(string) {
48
- return !testRe(nonSpaceRe, string);
49
- }
50
-
51
- var isArray = Array.isArray || function (obj) {
52
- return Object.prototype.toString.call(obj) === "[object Array]";
53
- };
54
-
55
- // OSWASP Guidlines: escape all non alphanumeric characters in ASCII space.
56
- var jsCharsRe = /[\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\xFF\u2028\u2029]/gm;
57
-
58
- function quote(text) {
59
- var escaped = text.replace(jsCharsRe, function (c) {
60
- return "\\u" + ('0000' + c.charCodeAt(0).toString(16)).slice(-4);
61
- });
62
-
63
- return '"' + escaped + '"';
64
- }
65
-
66
- function escapeRe(string) {
67
- return string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
68
- }
69
-
70
- var entityMap = {
71
- "&": "&",
72
- "<": "&lt;",
73
- ">": "&gt;",
74
- '"': '&quot;',
75
- "'": '&#39;',
76
- "/": '&#x2F;'
77
- };
78
-
79
- function escapeHtml(string) {
80
- return String(string).replace(/[&<>"'\/]/g, function (s) {
81
- return entityMap[s];
82
- });
83
- }
84
-
85
- // Export these utility functions.
86
- exports.isWhitespace = isWhitespace;
87
- exports.isArray = isArray;
88
- exports.quote = quote;
89
- exports.escapeRe = escapeRe;
90
- exports.escapeHtml = escapeHtml;
91
-
92
- function Scanner(string) {
93
- this.string = string;
94
- this.tail = string;
95
- this.pos = 0;
96
- }
97
-
98
- /**
99
- * Returns `true` if the tail is empty (end of string).
100
- */
101
- Scanner.prototype.eos = function () {
102
- return this.tail === "";
103
- };
104
-
105
- /**
106
- * Tries to match the given regular expression at the current position.
107
- * Returns the matched text if it can match, `null` otherwise.
108
- */
109
- Scanner.prototype.scan = function (re) {
110
- var match = this.tail.match(re);
111
-
112
- if (match && match.index === 0) {
113
- this.tail = this.tail.substring(match[0].length);
114
- this.pos += match[0].length;
115
- return match[0];
116
- }
117
-
118
- return null;
119
- };
120
-
121
- /**
122
- * Skips all text until the given regular expression can be matched. Returns
123
- * the skipped string, which is the entire tail of this scanner if no match
124
- * can be made.
125
- */
126
- Scanner.prototype.scanUntil = function (re) {
127
- var match, pos = this.tail.search(re);
128
-
129
- switch (pos) {
130
- case -1:
131
- match = this.tail;
132
- this.pos += this.tail.length;
133
- this.tail = "";
134
- break;
135
- case 0:
136
- match = null;
137
- break;
138
- default:
139
- match = this.tail.substring(0, pos);
140
- this.tail = this.tail.substring(pos);
141
- this.pos += pos;
142
- }
143
-
144
- return match;
145
- };
146
-
147
- function Context(view, parent) {
148
- this.view = view;
149
- this.parent = parent;
150
- this.clearCache();
151
- }
152
-
153
- Context.make = function (view) {
154
- return (view instanceof Context) ? view : new Context(view);
155
- };
156
-
157
- Context.prototype.clearCache = function () {
158
- this._cache = {};
159
- };
160
-
161
- Context.prototype.push = function (view) {
162
- return new Context(view, this);
163
- };
164
-
165
- Context.prototype.lookup = function (name) {
166
- var value = this._cache[name];
167
-
168
- if (!value) {
169
- if (name === ".") {
170
- value = this.view;
171
- } else {
172
- var context = this;
173
-
174
- while (context) {
175
- if (name.indexOf(".") > 0) {
176
- var names = name.split("."), i = 0;
177
-
178
- value = context.view;
179
-
180
- while (value && i < names.length) {
181
- value = value[names[i++]];
182
- }
183
- } else {
184
- value = context.view[name];
185
- }
186
-
187
- if (value != null) {
188
- break;
189
- }
190
-
191
- context = context.parent;
192
- }
193
- }
194
-
195
- this._cache[name] = value;
196
- }
197
-
198
- if (typeof value === "function") {
199
- value = value.call(this.view);
200
- }
201
-
202
- return value;
203
- };
204
-
205
- function Renderer() {
206
- this.clearCache();
207
- }
208
-
209
- Renderer.prototype.clearCache = function () {
210
- this._cache = {};
211
- this._partialCache = {};
212
- };
213
-
214
- Renderer.prototype.compile = function (tokens, tags) {
215
- var fn = compileTokens(tokens),
216
- self = this;
217
-
218
- return function (view) {
219
- return fn(Context.make(view), self);
220
- };
221
- };
222
-
223
- Renderer.prototype.compilePartial = function (name, tokens, tags) {
224
- this._partialCache[name] = this.compile(tokens, tags);
225
- return this._partialCache[name];
226
- };
227
-
228
- Renderer.prototype.render = function (template, view) {
229
- var fn = this._cache[template];
230
-
231
- if (!fn) {
232
- fn = this.compile(template);
233
- this._cache[template] = fn;
234
- }
235
-
236
- return fn(view);
237
- };
238
-
239
- Renderer.prototype._section = function (name, context, callback) {
240
- var value = context.lookup(name);
241
-
242
- switch (typeof value) {
243
- case "object":
244
- if (isArray(value)) {
245
- var buffer = "";
246
- for (var i = 0, len = value.length; i < len; ++i) {
247
- buffer += callback(context.push(value[i]), this);
248
- }
249
- return buffer;
250
- } else {
251
- return callback(context.push(value), this);
252
- }
253
- break;
254
- case "function":
255
- var sectionText = callback(context, this), self = this;
256
- var scopedRender = function (template) {
257
- return self.render(template, context);
258
- };
259
- return value.call(context.view, sectionText, scopedRender) || "";
260
- break;
261
- default:
262
- if (value) {
263
- return callback(context, this);
264
- }
265
- }
266
-
267
- return "";
268
- };
269
-
270
- Renderer.prototype._inverted = function (name, context, callback) {
271
- var value = context.lookup(name);
272
-
273
- // From the spec: inverted sections may render text once based on the
274
- // inverse value of the key. That is, they will be rendered if the key
275
- // doesn't exist, is false, or is an empty list.
276
- if (value == null || value === false || (isArray(value) && value.length === 0)) {
277
- return callback(context, this);
278
- }
279
-
280
- return "";
281
- };
282
-
283
- Renderer.prototype._partial = function (name, context) {
284
- var fn = this._partialCache[name];
285
-
286
- if (fn) {
287
- return fn(context, this);
288
- }
289
-
290
- return "";
291
- };
292
-
293
- Renderer.prototype._name = function (name, context, escape) {
294
- var value = context.lookup(name);
295
-
296
- if (typeof value === "function") {
297
- value = value.call(context.view);
298
- }
299
-
300
- var string = (value == null) ? "" : String(value);
301
-
302
- if (escape) {
303
- return escapeHtml(string);
304
- }
305
-
306
- return string;
307
- };
308
-
309
- /**
310
- * Low-level function that compiles the given `tokens` into a
311
- * function that accepts two arguments: a Context and a
312
- * Renderer. Returns the body of the function as a string if
313
- * `returnBody` is true.
314
- */
315
- function compileTokens(tokens, returnBody) {
316
- if (typeof tokens === "string") {
317
- tokens = parse(tokens);
318
- }
319
-
320
- var body = ['""'];
321
- var token, method, escape;
322
-
323
- for (var i = 0, len = tokens.length; i < len; ++i) {
324
- token = tokens[i];
325
-
326
- switch (token.type) {
327
- case "#":
328
- case "^":
329
- method = (token.type === "#") ? "_section" : "_inverted";
330
- body.push("r." + method + "(" + quote(token.value) + ", c, function (c, r) {\n" +
331
- " " + compileTokens(token.tokens, true) + "\n" +
332
- "})");
333
- break;
334
- case "{":
335
- case "&":
336
- case "name":
337
- escape = token.type === "name" ? "true" : "false";
338
- body.push("r._name(" + quote(token.value) + ", c, " + escape + ")");
339
- break;
340
- case ">":
341
- body.push("r._partial(" + quote(token.value) + ", c)");
342
- break;
343
- case "text":
344
- body.push(quote(token.value));
345
- break;
346
- }
347
- }
348
-
349
- // Convert to a string body.
350
- body = "return " + body.join(" + ") + ";";
351
-
352
- // Good for debugging.
353
- // console.log(body);
354
-
355
- if (returnBody) {
356
- return body;
357
- }
358
-
359
- // For great evil!
360
- return new Function("c, r", body);
361
- }
362
-
363
- function escapeTags(tags) {
364
- if (tags.length === 2) {
365
- return [
366
- new RegExp(escapeRe(tags[0]) + "\\s*"),
367
- new RegExp("\\s*" + escapeRe(tags[1]))
368
- ];
369
- }
370
-
371
- throw new Error("Invalid tags: " + tags.join(" "));
372
- }
373
-
374
- /**
375
- * Forms the given linear array of `tokens` into a nested tree structure
376
- * where tokens that represent a section have a "tokens" array property
377
- * that contains all tokens that are in that section.
378
- */
379
- function nestTokens(tokens) {
380
- var tree = [];
381
- var collector = tree;
382
- var sections = [];
383
- var token, section;
384
-
385
- for (var i = 0; i < tokens.length; ++i) {
386
- token = tokens[i];
387
-
388
- switch (token.type) {
389
- case "#":
390
- case "^":
391
- token.tokens = [];
392
- sections.push(token);
393
- collector.push(token);
394
- collector = token.tokens;
395
- break;
396
- case "/":
397
- if (sections.length === 0) {
398
- throw new Error("Unopened section: " + token.value);
399
- }
400
-
401
- section = sections.pop();
402
-
403
- if (section.value !== token.value) {
404
- throw new Error("Unclosed section: " + section.value);
405
- }
406
-
407
- if (sections.length > 0) {
408
- collector = sections[sections.length - 1].tokens;
409
- } else {
410
- collector = tree;
411
- }
412
- break;
413
- default:
414
- collector.push(token);
415
- }
416
- }
417
-
418
- // Make sure there were no open sections when we're done.
419
- section = sections.pop();
420
-
421
- if (section) {
422
- throw new Error("Unclosed section: " + section.value);
423
- }
424
-
425
- return tree;
426
- }
427
-
428
- /**
429
- * Combines the values of consecutive text tokens in the given `tokens` array
430
- * to a single token.
431
- */
432
- function squashTokens(tokens) {
433
- var lastToken;
434
-
435
- for (var i = 0; i < tokens.length; ++i) {
436
- token = tokens[i];
437
-
438
- if (lastToken && lastToken.type === "text" && token.type === "text") {
439
- lastToken.value += token.value;
440
- tokens.splice(i--, 1); // Remove this token from the array.
441
- } else {
442
- lastToken = token;
443
- }
444
- }
445
- }
446
-
447
- /**
448
- * Breaks up the given `template` string into a tree of token objects. If
449
- * `tags` is given here it must be an array with two string values: the
450
- * opening and closing tags used in the template (e.g. ["<%", "%>"]). Of
451
- * course, the default is to use mustaches (i.e. Mustache.tags).
452
- */
453
- function parse(template, tags) {
454
- tags = tags || exports.tags;
455
- tagRes = escapeTags(tags);
456
-
457
- var scanner = new Scanner(template);
458
-
459
- var tokens = [], // Buffer to hold the tokens
460
- spaces = [], // Indices of whitespace tokens on the current line
461
- hasTag = false, // Is there a {{tag}} on the current line?
462
- nonSpace = false; // Is there a non-space char on the current line?
463
-
464
- // Strips all whitespace tokens array for the current line
465
- // if there was a {{#tag}} on it and otherwise only space.
466
- var stripSpace = function () {
467
- if (hasTag && !nonSpace) {
468
- while (spaces.length) {
469
- tokens.splice(spaces.pop(), 1);
470
- }
471
- } else {
472
- spaces = [];
473
- }
474
-
475
- hasTag = false;
476
- nonSpace = false;
477
- };
478
-
479
- var type, value, chr;
480
-
481
- while (!scanner.eos()) {
482
- value = scanner.scanUntil(tagRes[0]);
483
-
484
- if (value) {
485
- for (var i = 0, len = value.length; i < len; ++i) {
486
- chr = value[i];
487
-
488
- if (isWhitespace(chr)) {
489
- spaces.push(tokens.length);
490
- } else {
491
- nonSpace = true;
492
- }
493
-
494
- tokens.push({type: "text", value: chr});
495
-
496
- if (chr === "\n") {
497
- stripSpace(); // Check for whitespace on the current line.
498
- }
499
- }
500
- }
501
-
502
- // Match the opening tag.
503
- if (!scanner.scan(tagRes[0])) {
504
- break;
505
- }
506
-
507
- hasTag = true;
508
- type = scanner.scan(tagRe) || "name";
509
-
510
- // Skip any whitespace between tag and value.
511
- scanner.scan(whiteRe);
512
-
513
- // Extract the tag value.
514
- if (type === "=") {
515
- value = scanner.scanUntil(eqRe);
516
- scanner.scan(eqRe);
517
- scanner.scanUntil(tagRes[1]);
518
- } else if (type === "{") {
519
- var closeRe = new RegExp("\\s*" + escapeRe("}" + tags[1]));
520
- value = scanner.scanUntil(closeRe);
521
- scanner.scan(curlyRe);
522
- scanner.scanUntil(tagRes[1]);
523
- } else {
524
- value = scanner.scanUntil(tagRes[1]);
525
- }
526
-
527
- // Match the closing tag.
528
- if (!scanner.scan(tagRes[1])) {
529
- throw new Error("Unclosed tag at " + scanner.pos);
530
- }
531
-
532
- tokens.push({type: type, value: value});
533
-
534
- if (type === "name" || type === "{" || type === "&") {
535
- nonSpace = true;
536
- }
537
-
538
- // Set the tags for the next time around.
539
- if (type === "=") {
540
- tags = value.split(spaceRe);
541
- tagRes = escapeTags(tags);
542
- }
543
- }
544
-
545
- squashTokens(tokens);
546
-
547
- return nestTokens(tokens);
548
- }
549
-
550
- // The high-level clearCache, compile, compilePartial, and render functions
551
- // use this default renderer.
552
- var _renderer = new Renderer;
553
-
554
- /**
555
- * Clears all cached templates and partials.
556
- */
557
- function clearCache() {
558
- _renderer.clearCache();
559
- }
560
-
561
- /**
562
- * High-level API for compiling the given `tokens` down to a reusable
563
- * function. If `tokens` is a string it will be parsed using the given `tags`
564
- * before it is compiled.
565
- */
566
- function compile(tokens, tags) {
567
- return _renderer.compile(tokens, tags);
568
- }
569
-
570
- /**
571
- * High-level API for compiling the `tokens` for the partial with the given
572
- * `name` down to a reusable function. If `tokens` is a string it will be
573
- * parsed using the given `tags` before it is compiled.
574
- */
575
- function compilePartial(name, tokens, tags) {
576
- return _renderer.compilePartial(name, tokens, tags);
577
- }
578
-
579
- /**
580
- * High-level API for rendering the `template` using the given `view`. The
581
- * optional `partials` object may be given here for convenience, but note that
582
- * it will cause all partials to be re-compiled, thus hurting performance. Of
583
- * course, this only matters if you're going to render the same template more
584
- * than once. If so, it is best to call `compilePartial` before calling this
585
- * function and to leave the `partials` argument blank.
586
- */
587
- function render(template, view, partials) {
588
- if (partials) {
589
- for (var name in partials) {
590
- compilePartial(name, partials[name]);
591
- }
592
- }
593
-
594
- return _renderer.render(template, view);
595
- }
596
-
597
- })(Mustache);
@@ -1,5 +0,0 @@
1
- // Underscore.js 1.4.2
2
- // http://underscorejs.org
3
- // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
4
- // Underscore may be freely distributed under the MIT license.
5
- (function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=r.unshift,l=i.toString,c=i.hasOwnProperty,h=r.forEach,p=r.map,d=r.reduce,v=r.reduceRight,m=r.filter,g=r.every,y=r.some,b=r.indexOf,w=r.lastIndexOf,E=Array.isArray,S=Object.keys,x=s.bind,T=function(e){if(e instanceof T)return e;if(!(this instanceof T))return new T(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=T),exports._=T):e._=T,T.VERSION="1.4.2";var N=T.each=T.forEach=function(e,t,r){if(e==null)return;if(h&&e.forEach===h)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i<s;i++)if(t.call(r,e[i],i,e)===n)return}else for(var o in e)if(T.has(e,o)&&t.call(r,e[o],o,e)===n)return};T.map=T.collect=function(e,t,n){var r=[];return e==null?r:p&&e.map===p?e.map(t,n):(N(e,function(e,i,s){r[r.length]=t.call(n,e,i,s)}),r)},T.reduce=T.foldl=T.inject=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(d&&e.reduce===d)return r&&(t=T.bind(t,r)),i?e.reduce(t,n):e.reduce(t);N(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError("Reduce of empty array with no initial value");return n},T.reduceRight=T.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(v&&e.reduceRight===v)return r&&(t=T.bind(t,r)),arguments.length>2?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=T.keys(e);s=o.length}N(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError("Reduce of empty array with no initial value");return n},T.find=T.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},T.filter=T.select=function(e,t,n){var r=[];return e==null?r:m&&e.filter===m?e.filter(t,n):(N(e,function(e,i,s){t.call(n,e,i,s)&&(r[r.length]=e)}),r)},T.reject=function(e,t,n){var r=[];return e==null?r:(N(e,function(e,i,s){t.call(n,e,i,s)||(r[r.length]=e)}),r)},T.every=T.all=function(e,t,r){t||(t=T.identity);var i=!0;return e==null?i:g&&e.every===g?e.every(t,r):(N(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=T.some=T.any=function(e,t,r){t||(t=T.identity);var i=!1;return e==null?i:y&&e.some===y?e.some(t,r):(N(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};T.contains=T.include=function(e,t){var n=!1;return e==null?n:b&&e.indexOf===b?e.indexOf(t)!=-1:(n=C(e,function(e){return e===t}),n)},T.invoke=function(e,t){var n=u.call(arguments,2);return T.map(e,function(e){return(T.isFunction(t)?t:e[t]).apply(e,n)})},T.pluck=function(e,t){return T.map(e,function(e){return e[t]})},T.where=function(e,t){return T.isEmpty(t)?[]:T.filter(e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},T.max=function(e,t,n){if(!t&&T.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);if(!t&&T.isEmpty(e))return-Infinity;var r={computed:-Infinity};return N(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},T.min=function(e,t,n){if(!t&&T.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);if(!t&&T.isEmpty(e))return Infinity;var r={computed:Infinity};return N(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o<r.computed&&(r={value:e,computed:o})}),r.value},T.shuffle=function(e){var t,n=0,r=[];return N(e,function(e){t=T.random(n++),r[n-1]=r[t],r[t]=e}),r};var k=function(e){return T.isFunction(e)?e:function(t){return t[e]}};T.sortBy=function(e,t,n){var r=k(t);return T.pluck(T.map(e,function(e,t,i){return{value:e,index:t,criteria:r.call(n,e,t,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(n<r||r===void 0)return-1}return e.index<t.index?-1:1}),"value")};var L=function(e,t,n,r){var i={},s=k(t);return N(e,function(t,o){var u=s.call(n,t,o,e);r(i,u,t)}),i};T.groupBy=function(e,t,n){return L(e,t,n,function(e,t,n){(T.has(e,t)?e[t]:e[t]=[]).push(n)})},T.countBy=function(e,t,n){return L(e,t,n,function(e,t,n){T.has(e,t)||(e[t]=0),e[t]++})},T.sortedIndex=function(e,t,n,r){n=n==null?T.identity:k(n);var i=n.call(r,t),s=0,o=e.length;while(s<o){var u=s+o>>>1;n.call(r,e[u])<i?s=u+1:o=u}return s},T.toArray=function(e){return e?e.length===+e.length?u.call(e):T.values(e):[]},T.size=function(e){return e.length===+e.length?e.length:T.keys(e).length},T.first=T.head=T.take=function(e,t,n){return t!=null&&!n?u.call(e,0,t):e[0]},T.initial=function(e,t,n){return u.call(e,0,e.length-(t==null||n?1:t))},T.last=function(e,t,n){return t!=null&&!n?u.call(e,Math.max(e.length-t,0)):e[e.length-1]},T.rest=T.tail=T.drop=function(e,t,n){return u.call(e,t==null||n?1:t)},T.compact=function(e){return T.filter(e,function(e){return!!e})};var A=function(e,t,n){return N(e,function(e){T.isArray(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n};T.flatten=function(e,t){return A(e,t,[])},T.without=function(e){return T.difference(e,u.call(arguments,1))},T.uniq=T.unique=function(e,t,n,r){var i=n?T.map(e,n,r):e,s=[],o=[];return N(i,function(n,r){if(t?!r||o[o.length-1]!==n:!T.contains(o,n))o.push(n),s.push(e[r])}),s},T.union=function(){return T.uniq(a.apply(r,arguments))},T.intersection=function(e){var t=u.call(arguments,1);return T.filter(T.uniq(e),function(e){return T.every(t,function(t){return T.indexOf(t,e)>=0})})},T.difference=function(e){var t=a.apply(r,u.call(arguments,1));return T.filter(e,function(e){return!T.contains(t,e)})},T.zip=function(){var e=u.call(arguments),t=T.max(T.pluck(e,"length")),n=new Array(t);for(var r=0;r<t;r++)n[r]=T.pluck(e,""+r);return n},T.object=function(e,t){var n={};for(var r=0,i=e.length;r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},T.indexOf=function(e,t,n){if(e==null)return-1;var r=0,i=e.length;if(n){if(typeof n!="number")return r=T.sortedIndex(e,t),e[r]===t?r:-1;r=n<0?Math.max(0,i+n):n}if(b&&e.indexOf===b)return e.indexOf(t,n);for(;r<i;r++)if(e[r]===t)return r;return-1},T.lastIndexOf=function(e,t,n){if(e==null)return-1;var r=n!=null;if(w&&e.lastIndexOf===w)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);var i=r?n:e.length;while(i--)if(e[i]===t)return i;return-1},T.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=arguments[2]||1;var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=new Array(r);while(i<r)s[i++]=e,e+=n;return s};var O=function(){};T.bind=function(t,n){var r,i;if(t.bind===x&&x)return x.apply(t,u.call(arguments,1));if(!T.isFunction(t))throw new TypeError;return i=u.call(arguments,2),r=function(){if(this instanceof r){O.prototype=t.prototype;var e=new O,s=t.apply(e,i.concat(u.call(arguments)));return Object(s)===s?s:e}return t.apply(n,i.concat(u.call(arguments)))}},T.bindAll=function(e){var t=u.call(arguments,1);return t.length==0&&(t=T.functions(e)),N(t,function(t){e[t]=T.bind(e[t],e)}),e},T.memoize=function(e,t){var n={};return t||(t=T.identity),function(){var r=t.apply(this,arguments);return T.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},T.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},T.defer=function(e){return T.delay.apply(T,[e,1].concat(u.call(arguments,1)))},T.throttle=function(e,t){var n,r,i,s,o,u,a=T.debounce(function(){o=s=!1},t);return function(){n=this,r=arguments;var f=function(){i=null,o&&(u=e.apply(n,r)),a()};return i||(i=setTimeout(f,t)),s?o=!0:(s=!0,u=e.apply(n,r)),a(),u}},T.debounce=function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},T.once=function(e){var t=!1,n;return function(){return t?n:(t=!0,n=e.apply(this,arguments),e=null,n)}},T.wrap=function(e,t){return function(){var n=[e];return o.apply(n,arguments),t.apply(this,n)}},T.compose=function(){var e=arguments;return function(){var t=arguments;for(var n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},T.after=function(e,t){return e<=0?t():function(){if(--e<1)return t.apply(this,arguments)}},T.keys=S||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)T.has(e,n)&&(t[t.length]=n);return t},T.values=function(e){var t=[];for(var n in e)T.has(e,n)&&t.push(e[n]);return t},T.pairs=function(e){var t=[];for(var n in e)T.has(e,n)&&t.push([n,e[n]]);return t},T.invert=function(e){var t={};for(var n in e)T.has(e,n)&&(t[e[n]]=n);return t},T.functions=T.methods=function(e){var t=[];for(var n in e)T.isFunction(e[n])&&t.push(n);return t.sort()},T.extend=function(e){return N(u.call(arguments,1),function(t){for(var n in t)e[n]=t[n]}),e},T.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return N(n,function(n){n in e&&(t[n]=e[n])}),t},T.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)T.contains(n,i)||(t[i]=e[i]);return t},T.defaults=function(e){return N(u.call(arguments,1),function(t){for(var n in t)e[n]==null&&(e[n]=t[n])}),e},T.clone=function(e){return T.isObject(e)?T.isArray(e)?e.slice():T.extend({},e):e},T.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof T&&(e=e._wrapped),t instanceof T&&(t=t._wrapped);var i=l.call(e);if(i!=l.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;n.push(e),r.push(t);var o=0,u=!0;if(i=="[object Array]"){o=e.length,u=o==t.length;if(u)while(o--)if(!(u=M(e[o],t[o],n,r)))break}else{var a=e.constructor,f=t.constructor;if(a!==f&&!(T.isFunction(a)&&a instanceof a&&T.isFunction(f)&&f instanceof f))return!1;for(var c in e)if(T.has(e,c)){o++;if(!(u=T.has(t,c)&&M(e[c],t[c],n,r)))break}if(u){for(c in t)if(T.has(t,c)&&!(o--))break;u=!o}}return n.pop(),r.pop(),u};T.isEqual=function(e,t){return M(e,t,[],[])},T.isEmpty=function(e){if(e==null)return!0;if(T.isArray(e)||T.isString(e))return e.length===0;for(var t in e)if(T.has(e,t))return!1;return!0},T.isElement=function(e){return!!e&&e.nodeType===1},T.isArray=E||function(e){return l.call(e)=="[object Array]"},T.isObject=function(e){return e===Object(e)},N(["Arguments","Function","String","Number","Date","RegExp"],function(e){T["is"+e]=function(t){return l.call(t)=="[object "+e+"]"}}),T.isArguments(arguments)||(T.isArguments=function(e){return!!e&&!!T.has(e,"callee")}),typeof /./!="function"&&(T.isFunction=function(e){return typeof e=="function"}),T.isFinite=function(e){return T.isNumber(e)&&isFinite(e)},T.isNaN=function(e){return T.isNumber(e)&&e!=+e},T.isBoolean=function(e){return e===!0||e===!1||l.call(e)=="[object Boolean]"},T.isNull=function(e){return e===null},T.isUndefined=function(e){return e===void 0},T.has=function(e,t){return c.call(e,t)},T.noConflict=function(){return e._=t,this},T.identity=function(e){return e},T.times=function(e,t,n){for(var r=0;r<e;r++)t.call(n,r)},T.random=function(e,t){return t==null&&(t=e,e=0),e+(0|Math.random()*(t-e+1))};var _={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"}};_.unescape=T.invert(_.escape);var D={escape:new RegExp("["+T.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+T.keys(_.unescape).join("|")+")","g")};T.each(["escape","unescape"],function(e){T[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),T.result=function(e,t){if(e==null)return null;var n=e[t];return T.isFunction(n)?n.call(e):n},T.mixin=function(e){N(T.functions(e),function(t){var n=T[t]=e[t];T.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(T,e))}})};var P=0;T.uniqueId=function(e){var t=P++;return e?e+t:t},T.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;T.template=function(e,t,n){n=T.defaults({},n,T.templateSettings);var r=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),i=0,s="__p+='";e.replace(r,function(t,n,r,o,u){s+=e.slice(i,u).replace(j,function(e){return"\\"+B[e]}),s+=n?"'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?"'+\n((__t=("+r+"))==null?'':__t)+\n'":o?"';\n"+o+"\n__p+='":"",i=u+t.length}),s+="';\n",n.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n";try{var o=new Function(n.variable||"obj","_",s)}catch(u){throw u.source=s,u}if(t)return o(t,T);var a=function(e){return o.call(this,e,T)};return a.source="function("+(n.variable||"obj")+"){\n"+s+"}",a},T.chain=function(e){return T(e).chain()};var F=function(e){return this._chain?T(e).chain():e};T.mixin(T),N(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];T.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),N(["concat","join","slice"],function(e){var t=r[e];T.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),T.extend(T.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);