ledger_web 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. data/.gitignore +10 -0
  2. data/LICENSE +7 -0
  3. data/README.md +140 -0
  4. data/Rakefile +11 -0
  5. data/bin/ledger_web +14 -0
  6. data/ledger_web.gemspec +26 -0
  7. data/lib/ledger_web/app.rb +69 -0
  8. data/lib/ledger_web/config.rb +87 -0
  9. data/lib/ledger_web/db/migrate/20111226180900_initial_schema.rb +38 -0
  10. data/lib/ledger_web/db/migrate/20111231132900_add_views.rb +37 -0
  11. data/lib/ledger_web/db.rb +54 -0
  12. data/lib/ledger_web/helpers.rb +62 -0
  13. data/lib/ledger_web/public/bootstrap-dropdown.js +55 -0
  14. data/lib/ledger_web/public/bootstrap.min.css +356 -0
  15. data/lib/ledger_web/public/codemirror/keymap/emacs.js +29 -0
  16. data/lib/ledger_web/public/codemirror/keymap/vim.js +76 -0
  17. data/lib/ledger_web/public/codemirror/lib/codemirror.css +104 -0
  18. data/lib/ledger_web/public/codemirror/lib/codemirror.js +2761 -0
  19. data/lib/ledger_web/public/codemirror/lib/util/dialog.css +23 -0
  20. data/lib/ledger_web/public/codemirror/lib/util/dialog.js +63 -0
  21. data/lib/ledger_web/public/codemirror/lib/util/foldcode.js +66 -0
  22. data/lib/ledger_web/public/codemirror/lib/util/formatting.js +291 -0
  23. data/lib/ledger_web/public/codemirror/lib/util/javascript-hint.js +83 -0
  24. data/lib/ledger_web/public/codemirror/lib/util/overlay.js +51 -0
  25. data/lib/ledger_web/public/codemirror/lib/util/runmode.js +27 -0
  26. data/lib/ledger_web/public/codemirror/lib/util/search.js +114 -0
  27. data/lib/ledger_web/public/codemirror/lib/util/searchcursor.js +117 -0
  28. data/lib/ledger_web/public/codemirror/lib/util/simple-hint.css +16 -0
  29. data/lib/ledger_web/public/codemirror/lib/util/simple-hint.js +66 -0
  30. data/lib/ledger_web/public/codemirror/mode/clike/clike.js +249 -0
  31. data/lib/ledger_web/public/codemirror/mode/clike/index.html +101 -0
  32. data/lib/ledger_web/public/codemirror/mode/clojure/clojure.js +207 -0
  33. data/lib/ledger_web/public/codemirror/mode/clojure/index.html +66 -0
  34. data/lib/ledger_web/public/codemirror/mode/coffeescript/LICENSE +22 -0
  35. data/lib/ledger_web/public/codemirror/mode/coffeescript/coffeescript.js +325 -0
  36. data/lib/ledger_web/public/codemirror/mode/coffeescript/index.html +721 -0
  37. data/lib/ledger_web/public/codemirror/mode/css/css.js +124 -0
  38. data/lib/ledger_web/public/codemirror/mode/css/index.html +55 -0
  39. data/lib/ledger_web/public/codemirror/mode/diff/diff.css +3 -0
  40. data/lib/ledger_web/public/codemirror/mode/diff/diff.js +13 -0
  41. data/lib/ledger_web/public/codemirror/mode/diff/index.html +99 -0
  42. data/lib/ledger_web/public/codemirror/mode/gfm/gfm.js +108 -0
  43. data/lib/ledger_web/public/codemirror/mode/gfm/index.html +47 -0
  44. data/lib/ledger_web/public/codemirror/mode/groovy/groovy.js +210 -0
  45. data/lib/ledger_web/public/codemirror/mode/groovy/index.html +71 -0
  46. data/lib/ledger_web/public/codemirror/mode/haskell/haskell.js +242 -0
  47. data/lib/ledger_web/public/codemirror/mode/haskell/index.html +60 -0
  48. data/lib/ledger_web/public/codemirror/mode/htmlembedded/htmlembedded.js +68 -0
  49. data/lib/ledger_web/public/codemirror/mode/htmlembedded/index.html +49 -0
  50. data/lib/ledger_web/public/codemirror/mode/htmlmixed/htmlmixed.js +83 -0
  51. data/lib/ledger_web/public/codemirror/mode/htmlmixed/index.html +51 -0
  52. data/lib/ledger_web/public/codemirror/mode/javascript/index.html +77 -0
  53. data/lib/ledger_web/public/codemirror/mode/javascript/javascript.js +360 -0
  54. data/lib/ledger_web/public/codemirror/mode/jinja2/index.html +37 -0
  55. data/lib/ledger_web/public/codemirror/mode/jinja2/jinja2.js +42 -0
  56. data/lib/ledger_web/public/codemirror/mode/lua/index.html +72 -0
  57. data/lib/ledger_web/public/codemirror/mode/lua/lua.js +140 -0
  58. data/lib/ledger_web/public/codemirror/mode/markdown/index.html +339 -0
  59. data/lib/ledger_web/public/codemirror/mode/markdown/markdown.js +242 -0
  60. data/lib/ledger_web/public/codemirror/mode/ntriples/index.html +32 -0
  61. data/lib/ledger_web/public/codemirror/mode/ntriples/ntriples.js +172 -0
  62. data/lib/ledger_web/public/codemirror/mode/pascal/LICENSE +7 -0
  63. data/lib/ledger_web/public/codemirror/mode/pascal/index.html +48 -0
  64. data/lib/ledger_web/public/codemirror/mode/pascal/pascal.js +138 -0
  65. data/lib/ledger_web/public/codemirror/mode/perl/LICENSE +19 -0
  66. data/lib/ledger_web/public/codemirror/mode/perl/index.html +62 -0
  67. data/lib/ledger_web/public/codemirror/mode/perl/perl.js +816 -0
  68. data/lib/ledger_web/public/codemirror/mode/php/index.html +48 -0
  69. data/lib/ledger_web/public/codemirror/mode/php/php.js +120 -0
  70. data/lib/ledger_web/public/codemirror/mode/plsql/index.html +62 -0
  71. data/lib/ledger_web/public/codemirror/mode/plsql/plsql.js +217 -0
  72. data/lib/ledger_web/public/codemirror/mode/python/LICENSE.txt +21 -0
  73. data/lib/ledger_web/public/codemirror/mode/python/index.html +122 -0
  74. data/lib/ledger_web/public/codemirror/mode/python/python.js +333 -0
  75. data/lib/ledger_web/public/codemirror/mode/r/LICENSE +24 -0
  76. data/lib/ledger_web/public/codemirror/mode/r/index.html +73 -0
  77. data/lib/ledger_web/public/codemirror/mode/r/r.js +141 -0
  78. data/lib/ledger_web/public/codemirror/mode/rpm/changes/changes.js +19 -0
  79. data/lib/ledger_web/public/codemirror/mode/rpm/changes/index.html +53 -0
  80. data/lib/ledger_web/public/codemirror/mode/rpm/spec/index.html +99 -0
  81. data/lib/ledger_web/public/codemirror/mode/rpm/spec/spec.css +5 -0
  82. data/lib/ledger_web/public/codemirror/mode/rpm/spec/spec.js +66 -0
  83. data/lib/ledger_web/public/codemirror/mode/rst/index.html +525 -0
  84. data/lib/ledger_web/public/codemirror/mode/rst/rst.js +326 -0
  85. data/lib/ledger_web/public/codemirror/mode/ruby/LICENSE +24 -0
  86. data/lib/ledger_web/public/codemirror/mode/ruby/index.html +171 -0
  87. data/lib/ledger_web/public/codemirror/mode/ruby/ruby.js +195 -0
  88. data/lib/ledger_web/public/codemirror/mode/rust/index.html +48 -0
  89. data/lib/ledger_web/public/codemirror/mode/rust/rust.js +411 -0
  90. data/lib/ledger_web/public/codemirror/mode/scheme/index.html +64 -0
  91. data/lib/ledger_web/public/codemirror/mode/scheme/scheme.js +202 -0
  92. data/lib/ledger_web/public/codemirror/mode/smalltalk/index.html +55 -0
  93. data/lib/ledger_web/public/codemirror/mode/smalltalk/smalltalk.js +139 -0
  94. data/lib/ledger_web/public/codemirror/mode/sparql/index.html +40 -0
  95. data/lib/ledger_web/public/codemirror/mode/sparql/sparql.js +143 -0
  96. data/lib/ledger_web/public/codemirror/mode/stex/index.html +95 -0
  97. data/lib/ledger_web/public/codemirror/mode/stex/stex.js +167 -0
  98. data/lib/ledger_web/public/codemirror/mode/tiddlywiki/index.html +183 -0
  99. data/lib/ledger_web/public/codemirror/mode/tiddlywiki/tiddlywiki.css +21 -0
  100. data/lib/ledger_web/public/codemirror/mode/tiddlywiki/tiddlywiki.js +374 -0
  101. data/lib/ledger_web/public/codemirror/mode/velocity/index.html +103 -0
  102. data/lib/ledger_web/public/codemirror/mode/velocity/velocity.js +146 -0
  103. data/lib/ledger_web/public/codemirror/mode/xml/index.html +44 -0
  104. data/lib/ledger_web/public/codemirror/mode/xml/xml.js +252 -0
  105. data/lib/ledger_web/public/codemirror/mode/xmlpure/index.html +59 -0
  106. data/lib/ledger_web/public/codemirror/mode/xmlpure/xmlpure.js +485 -0
  107. data/lib/ledger_web/public/codemirror/mode/yaml/index.html +67 -0
  108. data/lib/ledger_web/public/codemirror/mode/yaml/yaml.js +95 -0
  109. data/lib/ledger_web/public/codemirror/theme/cobalt.css +18 -0
  110. data/lib/ledger_web/public/codemirror/theme/eclipse.css +25 -0
  111. data/lib/ledger_web/public/codemirror/theme/elegant.css +10 -0
  112. data/lib/ledger_web/public/codemirror/theme/monokai.css +28 -0
  113. data/lib/ledger_web/public/codemirror/theme/neat.css +9 -0
  114. data/lib/ledger_web/public/codemirror/theme/night.css +21 -0
  115. data/lib/ledger_web/public/codemirror/theme/rubyblue.css +21 -0
  116. data/lib/ledger_web/public/jquery-1.7.1.min.js +4 -0
  117. data/lib/ledger_web/public/jquery.tablesorter.min.js +4 -0
  118. data/lib/ledger_web/public/ledger.css +14 -0
  119. data/lib/ledger_web/report.rb +187 -0
  120. data/lib/ledger_web/reports/savings_rate.erb +49 -0
  121. data/lib/ledger_web/version.rb +3 -0
  122. data/lib/ledger_web/views/error.erb +5 -0
  123. data/lib/ledger_web/views/help.erb +6 -0
  124. data/lib/ledger_web/views/layout.erb +44 -0
  125. data/lib/ledger_web/views/table.erb +31 -0
  126. data/lib/ledger_web/watcher.rb +37 -0
  127. data/lib/ledger_web.rb +20 -0
  128. metadata +229 -0
