cans 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,324 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/SyntaxHighlighter
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
7
+ *
8
+ * @version
9
+ * 3.0.83 (July 02 2010)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2010 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * Dual licensed under the MIT and GPL licenses.
16
+ */
17
+ .syntaxhighlighter a,
18
+ .syntaxhighlighter div,
19
+ .syntaxhighlighter code,
20
+ .syntaxhighlighter table,
21
+ .syntaxhighlighter table td,
22
+ .syntaxhighlighter table tr,
23
+ .syntaxhighlighter table tbody,
24
+ .syntaxhighlighter table thead,
25
+ .syntaxhighlighter table caption,
26
+ .syntaxhighlighter textarea {
27
+ -moz-border-radius: 0 0 0 0 !important;
28
+ -webkit-border-radius: 0 0 0 0 !important;
29
+ background: none !important;
30
+ border: 0 !important;
31
+ bottom: auto !important;
32
+ float: none !important;
33
+ height: auto !important;
34
+ left: auto !important;
35
+ line-height: 1.1em !important;
36
+ margin: 0 !important;
37
+ outline: 0 !important;
38
+ /* overflow: visible !important; */
39
+ padding: 0 !important;
40
+ position: static !important;
41
+ right: auto !important;
42
+ text-align: left !important;
43
+ top: auto !important;
44
+ vertical-align: baseline !important;
45
+ width: auto !important;
46
+ box-sizing: content-box !important;
47
+ font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important;
48
+ font-weight: normal !important;
49
+ font-style: normal !important;
50
+ font-size: 1em !important;
51
+ min-height: inherit !important;
52
+ min-height: auto !important;
53
+ }
54
+
55
+ .syntaxhighlighter {
56
+ width: 100% !important;
57
+ margin: 1em 0 1em 0 !important;
58
+ position: relative !important;
59
+ /* overflow: auto !important; */
60
+ font-size: 1em !important;
61
+ }
62
+ .syntaxhighlighter.source {
63
+ overflow: hidden !important;
64
+ }
65
+ .syntaxhighlighter .bold {
66
+ font-weight: bold !important;
67
+ }
68
+ .syntaxhighlighter .italic {
69
+ font-style: italic !important;
70
+ }
71
+ .syntaxhighlighter .line {
72
+ white-space: pre !important;
73
+ }
74
+ .syntaxhighlighter table {
75
+ width: 100% !important;
76
+ }
77
+ .syntaxhighlighter table caption {
78
+ text-align: left !important;
79
+ padding: .5em 0 0.5em 1em !important;
80
+ }
81
+ .syntaxhighlighter table td.code {
82
+ width: 100% !important;
83
+ }
84
+ .syntaxhighlighter table td.code .container {
85
+ position: relative !important;
86
+ }
87
+ .syntaxhighlighter table td.code .container textarea {
88
+ box-sizing: border-box !important;
89
+ position: absolute !important;
90
+ left: 0 !important;
91
+ top: 0 !important;
92
+ width: 100% !important;
93
+ height: 100% !important;
94
+ border: none !important;
95
+ background: white !important;
96
+ padding-left: 1em !important;
97
+ overflow: hidden !important;
98
+ white-space: pre !important;
99
+ }
100
+ .syntaxhighlighter table td.gutter .line {
101
+ text-align: right !important;
102
+ padding: 0 0.5em 0 1em !important;
103
+ }
104
+ .syntaxhighlighter table td.code .line {
105
+ padding: 0 1em !important;
106
+ }
107
+ .syntaxhighlighter.nogutter td.code .container textarea, .syntaxhighlighter.nogutter td.code .line {
108
+ padding-left: 0em !important;
109
+ }
110
+ .syntaxhighlighter.show {
111
+ display: block !important;
112
+ }
113
+ .syntaxhighlighter.collapsed table {
114
+ display: none !important;
115
+ }
116
+ .syntaxhighlighter.collapsed .toolbar {
117
+ padding: 0.1em 0.8em 0em 0.8em !important;
118
+ font-size: 1em !important;
119
+ position: static !important;
120
+ width: auto !important;
121
+ height: auto !important;
122
+ }
123
+ .syntaxhighlighter.collapsed .toolbar span {
124
+ display: inline !important;
125
+ margin-right: 1em !important;
126
+ }
127
+ .syntaxhighlighter.collapsed .toolbar span a {
128
+ padding: 0 !important;
129
+ display: none !important;
130
+ }
131
+ .syntaxhighlighter.collapsed .toolbar span a.expandSource {
132
+ display: inline !important;
133
+ }
134
+ .syntaxhighlighter .toolbar {
135
+ position: absolute !important;
136
+ right: 1px !important;
137
+ top: 1px !important;
138
+ width: 11px !important;
139
+ height: 11px !important;
140
+ font-size: 10px !important;
141
+ z-index: 10 !important;
142
+ }
143
+ .syntaxhighlighter .toolbar span.title {
144
+ display: inline !important;
145
+ }
146
+ .syntaxhighlighter .toolbar a {
147
+ display: block !important;
148
+ text-align: center !important;
149
+ text-decoration: none !important;
150
+ padding-top: 1px !important;
151
+ }
152
+ .syntaxhighlighter .toolbar a.expandSource {
153
+ display: none !important;
154
+ }
155
+ .syntaxhighlighter.ie {
156
+ font-size: .9em !important;
157
+ padding: 1px 0 1px 0 !important;
158
+ }
159
+ .syntaxhighlighter.ie .toolbar {
160
+ line-height: 8px !important;
161
+ }
162
+ .syntaxhighlighter.ie .toolbar a {
163
+ padding-top: 0px !important;
164
+ }
165
+ .syntaxhighlighter.printing .line.alt1 .content,
166
+ .syntaxhighlighter.printing .line.alt2 .content,
167
+ .syntaxhighlighter.printing .line.highlighted .number,
168
+ .syntaxhighlighter.printing .line.highlighted.alt1 .content,
169
+ .syntaxhighlighter.printing .line.highlighted.alt2 .content {
170
+ background: none !important;
171
+ }
172
+ .syntaxhighlighter.printing .line .number {
173
+ color: #bbbbbb !important;
174
+ }
175
+ .syntaxhighlighter.printing .line .content {
176
+ color: black !important;
177
+ }
178
+ .syntaxhighlighter.printing .toolbar {
179
+ display: none !important;
180
+ }
181
+ .syntaxhighlighter.printing a {
182
+ text-decoration: none !important;
183
+ }
184
+ .syntaxhighlighter.printing .plain, .syntaxhighlighter.printing .plain a {
185
+ color: black !important;
186
+ }
187
+ .syntaxhighlighter.printing .comments, .syntaxhighlighter.printing .comments a {
188
+ color: #008200 !important;
189
+ }
190
+ .syntaxhighlighter.printing .string, .syntaxhighlighter.printing .string a {
191
+ color: blue !important;
192
+ }
193
+ .syntaxhighlighter.printing .keyword {
194
+ color: #006699 !important;
195
+ font-weight: bold !important;
196
+ }
197
+ .syntaxhighlighter.printing .preprocessor {
198
+ color: gray !important;
199
+ }
200
+ .syntaxhighlighter.printing .variable {
201
+ color: #aa7700 !important;
202
+ }
203
+ .syntaxhighlighter.printing .value {
204
+ color: #009900 !important;
205
+ }
206
+ .syntaxhighlighter.printing .functions {
207
+ color: #ff1493 !important;
208
+ }
209
+ .syntaxhighlighter.printing .constants {
210
+ color: #0066cc !important;
211
+ }
212
+ .syntaxhighlighter.printing .script {
213
+ font-weight: bold !important;
214
+ }
215
+ .syntaxhighlighter.printing .color1, .syntaxhighlighter.printing .color1 a {
216
+ color: gray !important;
217
+ }
218
+ .syntaxhighlighter.printing .color2, .syntaxhighlighter.printing .color2 a {
219
+ color: #ff1493 !important;
220
+ }
221
+ .syntaxhighlighter.printing .color3, .syntaxhighlighter.printing .color3 a {
222
+ color: red !important;
223
+ }
224
+ .syntaxhighlighter.printing .break, .syntaxhighlighter.printing .break a {
225
+ color: black !important;
226
+ }
227
+
228
+ .syntaxhighlighter {
229
+ background-color: #0f192a !important;
230
+ }
231
+ .syntaxhighlighter .line.alt1 {
232
+ background-color: #0f192a !important;
233
+ }
234
+ .syntaxhighlighter .line.alt2 {
235
+ background-color: #0f192a !important;
236
+ }
237
+ .syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 {
238
+ background-color: #253e5a !important;
239
+ }
240
+ .syntaxhighlighter .line.highlighted.number {
241
+ color: #38566f !important;
242
+ }
243
+ .syntaxhighlighter table caption {
244
+ color: #d1edff !important;
245
+ }
246
+ .syntaxhighlighter .gutter {
247
+ color: #afafaf !important;
248
+ }
249
+ .syntaxhighlighter .gutter .line {
250
+ border-right: 3px solid #435a5f !important;
251
+ }
252
+ .syntaxhighlighter .gutter .line.highlighted {
253
+ background-color: #435a5f !important;
254
+ color: #0f192a !important;
255
+ }
256
+ .syntaxhighlighter.printing .line .content {
257
+ border: none !important;
258
+ }
259
+ .syntaxhighlighter.collapsed {
260
+ overflow: visible !important;
261
+ }
262
+ .syntaxhighlighter.collapsed .toolbar {
263
+ color: #428bdd !important;
264
+ background: black !important;
265
+ border: 1px solid #435a5f !important;
266
+ }
267
+ .syntaxhighlighter.collapsed .toolbar a {
268
+ color: #428bdd !important;
269
+ }
270
+ .syntaxhighlighter.collapsed .toolbar a:hover {
271
+ color: #1dc116 !important;
272
+ }
273
+ .syntaxhighlighter .toolbar {
274
+ color: #d1edff !important;
275
+ background: #435a5f !important;
276
+ border: none !important;
277
+ }
278
+ .syntaxhighlighter .toolbar a {
279
+ color: #d1edff !important;
280
+ }
281
+ .syntaxhighlighter .toolbar a:hover {
282
+ color: #8aa6c1 !important;
283
+ }
284
+ .syntaxhighlighter .plain, .syntaxhighlighter .plain a {
285
+ color: #d1edff !important;
286
+ }
287
+ .syntaxhighlighter .comments, .syntaxhighlighter .comments a {
288
+ color: #428bdd !important;
289
+ }
290
+ .syntaxhighlighter .string, .syntaxhighlighter .string a {
291
+ color: #1dc116 !important;
292
+ }
293
+ .syntaxhighlighter .keyword {
294
+ color: #b43d3d !important;
295
+ }
296
+ .syntaxhighlighter .preprocessor {
297
+ color: #8aa6c1 !important;
298
+ }
299
+ .syntaxhighlighter .variable {
300
+ color: #ffaa3e !important;
301
+ }
302
+ .syntaxhighlighter .value {
303
+ color: #f7e741 !important;
304
+ }
305
+ .syntaxhighlighter .functions {
306
+ color: #ffaa3e !important;
307
+ }
308
+ .syntaxhighlighter .constants {
309
+ color: #e0e8ff !important;
310
+ }
311
+ .syntaxhighlighter .script {
312
+ font-weight: bold !important;
313
+ color: #b43d3d !important;
314
+ background-color: none !important;
315
+ }
316
+ .syntaxhighlighter .color1, .syntaxhighlighter .color1 a {
317
+ color: #f8bb00 !important;
318
+ }
319
+ .syntaxhighlighter .color2, .syntaxhighlighter .color2 a {
320
+ color: white !important;
321
+ }
322
+ .syntaxhighlighter .color3, .syntaxhighlighter .color3 a {
323
+ color: #ffaa3e !important;
324
+ }
@@ -0,0 +1,26 @@
1
+ // Underscore.js 1.1.6
2
+ // (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
3
+ // Underscore is freely distributable under the MIT license.
4
+ // Portions of Underscore are inspired or borrowed from Prototype,
5
+ // Oliver Steele's Functional, and John Resig's Micro-Templating.
6
+ // For all details and documentation:
7
+ // http://documentcloud.github.com/underscore
8
+ (function(){var p=this,C=p._,m={},i=Array.prototype,n=Object.prototype,f=i.slice,D=i.unshift,E=n.toString,l=n.hasOwnProperty,s=i.forEach,t=i.map,u=i.reduce,v=i.reduceRight,w=i.filter,x=i.every,y=i.some,o=i.indexOf,z=i.lastIndexOf;n=Array.isArray;var F=Object.keys,q=Function.prototype.bind,b=function(a){return new j(a)};typeof module!=="undefined"&&module.exports?(module.exports=b,b._=b):p._=b;b.VERSION="1.1.6";var h=b.each=b.forEach=function(a,c,d){if(a!=null)if(s&&a.forEach===s)a.forEach(c,d);else if(b.isNumber(a.length))for(var e=
9
+ 0,k=a.length;e<k;e++){if(c.call(d,a[e],e,a)===m)break}else for(e in a)if(l.call(a,e)&&c.call(d,a[e],e,a)===m)break};b.map=function(a,c,b){var e=[];if(a==null)return e;if(t&&a.map===t)return a.map(c,b);h(a,function(a,g,G){e[e.length]=c.call(b,a,g,G)});return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var k=d!==void 0;a==null&&(a=[]);if(u&&a.reduce===u)return e&&(c=b.bind(c,e)),k?a.reduce(c,d):a.reduce(c);h(a,function(a,b,f){!k&&b===0?(d=a,k=!0):d=c.call(e,d,a,b,f)});if(!k)throw new TypeError("Reduce of empty array with no initial value");
10
+ return d};b.reduceRight=b.foldr=function(a,c,d,e){a==null&&(a=[]);if(v&&a.reduceRight===v)return e&&(c=b.bind(c,e)),d!==void 0?a.reduceRight(c,d):a.reduceRight(c);a=(b.isArray(a)?a.slice():b.toArray(a)).reverse();return b.reduce(a,c,d,e)};b.find=b.detect=function(a,c,b){var e;A(a,function(a,g,f){if(c.call(b,a,g,f))return e=a,!0});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(w&&a.filter===w)return a.filter(c,b);h(a,function(a,g,f){c.call(b,a,g,f)&&(e[e.length]=a)});return e};
11
+ b.reject=function(a,c,b){var e=[];if(a==null)return e;h(a,function(a,g,f){c.call(b,a,g,f)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=!0;if(a==null)return e;if(x&&a.every===x)return a.every(c,b);h(a,function(a,g,f){if(!(e=e&&c.call(b,a,g,f)))return m});return e};var A=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=!1;if(a==null)return e;if(y&&a.some===y)return a.some(c,d);h(a,function(a,b,f){if(e=c.call(d,a,b,f))return m});return e};b.include=b.contains=function(a,c){var b=
12
+ !1;if(a==null)return b;if(o&&a.indexOf===o)return a.indexOf(c)!=-1;A(a,function(a){if(b=a===c)return!0});return b};b.invoke=function(a,c){var d=f.call(arguments,2);return b.map(a,function(a){return(c.call?c||a:a[c]).apply(a,d)})};b.pluck=function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);var e={computed:-Infinity};h(a,function(a,b,f){b=c?c.call(d,a,b,f):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,
13
+ c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};h(a,function(a,b,f){b=c?c.call(d,a,b,f):a;b<e.computed&&(e={value:a,computed:b})});return e.value};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,f){return{value:a,criteria:c.call(d,a,b,f)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=
14
+ function(a){if(!a)return[];if(a.toArray)return a.toArray();if(b.isArray(a))return a;if(b.isArguments(a))return f.call(a);return b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?f.call(a,0,b):a[0]};b.rest=b.tail=function(a,b,d){return f.call(a,b==null||d?1:b)};b.last=function(a){return a[a.length-1]};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a){return b.reduce(a,function(a,d){if(b.isArray(d))return a.concat(b.flatten(d));
15
+ a[a.length]=d;return a},[])};b.without=function(a){var c=f.call(arguments,1);return b.filter(a,function(a){return!b.include(c,a)})};b.uniq=b.unique=function(a,c){return b.reduce(a,function(a,e,f){if(0==f||(c===!0?b.last(a)!=e:!b.include(a,e)))a[a.length]=e;return a},[])};b.intersect=function(a){var c=f.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.zip=function(){for(var a=f.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),
16
+ e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(o&&a.indexOf===o)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(z&&a.lastIndexOf===z)return a.lastIndexOf(b);for(var d=a.length;d--;)if(a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);d=arguments[2]||1;for(var e=Math.max(Math.ceil((b-a)/
17
+ d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};b.bind=function(a,b){if(a.bind===q&&q)return q.apply(a,f.call(arguments,1));var d=f.call(arguments,2);return function(){return a.apply(b,d.concat(f.call(arguments)))}};b.bindAll=function(a){var c=f.call(arguments,1);c.length==0&&(c=b.functions(a));h(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var b=c.apply(this,arguments);return l.call(d,b)?d[b]:d[b]=a.apply(this,arguments)}};b.delay=
18
+ function(a,b){var d=f.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(f.call(arguments,1)))};var B=function(a,b,d){var e;return function(){var f=this,g=arguments,h=function(){e=null;a.apply(f,g)};d&&clearTimeout(e);if(d||!e)e=setTimeout(h,b)}};b.throttle=function(a,b){return B(a,b,!1)};b.debounce=function(a,b){return B(a,b,!0)};b.once=function(a){var b=!1,d;return function(){if(b)return d;b=!0;return d=a.apply(this,arguments)}};
19
+ b.wrap=function(a,b){return function(){var d=[a].concat(f.call(arguments));return b.apply(this,d)}};b.compose=function(){var a=f.call(arguments);return function(){for(var b=f.call(arguments),d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}};b.keys=F||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[],d;for(d in a)l.call(a,d)&&(b[b.length]=d);return b};b.values=function(a){return b.map(a,
20
+ b.identity)};b.functions=b.methods=function(a){return b.filter(b.keys(a),function(c){return b.isFunction(a[c])}).sort()};b.extend=function(a){h(f.call(arguments,1),function(b){for(var d in b)b[d]!==void 0&&(a[d]=b[d])});return a};b.defaults=function(a){h(f.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,c){if(a===c)return!0;var d=typeof a;if(d!=
21
+ typeof c)return!1;if(a==c)return!0;if(!a&&c||a&&!c)return!1;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual)return a.isEqual(c);if(b.isDate(a)&&b.isDate(c))return a.getTime()===c.getTime();if(b.isNaN(a)&&b.isNaN(c))return!1;if(b.isRegExp(a)&&b.isRegExp(c))return a.source===c.source&&a.global===c.global&&a.ignoreCase===c.ignoreCase&&a.multiline===c.multiline;if(d!=="object")return!1;if(a.length&&a.length!==c.length)return!1;d=b.keys(a);var e=b.keys(c);if(d.length!=e.length)return!1;
22
+ for(var f in a)if(!(f in c)||!b.isEqual(a[f],c[f]))return!1;return!0};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(l.call(a,c))return!1;return!0};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=n||function(a){return E.call(a)==="[object Array]"};b.isArguments=function(a){return!(!a||!l.call(a,"callee"))};b.isFunction=function(a){return!(!a||!a.constructor||!a.call||!a.apply)};b.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)};
23
+ b.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===!0||a===!1};b.isDate=function(a){return!(!a||!a.getTimezoneOffset||!a.setUTCFullYear)};b.isRegExp=function(a){return!(!a||!a.test||!a.exec||!(a.ignoreCase||a.ignoreCase===!1))};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.noConflict=function(){p._=C;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=
24
+ 0;e<a;e++)b.call(d,e)};b.mixin=function(a){h(b.functions(a),function(c){H(c,b[c]=a[c])})};var I=0;b.uniqueId=function(a){var b=I++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g};b.template=function(a,c){var d=b.templateSettings;d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.interpolate,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(d.evaluate||
25
+ null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";d=new Function("obj",d);return c?d(c):d};var j=function(a){this._wrapped=a};b.prototype=j.prototype;var r=function(a,c){return c?b(a).chain():a},H=function(a,c){j.prototype[a]=function(){var a=f.call(arguments);D.call(a,this._wrapped);return r(c.apply(b,a),this._chain)}};b.mixin(b);h(["pop","push","reverse","shift","sort",
26
+ "splice","unshift"],function(a){var b=i[a];j.prototype[a]=function(){b.apply(this._wrapped,arguments);return r(this._wrapped,this._chain)}});h(["concat","join","slice"],function(a){var b=i[a];j.prototype[a]=function(){return r(b.apply(this._wrapped,arguments),this._chain)}});j.prototype.chain=function(){this._chain=!0;return this};j.prototype.value=function(){return this._wrapped}})();
@@ -0,0 +1,3 @@
1
+ module Cans
2
+ VERSION = '0.2.0'
3
+ end
@@ -0,0 +1,161 @@
1
+ jQuery ->
2
+ jQuery.ajaxSetup(
3
+ type: 'post'
4
+ dataType: 'json'
5
+ )
6
+
7
+ # cans-based ajax helper, since we don't necessarily know where
8
+ # cans has been mounted
9
+ Ajax = (path, callback) ->
10
+ fullPath = window.location.pathname + path
11
+ jQuery.ajax(
12
+ url: fullPath
13
+ success: callback
14
+ )
15
+
16
+ # the top-level view of the Ruby VM image
17
+ class window.Machine
18
+ constructor: () ->
19
+ this.load()
20
+ load: ->
21
+ Ajax '/image', (data) =>
22
+ this.consume data
23
+ consume: (returned) ->
24
+ @modules = _.map returned.modules, (m) ->
25
+ new Module(m)
26
+ @view.trigger 'loaded'
27
+
28
+ class window.Module
29
+ constructor: (@name) ->
30
+ @view = null
31
+ load: ->
32
+ Ajax "/class/#{@name}", (data) =>
33
+ this.consume data
34
+ consume: (returned) ->
35
+ @childModules = _.map returned.child_modules, (m) => new Module(m)
36
+ @classMethods = _.map returned.class_methods, (m) => new ClassMethod(this, m)
37
+ @localInstanceMethods = _.map returned.local_instance_methods, (m) => new InstanceMethod(this, m)
38
+ @inheritedInstanceMethods = _.map returned.inherited_instance_methods, (m) => new InstanceMethod(this, m)
39
+ this.view.trigger 'loaded'
40
+ toJSON: ->
41
+ name: @name
42
+
43
+ class window.Method
44
+ constructor: (@module, @name) ->
45
+ load: (flavor) ->
46
+ Ajax this.url(), (data) =>
47
+ this.consume data
48
+ consume: (returned) ->
49
+ @source = returned.source
50
+ if @source
51
+ @source_file = returned.source_location[0]
52
+ @source_line = returned.source_location[1]
53
+ this.view.trigger 'loaded'
54
+ url: ->
55
+ "/method/#{escape(@module.name)}/.#{escape(@flavor)}/#{escape(@name)}"
56
+ toJSON: ->
57
+ module: @module.toJSON()
58
+ name: @name
59
+ source: @source
60
+ file: @source_file
61
+ line: @source_line
62
+ flavor: @flavor
63
+ flavorSymbol: @flavorSymbol
64
+
65
+ class window.InstanceMethod extends window.Method
66
+ flavor: 'i'
67
+ flavorSymbol: '#'
68
+
69
+ class window.ClassMethod extends window.Method
70
+ flavor: 'm'
71
+ flavorSymbol: '::'
72
+
73
+ window.SourceView = Backbone.View.extend
74
+ tagName: 'div'
75
+ template: _.template($('#source_template').html())
76
+ errorTemplate: _.template($('#source_error_template').html())
77
+ render: ->
78
+ if @model.source
79
+ return this.renderOkay()
80
+ else
81
+ return this.renderError()
82
+ renderOkay: ->
83
+ rendered = @template(@model.toJSON())
84
+ $(@el).html(rendered)
85
+ return this
86
+ renderError: ->
87
+ rendered = @errorTemplate(@model.toJSON())
88
+ $(@el).html(rendered)
89
+ return this
90
+
91
+ window.MethodView = Backbone.View.extend
92
+ tagName: 'li'
93
+ template: _.template($('#method_template').html())
94
+ events:
95
+ 'click': 'loadSource'
96
+ initialize: ->
97
+ @model.view = this
98
+ this.bind 'loaded', this.drawSource
99
+ loadSource: ->
100
+ $('#content').html('')
101
+ @model.load()
102
+ false
103
+ drawSource: ->
104
+ sourceView = new SourceView({model: @model})
105
+ $('#content').html(sourceView.render().el)
106
+ SyntaxHighlighter.highlight({}, $('#content pre')[0])
107
+ render: ->
108
+ rendered = this.template(this.model.toJSON())
109
+ $(this.el).html(rendered)
110
+ $(this.el).addClass(this.model.flavor)
111
+ return this
112
+
113
+ window.ModuleView = Backbone.View.extend
114
+ tagName: 'li'
115
+ template: _.template($('#module_template').html())
116
+ events:
117
+ 'click': 'loadChildren'
118
+ initialize: ->
119
+ @model.view = this
120
+ this.bind 'loaded', this.drawChildren
121
+ loadChildren: ->
122
+ $('#class_method_list').html('')
123
+ $('#instance_method_list').html('')
124
+ $('#content').html('')
125
+ $(@el).children('.child_modules').html('')
126
+ @model.load()
127
+ false
128
+ drawChildren: ->
129
+ this.drawChildModules()
130
+ this.drawClassMethods()
131
+ this.drawInstanceMethods()
132
+ drawClassMethods: ->
133
+ _(this.model.classMethods).each (m) ->
134
+ view = new MethodView({model: m})
135
+ $('#class_method_list').append(view.render().el)
136
+ drawInstanceMethods: ->
137
+ _(this.model.localInstanceMethods).each (m) ->
138
+ view = new MethodView({model: m})
139
+ $('#instance_method_list').append(view.render().el)
140
+ _(this.model.inheritedInstanceMethods).each (m) ->
141
+ view = new MethodView({model: m})
142
+ $('#instance_method_list').append(view.render().el)
143
+ drawChildModules: ->
144
+ _(this.model.childModules).each (m) =>
145
+ view = new ModuleView({model: m})
146
+ $(@el).children('.child_modules').append(view.render().el)
147
+ render: ->
148
+ rendered = this.template(this.model.toJSON())
149
+ $(this.el).html(rendered)
150
+ return this
151
+
152
+ window.MachineView = Backbone.View.extend
153
+ initialize: ->
154
+ @model.view = this
155
+ this.bind 'loaded', this.drawModules
156
+ drawModules: ->
157
+ _(@model.modules).each (m)->
158
+ view = new ModuleView({model: m})
159
+ $('#module_list').append(view.render().el)
160
+
161
+ window.App = new window.MachineView({model: new window.Machine})
@@ -0,0 +1,38 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title Cans
5
+ %link(rel='stylesheet' href='frameset.css' type='text/css' media='screen')
6
+ %link(rel='stylesheet' href='shCoreMidnight.css' type='text/css' media='screen')
7
+ %body
8
+ %ul#columns
9
+ %li
10
+ %ul#module_list
11
+ %li
12
+ %h1 Class Methods
13
+ %ul#class_method_list
14
+ %li
15
+ %h1 Instance Methods
16
+ %ul#instance_method_list
17
+ #content
18
+ %script{:src=>'json2.js', :type=>'text/javascript'}
19
+ %script{:src=>'jquery-1.4.4.min.js', :type=>'text/javascript'}
20
+ %script{:src=>'underscore-min.js', :type=>'text/javascript'}
21
+ %script{:src=>'backbone-min.js', :type=>'text/javascript'}
22
+ %script{:src=>'shCore.js', :type=>'text/javascript'}
23
+ %script{:src=>'shBrushRuby.js', :type=>'text/javascript'}
24
+ %script{:src=>'application.js', :type=>'text/javascript'}
25
+ %script#module_template(type='text/template')
26
+ <a><%= name %></a>
27
+ <ul class="child_modules"></ul>
28
+ %script#method_template(type='text/template')
29
+ <a><%= name %></a>
30
+ %script#source_template(type='text/template')
31
+ %h1 <%= module.name %><%= flavorSymbol %><%= name %>
32
+ %p.location Found at <%= file %>:<%= line %>
33
+ %pre{:class=>'brush: ruby'} <%= source %>
34
+ %script#source_error_template(type='text/template')
35
+ %h1 <%= module.name %><%= flavorSymbol %><%= name %>
36
+ %p
37
+ Couldn't find source for this method. It's probably implemented in C,
38
+ an accessor method, or dynamically generated.
data/lib/cans.rb CHANGED
@@ -1,4 +1,4 @@
1
- %w{ method_extensions sinatra/base haml }.each do |g|
1
+ %w{ method_extensions sinatra/base haml coffee-script json }.each do |g|
2
2
  require g
