mongo3 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/README.rdoc +6 -2
  2. data/Rakefile +1 -0
  3. data/data/populate +13 -11
  4. data/lib/controllers/databases.rb +3 -3
  5. data/lib/controllers/explore.rb +7 -5
  6. data/lib/helpers/main_helper.rb +24 -0
  7. data/lib/mongo3/connection.rb +105 -59
  8. data/lib/mongo3/node.rb +35 -6
  9. data/lib/mongo3.rb +1 -1
  10. data/lib/public/javascripts/{Jit/jit.js → jit.js} +0 -0
  11. data/lib/views/databases/_results.erb +29 -12
  12. data/lib/views/explore/explore.erb +52 -31
  13. data/lib/views/layout.erb +2 -6
  14. data/spec/mongo3/connection_spec.rb +40 -6
  15. metadata +13 -45
  16. data/lib/public/javascripts/Jit/Examples/Hypertree/example1.html +0 -57
  17. data/lib/public/javascripts/Jit/Examples/Hypertree/example1.js +0 -427
  18. data/lib/public/javascripts/Jit/Examples/Hypertree/example2.html +0 -58
  19. data/lib/public/javascripts/Jit/Examples/Hypertree/example2.js +0 -310
  20. data/lib/public/javascripts/Jit/Examples/Hypertree/example3.html +0 -199
  21. data/lib/public/javascripts/Jit/Examples/Hypertree/example3.js +0 -615
  22. data/lib/public/javascripts/Jit/Examples/Other/example1.html +0 -58
  23. data/lib/public/javascripts/Jit/Examples/Other/example1.js +0 -566
  24. data/lib/public/javascripts/Jit/Examples/Other/example2.html +0 -58
  25. data/lib/public/javascripts/Jit/Examples/Other/example2.js +0 -304
  26. data/lib/public/javascripts/Jit/Examples/Other/example3.html +0 -58
  27. data/lib/public/javascripts/Jit/Examples/Other/example3.js +0 -304
  28. data/lib/public/javascripts/Jit/Examples/RGraph/example1.html +0 -57
  29. data/lib/public/javascripts/Jit/Examples/RGraph/example1.js +0 -475
  30. data/lib/public/javascripts/Jit/Examples/RGraph/example2.html +0 -58
  31. data/lib/public/javascripts/Jit/Examples/RGraph/example2.js +0 -356
  32. data/lib/public/javascripts/Jit/Examples/RGraph/example3.html +0 -199
  33. data/lib/public/javascripts/Jit/Examples/RGraph/example3.js +0 -622
  34. data/lib/public/javascripts/Jit/Examples/Spacetree/example1.html +0 -91
  35. data/lib/public/javascripts/Jit/Examples/Spacetree/example1.js +0 -890
  36. data/lib/public/javascripts/Jit/Examples/Spacetree/example2.html +0 -90
  37. data/lib/public/javascripts/Jit/Examples/Spacetree/example2.js +0 -213
  38. data/lib/public/javascripts/Jit/Examples/Spacetree/example3.html +0 -75
  39. data/lib/public/javascripts/Jit/Examples/Spacetree/example3.js +0 -863
  40. data/lib/public/javascripts/Jit/Examples/Treemap/example1.html +0 -56
  41. data/lib/public/javascripts/Jit/Examples/Treemap/example1.js +0 -95
  42. data/lib/public/javascripts/Jit/Examples/Treemap/example2.html +0 -61
  43. data/lib/public/javascripts/Jit/Examples/Treemap/example2.js +0 -750
  44. data/lib/public/javascripts/Jit/Examples/Treemap/example3.html +0 -62
  45. data/lib/public/javascripts/Jit/Examples/Treemap/example3.js +0 -775
  46. data/lib/public/javascripts/Jit/Examples/css/Hypertree.css +0 -0
  47. data/lib/public/javascripts/Jit/Examples/css/Other.css +0 -8
  48. data/lib/public/javascripts/Jit/Examples/css/RGraph.css +0 -0
  49. data/lib/public/javascripts/Jit/Examples/css/Spacetree.css +0 -0
  50. data/lib/public/javascripts/Jit/Examples/css/Treemap.css +0 -78
  51. data/lib/public/javascripts/Jit/Examples/css/base.css +0 -106
  52. data/lib/public/javascripts/Jit/Examples/css/col1.png +0 -0
  53. data/lib/public/javascripts/Jit/Examples/css/col2.png +0 -0
  54. data/lib/public/javascripts/Jit/Examples/css/gradient.png +0 -0
  55. data/lib/public/javascripts/Jit/Extras/excanvas.js +0 -35
  56. data/lib/public/javascripts/Jit/jit-yc.js +0 -1
  57. data/lib/public/javascripts/Jit-1.1.3.zip +0 -0