@@ -0,0 +1,333 @@
1
+ CodeMirror.defineMode("python", function(conf, parserConf) {
2
+ var ERRORCLASS = 'error';
3
+
4
+ function wordRegexp(words) {
5
+ return new RegExp("^((" + words.join(")|(") + "))\\b");
6
+ }
7
+
8
+ var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
9
+ var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
10
+ var doubleOperators = new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
11
+ var doubleDelimiters = new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
12
+ var tripleDelimiters = new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
13
+ var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
14
+
15
+ var wordOperators = wordRegexp(['and', 'or', 'not', 'is', 'in']);
16
+ var commonkeywords = ['as', 'assert', 'break', 'class', 'continue',
17
+ 'def', 'del', 'elif', 'else', 'except', 'finally',
18
+ 'for', 'from', 'global', 'if', 'import',
19
+ 'lambda', 'pass', 'raise', 'return',
20
+ 'try', 'while', 'with', 'yield'];
21
+ var commontypes = ['bool', 'classmethod', 'complex', 'dict', 'enumerate',
22
+ 'float', 'frozenset', 'int', 'list', 'object',
23
+ 'property', 'reversed', 'set', 'slice', 'staticmethod',
24
+ 'str', 'super', 'tuple', 'type'];
25
+ var py2 = {'types': ['basestring', 'buffer', 'file', 'long', 'unicode',
26
+ 'xrange'],
27
+ 'keywords': ['exec', 'print']};
28
+ var py3 = {'types': ['bytearray', 'bytes', 'filter', 'map', 'memoryview',
29
+ 'open', 'range', 'zip'],
30
+ 'keywords': ['nonlocal']};
31
+
32
+ if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {
33
+ commonkeywords = commonkeywords.concat(py3.keywords);
34
+ commontypes = commontypes.concat(py3.types);
35
+ var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
36
+ } else {
37
+ commonkeywords = commonkeywords.concat(py2.keywords);
38
+ commontypes = commontypes.concat(py2.types);
39
+ var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
40
+ }
41
+ var keywords = wordRegexp(commonkeywords);
42
+ var types = wordRegexp(commontypes);
43
+
44
+ var indentInfo = null;
45
+
46
+ // tokenizers
47
+ function tokenBase(stream, state) {
48
+ // Handle scope changes
49
+ if (stream.sol()) {
50
+ var scopeOffset = state.scopes[0].offset;
51
+ if (stream.eatSpace()) {
52
+ var lineOffset = stream.indentation();
53
+ if (lineOffset > scopeOffset) {
54
+ indentInfo = 'indent';
55
+ } else if (lineOffset < scopeOffset) {
56
+ indentInfo = 'dedent';
57
+ }
58
+ return null;
59
+ } else {
60
+ if (scopeOffset > 0) {
61
+ dedent(stream, state);
62
+ }
63
+ }
64
+ }
65
+ if (stream.eatSpace()) {
66
+ return null;
67
+ }
68
+
69
+ var ch = stream.peek();
70
+
71
+ // Handle Comments
72
+ if (ch === '#') {
73
+ stream.skipToEnd();
74
+ return 'comment';
75
+ }
76
+
77
+ // Handle Number Literals
78
+ if (stream.match(/^[0-9\.]/, false)) {
79
+ var floatLiteral = false;
80
+ // Floats
81
+ if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; }
82
+ if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
83
+ if (stream.match(/^\.\d+/)) { floatLiteral = true; }
84
+ if (floatLiteral) {
85
+ // Float literals may be "imaginary"
86
+ stream.eat(/J/i);
87
+ return 'number';
88
+ }
89
+ // Integers
90
+ var intLiteral = false;
91
+ // Hex
92
+ if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; }
93
+ // Binary
94
+ if (stream.match(/^0b[01]+/i)) { intLiteral = true; }
95
+ // Octal
96
+ if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; }
97
+ // Decimal
98
+ if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
99
+ // Decimal literals may be "imaginary"
100
+ stream.eat(/J/i);
101
+ // TODO - Can you have imaginary longs?
102
+ intLiteral = true;
103
+ }
104
+ // Zero by itself with no other piece of number.
105
+ if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
106
+ if (intLiteral) {
107
+ // Integer literals may be "long"
108
+ stream.eat(/L/i);
109
+ return 'number';
110
+ }
111
+ }
112
+
113
+ // Handle Strings
114
+ if (stream.match(stringPrefixes)) {
115
+ state.tokenize = tokenStringFactory(stream.current());
116
+ return state.tokenize(stream, state);
117
+ }
118
+
119
+ // Handle operators and Delimiters
120
+ if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
121
+ return null;
122
+ }
123
+ if (stream.match(doubleOperators)
124
+ || stream.match(singleOperators)
125
+ || stream.match(wordOperators)) {
126
+ return 'operator';
127
+ }
128
+ if (stream.match(singleDelimiters)) {
129
+ return null;
130
+ }
131
+
132
+ if (stream.match(types)) {
133
+ return 'builtin';
134
+ }
135
+
136
+ if (stream.match(keywords)) {
137
+ return 'keyword';
138
+ }
139
+
140
+ if (stream.match(identifiers)) {
141
+ return 'variable';
142
+ }
143
+
144
+ // Handle non-detected items
145
+ stream.next();
146
+ return ERRORCLASS;
147
+ }
148
+
149
+ function tokenStringFactory(delimiter) {
150
+ while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
151
+ delimiter = delimiter.substr(1);
152
+ }
153
+ var singleline = delimiter.length == 1;
154
+ var OUTCLASS = 'string';
155
+
156
+ return function tokenString(stream, state) {
157
+ while (!stream.eol()) {
158
+ stream.eatWhile(/[^'"\\]/);
159
+ if (stream.eat('\\')) {
160
+ stream.next();
161
+ if (singleline && stream.eol()) {
162
+ return OUTCLASS;
163
+ }
164
+ } else if (stream.match(delimiter)) {
165
+ state.tokenize = tokenBase;
166
+ return OUTCLASS;
167
+ } else {
168
+ stream.eat(/['"]/);
169
+ }
170
+ }
171
+ if (singleline) {
172
+ if (parserConf.singleLineStringErrors) {
173
+ return ERRORCLASS;
174
+ } else {
175
+ state.tokenize = tokenBase;
176
+ }
177
+ }
178
+ return OUTCLASS;
179
+ };
180
+ }
181
+
182
+ function indent(stream, state, type) {
183
+ type = type || 'py';
184
+ var indentUnit = 0;
185
+ if (type === 'py') {
186
+ if (state.scopes[0].type !== 'py') {
187
+ state.scopes[0].offset = stream.indentation();
188
+ return;
189
+ }
190
+ for (var i = 0; i < state.scopes.length; ++i) {
191
+ if (state.scopes[i].type === 'py') {
192
+ indentUnit = state.scopes[i].offset + conf.indentUnit;
193
+ break;
194
+ }
195
+ }
196
+ } else {
197
+ indentUnit = stream.column() + stream.current().length;
198
+ }
199
+ state.scopes.unshift({
200
+ offset: indentUnit,
201
+ type: type
202
+ });
203
+ }
204
+
205
+ function dedent(stream, state, type) {
206
+ type = type || 'py';
207
+ if (state.scopes.length == 1) return;
208
+ if (state.scopes[0].type === 'py') {
209
+ var _indent = stream.indentation();
210
+ var _indent_index = -1;
211
+ for (var i = 0; i < state.scopes.length; ++i) {
212
+ if (_indent === state.scopes[i].offset) {
213
+ _indent_index = i;
214
+ break;
215
+ }
216
+ }
217
+ if (_indent_index === -1) {
218
+ return true;
219
+ }
220
+ while (state.scopes[0].offset !== _indent) {
221
+ state.scopes.shift();
222
+ }
223
+ return false
224
+ } else {
225
+ if (type === 'py') {
226
+ state.scopes[0].offset = stream.indentation();
227
+ return false;
228
+ } else {
229
+ if (state.scopes[0].type != type) {
230
+ return true;
231
+ }
232
+ state.scopes.shift();
233
+ return false;
234
+ }
235
+ }
236
+ }
237
+
238
+ function tokenLexer(stream, state) {
239
+ indentInfo = null;
240
+ var style = state.tokenize(stream, state);
241
+ var current = stream.current();
242
+
243
+ // Handle '.' connected identifiers
244
+ if (current === '.') {
245
+ style = state.tokenize(stream, state);
246
+ current = stream.current();
247
+ if (style === 'variable') {
248
+ return 'variable';
249
+ } else {
250
+ return ERRORCLASS;
251
+ }
252
+ }
253
+
254
+ // Handle decorators
255
+ if (current === '@') {
256
+ style = state.tokenize(stream, state);
257
+ current = stream.current();
258
+ if (style === 'variable'
259
+ || current === '@staticmethod'
260
+ || current === '@classmethod') {
261
+ return 'meta';
262
+ } else {
263
+ return ERRORCLASS;
264
+ }
265
+ }
266
+
267
+ // Handle scope changes.
268
+ if (current === 'pass' || current === 'return') {
269
+ state.dedent += 1;
270
+ }
271
+ if ((current === ':' && !state.lambda && state.scopes[0].type == 'py')
272
+ || indentInfo === 'indent') {
273
+ indent(stream, state);
274
+ }
275
+ var delimiter_index = '[({'.indexOf(current);
276
+ if (delimiter_index !== -1) {
277
+ indent(stream, state, '])}'.slice(delimiter_index, delimiter_index+1));
278
+ }
279
+ if (indentInfo === 'dedent') {
280
+ if (dedent(stream, state)) {
281
+ return ERRORCLASS;
282
+ }
283
+ }
284
+ delimiter_index = '])}'.indexOf(current);
285
+ if (delimiter_index !== -1) {
286
+ if (dedent(stream, state, current)) {
287
+ return ERRORCLASS;
288
+ }
289
+ }
290
+ if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'py') {
291
+ if (state.scopes.length > 1) state.scopes.shift();
292
+ state.dedent -= 1;
293
+ }
294
+
295
+ return style;
296
+ }
297
+
298
+ var external = {
299
+ startState: function(basecolumn) {
300
+ return {
301
+ tokenize: tokenBase,
302
+ scopes: [{offset:basecolumn || 0, type:'py'}],
303
+ lastToken: null,
304
+ lambda: false,
305
+ dedent: 0
306
+ };
307
+ },
308
+
309
+ token: function(stream, state) {
310
+ var style = tokenLexer(stream, state);
311
+
312
+ state.lastToken = {style:style, content: stream.current()};
313
+
314
+ if (stream.eol() && stream.lambda) {
315
+ state.lambda = false;
316
+ }
317
+
318
+ return style;
319
+ },
320
+
321
+ indent: function(state, textAfter) {
322
+ if (state.tokenize != tokenBase) {
323
+ return 0;
324
+ }
325
+
326
+ return state.scopes[0].offset;
327
+ }
328
+
329
+ };
330
+ return external;
331
+ });
332
+
333
+ CodeMirror.defineMIME("text/x-python", "python");
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2011, Ubalo, Inc.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the Ubalo, Inc nor the names of its
12
+ contributors may be used to endorse or promote products derived
13
+ from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL UBALO, INC BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,73 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror: R mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="r.js"></script>
8
+ <style>
9
+ .CodeMirror { border-top: 1px solid silver; border-bottom: 1px solid silver; }
10
+ .cm-s-default span.cm-semi { color: blue; font-weight: bold; }
11
+ .cm-s-default span.cm-dollar { color: orange; font-weight: bold; }
12
+ .cm-s-default span.cm-arrow { color: brown; }
13
+ .cm-s-default span.cm-arg-is { color: brown; }
14
+ </style>
15
+ <link rel="stylesheet" href="../../doc/docs.css">
16
+ </head>
17
+ <body>
18
+ <h1>CodeMirror: R mode</h1>
19
+ <form><textarea id="code" name="code">
20
+ # Code from http://www.mayin.org/ajayshah/KB/R/
21
+
22
+ # FIRST LEARN ABOUT LISTS --
23
+ X = list(height=5.4, weight=54)
24
+ print("Use default printing --")
25
+ print(X)
26
+ print("Accessing individual elements --")
27
+ cat("Your height is ", X$height, " and your weight is ", X$weight, "\n")
28
+
29
+ # FUNCTIONS --
30
+ square <- function(x) {
31
+ return(x*x)
32
+ }
33
+ cat("The square of 3 is ", square(3), "\n")
34
+
35
+ # default value of the arg is set to 5.
36
+ cube <- function(x=5) {
37
+ return(x*x*x);
38
+ }
39
+ cat("Calling cube with 2 : ", cube(2), "\n") # will give 2^3
40
+ cat("Calling cube : ", cube(), "\n") # will default to 5^3.
41
+
42
+ # LEARN ABOUT FUNCTIONS THAT RETURN MULTIPLE OBJECTS --
43
+ powers <- function(x) {
44
+ parcel = list(x2=x*x, x3=x*x*x, x4=x*x*x*x);
45
+ return(parcel);
46
+ }
47
+
48
+ X = powers(3);
49
+ print("Showing powers of 3 --"); print(X);
50
+
51
+ # WRITING THIS COMPACTLY (4 lines instead of 7)
52
+
53
+ powerful <- function(x) {
54
+ return(list(x2=x*x, x3=x*x*x, x4=x*x*x*x));
55
+ }
56
+ print("Showing powers of 3 --"); print(powerful(3));
57
+
58
+ # In R, the last expression in a function is, by default, what is
59
+ # returned. So you could equally just say:
60
+ powerful <- function(x) {list(x2=x*x, x3=x*x*x, x4=x*x*x*x)}
61
+ </textarea></form>
62
+ <script>
63
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
64
+ </script>
65
+
66
+ <p><strong>MIME types defined:</strong> <code>text/x-rsrc</code>.</p>
67
+
68
+ <p>Development of the CodeMirror R mode was kindly sponsored
69
+ by <a href="http://ubalo.com/">Ubalo</a>, who hold
70
+ the <a href="LICENSE">license</a>.</p>
71
+
72
+ </body>
73
+ </html>
@@ -0,0 +1,141 @@
1
+ CodeMirror.defineMode("r", function(config) {
2
+ function wordObj(str) {
3
+ var words = str.split(" "), res = {};
4
+ for (var i = 0; i < words.length; ++i) res[words[i]] = true;
5
+ return res;
6
+ }
7
+ var atoms = wordObj("NULL NA Inf NaN NA_integer_ NA_real_ NA_complex_ NA_character_");
8
+ var builtins = wordObj("list quote bquote eval return call parse deparse");
9
+ var keywords = wordObj("if else repeat while function for in next break");
10
+ var blockkeywords = wordObj("if else repeat while function for");
11
+ var opChars = /[+\-*\/^<>=!&|~$:]/;
12
+ var curPunc;
13
+
14
+ function tokenBase(stream, state) {
15
+ curPunc = null;
16
+ var ch = stream.next();
17
+ if (ch == "#") {
18
+ stream.skipToEnd();
19
+ return "comment";
20
+ } else if (ch == "0" && stream.eat("x")) {
21
+ stream.eatWhile(/[\da-f]/i);
22
+ return "number";
23
+ } else if (ch == "." && stream.eat(/\d/)) {
24
+ stream.match(/\d*(?:e[+\-]?\d+)?/);
25
+ return "number";
26
+ } else if (/\d/.test(ch)) {
27
+ stream.match(/\d*(?:\.\d+)?(?:e[+\-]\d+)?L?/);
28
+ return "number";
29
+ } else if (ch == "'" || ch == '"') {
30
+ state.tokenize = tokenString(ch);
31
+ return "string";
32
+ } else if (ch == "." && stream.match(/.[.\d]+/)) {
33
+ return "keyword";
34
+ } else if (/[\w\.]/.test(ch) && ch != "_") {
35
+ stream.eatWhile(/[\w\.]/);
36
+ var word = stream.current();
37
+ if (atoms.propertyIsEnumerable(word)) return "atom";
38
+ if (keywords.propertyIsEnumerable(word)) {
39
+ if (blockkeywords.propertyIsEnumerable(word)) curPunc = "block";
40
+ return "keyword";
41
+ }
42
+ if (builtins.propertyIsEnumerable(word)) return "builtin";
43
+ return "variable";
44
+ } else if (ch == "%") {
45
+ if (stream.skipTo("%")) stream.next();
46
+ return "variable-2";
47
+ } else if (ch == "<" && stream.eat("-")) {
48
+ return "arrow";
49
+ } else if (ch == "=" && state.ctx.argList) {
50
+ return "arg-is";
51
+ } else if (opChars.test(ch)) {
52
+ if (ch == "$") return "dollar";
53
+ stream.eatWhile(opChars);
54
+ return "operator";
55
+ } else if (/[\(\){}\[\];]/.test(ch)) {
56
+ curPunc = ch;
57
+ if (ch == ";") return "semi";
58
+ return null;
59
+ } else {
60
+ return null;
61
+ }
62
+ }
63
+
64
+ function tokenString(quote) {
65
+ return function(stream, state) {
66
+ if (stream.eat("\\")) {
67
+ var ch = stream.next();
68
+ if (ch == "x") stream.match(/^[a-f0-9]{2}/i);
69
+ else if ((ch == "u" || ch == "U") && stream.eat("{") && stream.skipTo("}")) stream.next();
70
+ else if (ch == "u") stream.match(/^[a-f0-9]{4}/i);
71
+ else if (ch == "U") stream.match(/^[a-f0-9]{8}/i);
72
+ else if (/[0-7]/.test(ch)) stream.match(/^[0-7]{1,2}/);
73
+ return "string-2";
74
+ } else {
75
+ var next;
76
+ while ((next = stream.next()) != null) {
77
+ if (next == quote) { state.tokenize = tokenBase; break; }
78
+ if (next == "\\") { stream.backUp(1); break; }
79
+ }
80
+ return "string";
81
+ }
82
+ };
83
+ }
84
+
85
+ function push(state, type, stream) {
86
+ state.ctx = {type: type,
87
+ indent: state.indent,
88
+ align: null,
89
+ column: stream.column(),
90
+ prev: state.ctx};
91
+ }
92
+ function pop(state) {
93
+ state.indent = state.ctx.indent;
94
+ state.ctx = state.ctx.prev;
95
+ }
96
+
97
+ return {
98
+ startState: function(base) {
99
+ return {tokenize: tokenBase,
100
+ ctx: {type: "top",
101
+ indent: -config.indentUnit,
102
+ align: false},
103
+ indent: 0,
104
+ afterIdent: false};
105
+ },
106
+
107
+ token: function(stream, state) {
108
+ if (stream.sol()) {
109
+ if (state.ctx.align == null) state.ctx.align = false;
110
+ state.indent = stream.indentation();
111
+ }
112
+ if (stream.eatSpace()) return null;
113
+ var style = state.tokenize(stream, state);
114
+ if (style != "comment" && state.ctx.align == null) state.ctx.align = true;
115
+
116
+ var ctype = state.ctx.type;
117
+ if ((curPunc == ";" || curPunc == "{" || curPunc == "}") && ctype == "block") pop(state);
118
+ if (curPunc == "{") push(state, "}", stream);
119
+ else if (curPunc == "(") {
120
+ push(state, ")", stream);
121
+ if (state.afterIdent) state.ctx.argList = true;
122
+ }
123
+ else if (curPunc == "[") push(state, "]", stream);
124
+ else if (curPunc == "block") push(state, "block", stream);
125
+ else if (curPunc == ctype) pop(state);
126
+ state.afterIdent = style == "variable" || style == "keyword";
127
+ return style;
128
+ },
129
+
130
+ indent: function(state, textAfter) {
131
+ if (state.tokenize != tokenBase) return 0;
132
+ var firstChar = textAfter && textAfter.charAt(0), ctx = state.ctx,
133
+ closing = firstChar == ctx.type;
134
+ if (ctx.type == "block") return ctx.indent + (firstChar == "{" ? 0 : config.indentUnit);
135
+ else if (ctx.align) return ctx.column + (closing ? 0 : 1);
136
+ else return ctx.indent + (closing ? 0 : config.indentUnit);
137
+ }
138
+ };
139
+ });
140
+
141
+ CodeMirror.defineMIME("text/x-rsrc", "r");
@@ -0,0 +1,19 @@
1
+ CodeMirror.defineMode("changes", function(config, modeConfig) {
2
+ var headerSeperator = /^-+$/;
3
+ var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /;
4
+ var simpleEmail = /^[\w+.-]+@[\w.-]+/;
5
+
6
+ return {
7
+ token: function(stream) {
8
+ if (stream.sol()) {
9
+ if (stream.match(headerSeperator)) { return 'tag'; }
10
+ if (stream.match(headerLine)) { return 'tag'; }
11
+ }
12
+ if (stream.match(simpleEmail)) { return 'string'; }
13
+ stream.next();
14
+ return null;
15
+ }
16
+ };
17
+ });
18
+
19
+ CodeMirror.defineMIME("text/x-rpm-changes", "changes");
@@ -0,0 +1,53 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror: RPM changes mode</title>
5
+ <link rel="stylesheet" href="../../../lib/codemirror.css">
6
+ <script src="../../../lib/codemirror.js"></script>
7
+ <script src="changes.js"></script>
8
+ <link rel="stylesheet" href="../../../doc/docs.css">
9
+ <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10
+ </head>
11
+ <body>
12
+ <h1>CodeMirror: RPM changes mode</h1>
13
+
14
+ <div><textarea id="code" name="code">
15
+ -------------------------------------------------------------------
16
+ Tue Oct 18 13:58:40 UTC 2011 - misterx@example.com
17
+
18
+ - Update to r60.3
19
+ - Fixes bug in the reflect package
20
+ * disallow Interface method on Value obtained via unexported name
21
+
22
+ -------------------------------------------------------------------
23
+ Thu Oct 6 08:14:24 UTC 2011 - misterx@example.com
24
+
25
+ - Update to r60.2
26
+ - Fixes memory leak in certain map types
27
+
28
+ -------------------------------------------------------------------
29
+ Wed Oct 5 14:34:10 UTC 2011 - misterx@example.com
30
+
31
+ - Tweaks for gdb debugging
32
+ - go.spec changes:
33
+ - move %go_arch definition to %prep section
34
+ - pass correct location of go specific gdb pretty printer and
35
+ functions to cpp as HOST_EXTRA_CFLAGS macro
36
+ - install go gdb functions & printer
37
+ - gdb-printer.patch
38
+ - patch linker (src/cmd/ld/dwarf.c) to emit correct location of go
39
+ gdb functions and pretty printer
40
+ </textarea></div>
41
+ <script>
42
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
43
+ mode: {name: "changes"},
44
+ lineNumbers: true,
45
+ indentUnit: 4,
46
+ tabMode: "shift",
47
+ matchBrackets: true
48
+ });
49
+ </script>
50
+
51
+ <p><strong>MIME types defined:</strong> <code>text/x-rpm-changes</code>.</p>
52
+ </body>
53
+ </html>