3
3
  end
4
4
 
@@ -0,0 +1,21 @@
1
+ describe 'InstanceMethod', ->
2
+ module = null
3
+
4
+ beforeEach ->
5
+ module = new Module('SampleModule')
6
+
7
+ it 'should take a name and module when constructed', ->
8
+ method = new InstanceMethod(module, 'SampleMethod')
9
+ expect(method.module).toEqual module
10
+ expect(method.name).toEqual 'SampleMethod'
11
+
12
+ describe 'instance', ->
13
+ method = null
14
+
15
+ beforeEach ->
16
+ method = new InstanceMethod(module, 'SampleMethod')
17
+
18
+ it 'should Ajax fetch when asked to load', ->
19
+ spyOn jQuery, 'ajax'
20
+ method.load()
21
+ expect(jQuery.ajax).toHaveBeenCalled()
@@ -0,0 +1,31 @@
1
+ describe 'Machine', ->
2
+
3
+ it 'should Ajax fetch when constructed', ->
4
+ spyOn jQuery, 'ajax'
5
+ machine = new Machine()
6
+ expect(jQuery.ajax).toHaveBeenCalled()
7
+
8
+ describe 'instance', ->
9
+
10
+ machine = null
11
+
12
+ beforeEach ->
13
+ spyOn jQuery, 'ajax'
14
+ view =
15
+ trigger: (name) ->
16
+ null
17
+ spyOn view, 'trigger'
18
+ machine = new Machine()
19
+ machine.view = view
20
+
21
+ describe 'when receiving module data', ->
22
+ beforeEach ->
23
+ machine.consume(
24
+ modules: ['Alpha', 'Bravo']
25
+ )
26
+
27
+ it 'should create empty module instances for each datum', ->
28
+ expect(machine.modules).toEqual([new Module('Alpha'), new Module('Bravo')])
29
+
30
+ it 'should notify the view when loaded', ->
31
+ expect(machine.view.trigger).toHaveBeenCalledWith('loaded')
@@ -0,0 +1,3 @@
1
+ describe 'MachineView', ->
2
+ it 'should exist', ->
3
+ expect(window.MachineView).toBeDefined()
@@ -0,0 +1,21 @@
1
+ describe 'Method', ->
2
+ module = null
3
+
4
+ beforeEach ->
5
+ module = new Module('SampleModule')
6
+
7
+ it 'should take a name and module when constructed', ->
8
+ method = new Method(module, 'SampleMethod')
9
+ expect(method.module).toEqual module
10
+ expect(method.name).toEqual 'SampleMethod'
11
+
12
+ describe 'instance', ->
13
+ method = null
14
+
15
+ beforeEach ->
16
+ method = new Method(module, 'SampleMethod')
17
+
18
+ it 'should Ajax fetch when asked to load', ->
19
+ spyOn jQuery, 'ajax'
20
+ method.load()
21
+ expect(jQuery.ajax).toHaveBeenCalled()