@@ -1,622 +0,0 @@
1
- var Log = {
2
- elem: false,
3
- write: function(text){
4
- if (!this.elem)
5
- this.elem = document.getElementById('log');
6
- this.elem.innerHTML = text;
7
- this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px';
8
- }
9
- };
10
-
11
- function addEvent(obj, type, fn) {
12
- if (obj.addEventListener) obj.addEventListener(type, fn, false);
13
- else obj.attachEvent('on' + type, fn);
14
- };
15
-
16
-
17
- function init(){
18
- var infovis = document.getElementById('infovis');
19
- var w = infovis.offsetWidth, h = infovis.offsetHeight;
20
-
21
- //init data
22
- var json = {
23
- "id": "190_0",
24
- "name": "Pearl Jam",
25
- "children": [{
26
- "id": "306208_1",
27
- "name": "Pearl Jam & Cypress Hill",
28
- "data": {
29
- "band": "Pearl Jam",
30
- "relation": "collaboration"
31
- },
32
- "children": [{
33
- "id": "84_2",
34
- "name": "Cypress Hill",
35
- "data": {
36
- "band": "Pearl Jam & Cypress Hill",
37
- "relation": "collaboration"
38
- },
39
- "children": []
40
- }]
41
- }, {
42
- "id": "107877_3",
43
- "name": "Neil Young & Pearl Jam",
44
- "data": {
45
- "band": "Pearl Jam",
46
- "relation": "collaboration"
47
- },
48
- "children": [{
49
- "id": "964_4",
50
- "name": "Neil Young",
51
- "data": {
52
- "band": "Neil Young & Pearl Jam",
53
- "relation": "collaboration"
54
- },
55
- "children": []
56
- }]
57
- }, {
58
- "id": "236797_5",
59
- "name": "Jeff Ament",
60
- "data": {
61
- "band": "Pearl Jam",
62
- "relation": "member of band"
63
- },
64
- "children": [{
65
- "id": "1756_6",
66
- "name": "Temple of the Dog",
67
- "data": {
68
- "band": "Jeff Ament",
69
- "relation": "member of band"
70
- },
71
- "children": []
72
- }, {
73
- "id": "14581_7",
74
- "name": "Mother Love Bone",
75
- "data": {
76
- "band": "Jeff Ament",
77
- "relation": "member of band"
78
- },
79
- "children": []
80
- }, {
81
- "id": "50188_8",
82
- "name": "Green River",
83
- "data": {
84
- "band": "Jeff Ament",
85
- "relation": "member of band"
86
- },
87
- "children": []
88
- }, {
89
- "id": "65452_9",
90
- "name": "M.A.C.C.",
91
- "data": {
92
- "band": "Jeff Ament",
93
- "relation": "collaboration"
94
- },
95
- "children": []
96
- }, {
97
- "id": "115632_10",
98
- "name": "Three Fish",
99
- "data": {
100
- "band": "Jeff Ament",
101
- "relation": "member of band"
102
- },
103
- "children": []
104
- }, {
105
- "id": "346850_11",
106
- "name": "Gossman Project",
107
- "data": {
108
- "band": "Jeff Ament",
109
- "relation": "member of band"
110
- },
111
- "children": []
112
- }]
113
- }, {
114
- "id": "41529_12",
115
- "name": "Stone Gossard",
116
- "data": {
117
- "band": "Pearl Jam",
118
- "relation": "member of band"
119
- },
120
- "children": [{
121
- "id": "1756_13",
122
- "name": "Temple of the Dog",
123
- "data": {
124
- "band": "Stone Gossard",
125
- "relation": "member of band"
126
- },
127
- "children": []
128
- }, {
129
- "id": "14581_14",
130
- "name": "Mother Love Bone",
131
- "data": {
132
- "band": "Stone Gossard",
133
- "relation": "member of band"
134
- },
135
- "children": []
136
- }, {
137
- "id": "24119_15",
138
- "name": "Brad",
139
- "data": {
140
- "band": "Stone Gossard",
141
- "relation": "member of band"
142
- },
143
- "children": []
144
- }, {
145
- "id": "50188_16",
146
- "name": "Green River",
147
- "data": {
148
- "band": "Stone Gossard",
149
- "relation": "member of band"
150
- },
151
- "children": []
152
- }, {
153
- "id": "346850_17",
154
- "name": "Gossman Project",
155
- "data": {
156
- "band": "Stone Gossard",
157
- "relation": "member of band"
158
- },
159
- "children": []
160
- }]
161
- }, {
162
- "id": "131161_18",
163
- "name": "Eddie Vedder",
164
- "data": {
165
- "band": "Pearl Jam",
166
- "relation": "member of band"
167
- },
168
- "children": [{
169
- "id": "1756_19",
170
- "name": "Temple of the Dog",
171
- "data": {
172
- "band": "Eddie Vedder",
173
- "relation": "member of band"
174
- },
175
- "children": []
176
- }, {
177
- "id": "72007_20",
178
- "name": "Eddie Vedder & Zeke",
179
- "data": {
180
- "band": "Eddie Vedder",
181
- "relation": "collaboration"
182
- },
183
- "children": []
184
- }, {
185
- "id": "236657_21",
186
- "name": "Bad Radio",
187
- "data": {
188
- "band": "Eddie Vedder",
189
- "relation": "member of band"
190
- },
191
- "children": []
192
- }, {
193
- "id": "432176_22",
194
- "name": "Beck & Eddie Vedder",
195
- "data": {
196
- "band": "Eddie Vedder",
197
- "relation": "collaboration"
198
- },
199
- "children": []
200
- }]
201
- }, {
202
- "id": "236583_23",
203
- "name": "Mike McCready",
204
- "data": {
205
- "band": "Pearl Jam",
206
- "relation": "member of band"
207
- },
208
- "children": [{
209
- "id": "1744_24",
210
- "name": "Mad Season",
211
- "data": {
212
- "band": "Mike McCready",
213
- "relation": "member of band"
214
- },
215
- "children": []
216
- }, {
217
- "id": "1756_25",
218
- "name": "Temple of the Dog",
219
- "data": {
220
- "band": "Mike McCready",
221
- "relation": "member of band"
222
- },
223
- "children": []
224
- }, {
225
- "id": "43661_26",
226
- "name": "$10,000 Gold Chain",
227
- "data": {
228
- "band": "Mike McCready",
229
- "relation": "collaboration"
230
- },
231
- "children": []
232
- }, {
233
- "id": "65452_27",
234
- "name": "M.A.C.C.",
235
- "data": {
236
- "band": "Mike McCready",
237
- "relation": "collaboration"
238
- },
239
- "children": []
240
- }, {
241
- "id": "153766_28",
242
- "name": "The Rockfords",
243
- "data": {
244
- "band": "Mike McCready",
245
- "relation": "member of band"
246
- },
247
- "children": []
248
- }, {
249
- "id": "346850_29",
250
- "name": "Gossman Project",
251
- "data": {
252
- "band": "Mike McCready",
253
- "relation": "member of band"
254
- },
255
- "children": []
256
- }]
257
- }, {
258
- "id": "236585_30",
259
- "name": "Matt Cameron",
260
- "data": {
261
- "band": "Pearl Jam",
262
- "relation": "member of band"
263
- },
264
- "children": [{
265
- "id": "1111_31",
266
- "name": "Soundgarden",
267
- "data": {
268
- "band": "Matt Cameron",
269
- "relation": "member of band"
270
- },
271
- "children": []
272
- }, {
273
- "id": "1756_32",
274
- "name": "Temple of the Dog",
275
- "data": {
276
- "band": "Matt Cameron",
277
- "relation": "member of band"
278
- },
279
- "children": []
280
- }, {
281
- "id": "9570_33",
282
- "name": "Eleven",
283
- "data": {
284
- "band": "Matt Cameron",
285
- "relation": "supporting musician"
286
- },
287
- "children": []
288
- }, {
289
- "id": "11783_34",
290
- "name": "Queens of the Stone Age",
291
- "data": {
292
- "band": "Matt Cameron",
293
- "relation": "member of band"
294
- },
295
- "children": []
296
- }, {
297
- "id": "61972_35",
298
- "name": "Wellwater Conspiracy",
299
- "data": {
300
- "band": "Matt Cameron",
301
- "relation": "member of band"
302
- },
303
- "children": []
304
- }, {
305
- "id": "65452_36",
306
- "name": "M.A.C.C.",
307
- "data": {
308
- "band": "Matt Cameron",
309
- "relation": "collaboration"
310
- },
311
- "children": []
312
- }, {
313
- "id": "353097_37",
314
- "name": "Tone Dogs",
315
- "data": {
316
- "band": "Matt Cameron",
317
- "relation": "member of band"
318
- },
319
- "children": []
320
- }]
321
- }, {
322
- "id": "236594_38",
323
- "name": "Dave Krusen",
324
- "data": {
325
- "band": "Pearl Jam",
326
- "relation": "member of band"
327
- },
328
- "children": [{
329
- "id": "2092_39",
330
- "name": "Candlebox",
331
- "data": {
332
- "band": "Dave Krusen",
333
- "relation": "member of band"
334
- },
335
- "children": []
336
- }]
337
- }, {
338
- "id": "236022_40",
339
- "name": "Matt Chamberlain",
340
- "data": {
341
- "band": "Pearl Jam",
342
- "relation": "member of band"
343
- },
344
- "children": [{
345
- "id": "54761_41",
346
- "name": "Critters Buggin",
347
- "data": {
348
- "band": "Matt Chamberlain",
349
- "relation": "member of band"
350
- },
351
- "children": []
352
- }, {
353
- "id": "92043_42",
354
- "name": "Edie Brickell and New Bohemians",
355
- "data": {
356
- "band": "Matt Chamberlain",
357
- "relation": "member of band"
358
- },
359
- "children": []
360
- }]
361
- }, {
362
- "id": "236611_43",
363
- "name": "Dave Abbruzzese",
364
- "data": {
365
- "band": "Pearl Jam",
366
- "relation": "member of band"
367
- },
368
- "children": [{
369
- "id": "276933_44",
370
- "name": "Green Romance Orchestra",
371
- "data": {
372
- "band": "Dave Abbruzzese",
373
- "relation": "member of band"
374
- },
375
- "children": []
376
- }]
377
- }, {
378
- "id": "236612_45",
379
- "name": "Jack Irons",
380
- "data": {
381
- "band": "Pearl Jam",
382
- "relation": "member of band"
383
- },
384
- "children": [{
385
- "id": "4619_46",
386
- "name": "Redd Kross",
387
- "data": {
388
- "band": "Jack Irons",
389
- "relation": "member of band"
390
- },
391
- "children": []
392
- }, {
393
- "id": "9570_47",
394
- "name": "Eleven",
395
- "data": {
396
- "band": "Jack Irons",
397
- "relation": "member of band"
398
- },
399
- "children": []
400
- }, {
401
- "id": "12389_48",
402
- "name": "Red Hot Chili Peppers",
403
- "data": {
404
- "band": "Jack Irons",
405
- "relation": "member of band"
406
- },
407
- "children": []
408
- }, {
409
- "id": "114288_49",
410
- "name": "Anthym",
411
- "data": {
412
- "band": "Jack Irons",
413
- "relation": "member of band"
414
- },
415
- "children": []
416
- }, {
417
- "id": "240013_50",
418
- "name": "What Is This?",
419
- "data": {
420
- "band": "Jack Irons",
421
- "relation": "member of band"
422
- },
423
- "children": []
424
- }]
425
- }],
426
- "data": []
427
- };
428
-
429
- var graph = '[{id:"190_0", adjacencies:["node0"]}, {id:"node0", name:"node0 name", data:{$dim:8.660354683365695, "some other key":"some other value"}, adjacencies:["node1", "node2", "node3", "node4", "node5"]}, {id:"node1", name:"node1 name", data:{$dim:21.118129724156983, "some other key":"some other value"}, adjacencies:["node0", "node2", "node3", "node4", "node5"]}, {id:"node2", name:"node2 name", data:{$dim:6.688951018413683, "some other key":"some other value"}, adjacencies:["node0", "node1", "node3", "node4", "node5"]}, {id:"node3", name:"node3 name", data:{$dim:19.78771599710248, "some other key":"some other value"}, adjacencies:["node0", "node1", "node2", "node4", "node5"]}, {id:"node4", name:"node4 name", data:{$dim:3.025781742947326, "some other key":"some other value"}, adjacencies:["node0", "node1", "node2", "node3", "node5"]}, {id:"node5", name:"node5 name", data:{$dim:9.654383829711456, "some other key":"some other value"}, adjacencies:["node0", "node1", "node2", "node3", "node4"]}, {id:"4619_46", adjacencies:["190_0"]}, {id:"236585_30", adjacencies:["190_0"]}, {id:"131161_18", adjacencies:["190_0"]}, {id:"41529_12", adjacencies:["190_0"]}]';
430
- //end
431
-
432
- //init canvas
433
- //Create a new canvas instance.
434
- var canvas = new Canvas('mycanvas', {
435
- 'injectInto': 'infovis',
436
- 'width': w,
437
- 'height': h,
438
- //Optional: Create a background canvas
439
- //for painting concentric circles.
440
- 'backgroundCanvas': {
441
- 'styles': {
442
- 'strokeStyle': '#444'
443
- },
444
- 'impl': {
445
- 'init': function(){},
446
- 'plot': function(canvas, ctx){
447
- var times = 6, d = 100;
448
- var pi2 = Math.PI * 2;
449
- for (var i = 1; i <= times; i++) {
450
- ctx.beginPath();
451
- ctx.arc(0, 0, i * d, 0, pi2, true);
452
- ctx.stroke();
453
- ctx.closePath();
454
- }
455
- }
456
- }
457
- }
458
- });
459
- //end
460
- //init RGraph
461
- var rgraph = new RGraph(canvas, {
462
- //Set Edge and Node colors.
463
- Node: {
464
- color: '#ccddee'
465
- },
466
-
467
- Edge: {
468
- color: '#772277'
469
- },
470
- //Add the node's name into the label
471
- //This method is called only once, on label creation.
472
- onCreateLabel: function(domElement, node){
473
- domElement.innerHTML = node.name;
474
- },
475
-
476
- //Change the node's style based on its position.
477
- //This method is called each time a label is rendered/positioned
478
- //during an animation.
479
- onPlaceLabel: function(domElement, node){
480
- var style = domElement.style;
481
- style.display = '';
482
-
483
- if (node._depth <= 1) {
484
- style.fontSize = "0.8em";
485
- style.color = "#ccc";
486
-
487
- } else if(node._depth == 2){
488
- style.fontSize = "0.7em";
489
- style.color = "#494949";
490
-
491
- } else {
492
- style.display = 'none';
493
- }
494
-
495
- var left = parseInt(style.left);
496
- var w = domElement.offsetWidth;
497
- style.left = (left - w / 2) + 'px';
498
- }
499
- });
500
- //load JSON data.
501
- rgraph.loadJSON(json);
502
-
503
- //add some extra edges to the tree
504
- //to make it a graph (just for fun)
505
- rgraph.graph.addAdjacence({
506
- 'id': '236585_30'
507
- }, {
508
- 'id': '236583_23'
509
- }, null);
510
- rgraph.graph.addAdjacence({
511
- 'id': '236585_30'
512
- }, {
513
- 'id': '4619_46'
514
- }, null);
515
-
516
- //Compute positions and plot
517
- rgraph.refresh();
518
- //end
519
-
520
- //Global Options
521
- //Define a function that returns the selected duration
522
- function getDuration() {
523
- var sduration = document.getElementById('select-duration');
524
- var sdindex = sduration.selectedIndex;
525
- return parseInt(sduration.options[sdindex].text);
526
- };
527
- //Define a function that returns the selected fps
528
- function getFPS() {
529
- var fpstype = document.getElementById('select-fps');
530
- var fpsindex = fpstype.selectedIndex;
531
- return parseInt(fpstype.options[fpsindex].text);
532
- };
533
- //Define a function that returns whether you have to
534
- //hide labels during the animation or not.
535
- function hideLabels() {
536
- return document.getElementById('hide-labels').checked;
537
- };
538
-
539
- //init handlers
540
- //Add event handlers to the right column controls.
541
-
542
- //Remove Nodes
543
- var button = document.getElementById('remove-nodes');
544
- button.onclick = function() {
545
- //get animation type.
546
- var stype = document.getElementById('select-type-remove-nodes');
547
- var sindex = stype.selectedIndex;
548
- var type = stype.options[sindex].text;
549
- //get node ids to be removed.
550
- var subnodes = Graph.Util.getSubnodes(rgraph.graph.getNode('236797_5'), 0);
551
- var map = [];
552
- for (var i = 0; i < subnodes.length; i++) {
553
- map.push(subnodes[i].id);
554
- }
555
- //perform node-removing animation.
556
- rgraph.op.removeNode(map.reverse(), {
557
- type: type,
558
- duration: getDuration(),
559
- fps: getFPS(),
560
- hideLabels:hideLabels()
561
- });
562
- };
563
-
564
- //Remove edges
565
- button = document.getElementById('remove-edges');
566
- button.onclick = function() {
567
- //get animation type.
568
- var stype = document.getElementById('select-type-remove-edges');
569
- var sindex = stype.selectedIndex;
570
- var type = stype.options[sindex].text;
571
- //perform edge removing animation.
572
- rgraph.op.removeEdge([['236585_30', "190_0"], ['236585_30', '4619_46']], {
573
- type: type,
574
- duration: getDuration(),
575
- fps: getFPS(),
576
- hideLabels: hideLabels()
577
- });
578
- };
579
-
580
- //Add a Graph (Sum)
581
- button = document.getElementById('sum');
582
- button.onclick = function(){
583
- //get graph to add.
584
- var trueGraph = eval('(' + graph + ')');
585
- //get animation type.
586
- var stype = document.getElementById('select-type-sum');
587
- var sindex = stype.selectedIndex;
588
- var type = stype.options[sindex].text;
589
- //perform sum animation.
590
- rgraph.op.sum(trueGraph, {
591
- type: type,
592
- fps: getFPS(),
593
- duration: getDuration(),
594
- hideLabels: hideLabels(),
595
- onComplete: function(){
596
- Log.write("sum complete!");
597
- }
598
- });
599
- };
600
-
601
- //Morph
602
- button = document.getElementById('morph');
603
- button.onclick = function(){
604
- //get graph to morph to.
605
- var trueGraph = eval('(' + graph + ')');
606
- //get animation type.
607
- var stype = document.getElementById('select-type-morph');
608
- var sindex = stype.selectedIndex;
609
- var type = stype.options[sindex].text;
610
- //perform morphing animation.
611
- rgraph.op.morph(trueGraph, {
612
- type: type,
613
- fps: getFPS(),
614
- duration: getDuration(),
615
- hideLabels: hideLabels(),
616
- onComplete: function(){
617
- Log.write("morph complete!");
618
- }
619
- });
620
- };
621
- //end
622
- }