ledger_web 1.2

Sign up to get free protection for your applications and to get access to all the features.
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,252 @@
1
+ CodeMirror.defineMode("xml", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit;
3
+ var Kludges = parserConfig.htmlMode ? {
4
+ autoSelfClosers: {"br": true, "img": true, "hr": true, "link": true, "input": true,
5
+ "meta": true, "col": true, "frame": true, "base": true, "area": true},
6
+ doNotIndent: {"pre": true},
7
+ allowUnquoted: true
8
+ } : {autoSelfClosers: {}, doNotIndent: {}, allowUnquoted: false};
9
+ var alignCDATA = parserConfig.alignCDATA;
10
+
11
+ // Return variables for tokenizers
12
+ var tagName, type;
13
+
14
+ function inText(stream, state) {
15
+ function chain(parser) {
16
+ state.tokenize = parser;
17
+ return parser(stream, state);
18
+ }
19
+
20
+ var ch = stream.next();
21
+ if (ch == "<") {
22
+ if (stream.eat("!")) {
23
+ if (stream.eat("[")) {
24
+ if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
25
+ else return null;
26
+ }
27
+ else if (stream.match("--")) return chain(inBlock("comment", "-->"));
28
+ else if (stream.match("DOCTYPE", true, true)) {
29
+ stream.eatWhile(/[\w\._\-]/);
30
+ return chain(doctype(1));
31
+ }
32
+ else return null;
33
+ }
34
+ else if (stream.eat("?")) {
35
+ stream.eatWhile(/[\w\._\-]/);
36
+ state.tokenize = inBlock("meta", "?>");
37
+ return "meta";
38
+ }
39
+ else {
40
+ type = stream.eat("/") ? "closeTag" : "openTag";
41
+ stream.eatSpace();
42
+ tagName = "";
43
+ var c;
44
+ while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
45
+ state.tokenize = inTag;
46
+ return "tag";
47
+ }
48
+ }
49
+ else if (ch == "&") {
50
+ stream.eatWhile(/[^;]/);
51
+ stream.eat(";");
52
+ return "atom";
53
+ }
54
+ else {
55
+ stream.eatWhile(/[^&<]/);
56
+ return null;
57
+ }
58
+ }
59
+
60
+ function inTag(stream, state) {
61
+ var ch = stream.next();
62
+ if (ch == ">" || (ch == "/" && stream.eat(">"))) {
63
+ state.tokenize = inText;
64
+ type = ch == ">" ? "endTag" : "selfcloseTag";
65
+ return "tag";
66
+ }
67
+ else if (ch == "=") {
68
+ type = "equals";
69
+ return null;
70
+ }
71
+ else if (/[\'\"]/.test(ch)) {
72
+ state.tokenize = inAttribute(ch);
73
+ return state.tokenize(stream, state);
74
+ }
75
+ else {
76
+ stream.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);
77
+ return "word";
78
+ }
79
+ }
80
+
81
+ function inAttribute(quote) {
82
+ return function(stream, state) {
83
+ while (!stream.eol()) {
84
+ if (stream.next() == quote) {
85
+ state.tokenize = inTag;
86
+ break;
87
+ }
88
+ }
89
+ return "string";
90
+ };
91
+ }
92
+
93
+ function inBlock(style, terminator) {
94
+ return function(stream, state) {
95
+ while (!stream.eol()) {
96
+ if (stream.match(terminator)) {
97
+ state.tokenize = inText;
98
+ break;
99
+ }
100
+ stream.next();
101
+ }
102
+ return style;
103
+ };
104
+ }
105
+ function doctype(depth) {
106
+ return function(stream, state) {
107
+ var ch;
108
+ while ((ch = stream.next()) != null) {
109
+ if (ch == "<") {
110
+ state.tokenize = doctype(depth + 1);
111
+ return state.tokenize(stream, state);
112
+ } else if (ch == ">") {
113
+ if (depth == 1) {
114
+ state.tokenize = inText;
115
+ break;
116
+ } else {
117
+ state.tokenize = doctype(depth - 1);
118
+ return state.tokenize(stream, state);
119
+ }
120
+ }
121
+ }
122
+ return "meta";
123
+ };
124
+ }
125
+
126
+ var curState, setStyle;
127
+ function pass() {
128
+ for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
129
+ }
130
+ function cont() {
131
+ pass.apply(null, arguments);
132
+ return true;
133
+ }
134
+
135
+ function pushContext(tagName, startOfLine) {
136
+ var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent);
137
+ curState.context = {
138
+ prev: curState.context,
139
+ tagName: tagName,
140
+ indent: curState.indented,
141
+ startOfLine: startOfLine,
142
+ noIndent: noIndent
143
+ };
144
+ }
145
+ function popContext() {
146
+ if (curState.context) curState.context = curState.context.prev;
147
+ }
148
+
149
+ function element(type) {
150
+ if (type == "openTag") {
151
+ curState.tagName = tagName;
152
+ return cont(attributes, endtag(curState.startOfLine));
153
+ } else if (type == "closeTag") {
154
+ var err = false;
155
+ if (curState.context) {
156
+ err = curState.context.tagName != tagName;
157
+ } else {
158
+ err = true;
159
+ }
160
+ if (err) setStyle = "error";
161
+ return cont(endclosetag(err));
162
+ }
163
+ return cont();
164
+ }
165
+ function endtag(startOfLine) {
166
+ return function(type) {
167
+ if (type == "selfcloseTag" ||
168
+ (type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase())))
169
+ return cont();
170
+ if (type == "endTag") {pushContext(curState.tagName, startOfLine); return cont();}
171
+ return cont();
172
+ };
173
+ }
174
+ function endclosetag(err) {
175
+ return function(type) {
176
+ if (err) setStyle = "error";
177
+ if (type == "endTag") { popContext(); return cont(); }
178
+ setStyle = "error";
179
+ return cont(arguments.callee);
180
+ }
181
+ }
182
+
183
+ function attributes(type) {
184
+ if (type == "word") {setStyle = "attribute"; return cont(attributes);}
185
+ if (type == "equals") return cont(attvalue, attributes);
186
+ if (type == "string") {setStyle = "error"; return cont(attributes);}
187
+ return pass();
188
+ }
189
+ function attvalue(type) {
190
+ if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
191
+ if (type == "string") return cont(attvaluemaybe);
192
+ return pass();
193
+ }
194
+ function attvaluemaybe(type) {
195
+ if (type == "string") return cont(attvaluemaybe);
196
+ else return pass();
197
+ }
198
+
199
+ return {
200
+ startState: function() {
201
+ return {tokenize: inText, cc: [], indented: 0, startOfLine: true, tagName: null, context: null};
202
+ },
203
+
204
+ token: function(stream, state) {
205
+ if (stream.sol()) {
206
+ state.startOfLine = true;
207
+ state.indented = stream.indentation();
208
+ }
209
+ if (stream.eatSpace()) return null;
210
+
211
+ setStyle = type = tagName = null;
212
+ var style = state.tokenize(stream, state);
213
+ state.type = type;
214
+ if ((style || type) && style != "comment") {
215
+ curState = state;
216
+ while (true) {
217
+ var comb = state.cc.pop() || element;
218
+ if (comb(type || style)) break;
219
+ }
220
+ }
221
+ state.startOfLine = false;
222
+ return setStyle || style;
223
+ },
224
+
225
+ indent: function(state, textAfter, fullLine) {
226
+ var context = state.context;
227
+ if ((state.tokenize != inTag && state.tokenize != inText) ||
228
+ context && context.noIndent)
229
+ return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
230
+ if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
231
+ if (context && /^<\//.test(textAfter))
232
+ context = context.prev;
233
+ while (context && !context.startOfLine)
234
+ context = context.prev;
235
+ if (context) return context.indent + indentUnit;
236
+ else return 0;
237
+ },
238
+
239
+ compareStates: function(a, b) {
240
+ if (a.indented != b.indented || a.tokenize != b.tokenize) return false;
241
+ for (var ca = a.context, cb = b.context; ; ca = ca.prev, cb = cb.prev) {
242
+ if (!ca || !cb) return ca == cb;
243
+ if (ca.tagName != cb.tagName) return false;
244
+ }
245
+ },
246
+
247
+ electricChars: "/"
248
+ };
249
+ });
250
+
251
+ CodeMirror.defineMIME("application/xml", "xml");
252
+ CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
@@ -0,0 +1,59 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror: Pure XML mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="xmlpure.js"></script>
8
+ <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
9
+ <link rel="stylesheet" href="../../doc/docs.css">
10
+ </head>
11
+ <body>
12
+ <h1>CodeMirror: XML mode</h1>
13
+ <form><textarea id="code" name="code">
14
+ &lt;?xml version="1.0" encoding="UTF-8" standalone="no" ?&gt;
15
+
16
+ &lt;!-- This is the pure XML mode,
17
+ and we're inside a comment! --&gt;
18
+
19
+ &lt;catalog&gt;
20
+ &lt;books&gt;
21
+ &lt;book id="bk01"&gt;
22
+ &lt;title&gt;Lord of Light&lt;/title&gt;
23
+ &lt;author&gt;Roger Zelazny&lt;/author&gt;
24
+ &lt;year&gt;1967&lt;/year&gt;
25
+ &lt;description&gt;&lt;![CDATA[This is a great book, really!!]]&gt;&lt;/description&gt;
26
+ &lt;/book&gt;
27
+ &lt;/books&gt;
28
+ &lt;/catalog&gt;
29
+ </textarea></form>
30
+ <script>
31
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: {name: "xmlpure"}});
32
+ </script>
33
+
34
+ <p>This is my XML parser, based on the original:</p>
35
+ <ul>
36
+ <li>No html mode - this is pure xml</li>
37
+ <li>Illegal attributes and element names are errors</li>
38
+ <li>Attributes must have a value</li>
39
+ <li>XML declaration supported (e.g.: <b>&lt;?xml version="1.0" encoding="utf-8" standalone="no" ?&gt;</b>)</li>
40
+ <li>CDATA and comment blocks are not indented (except for their start-tag)</li>
41
+ <li>Better handling of errors per line with the state object - provides good infrastructure for extending it</li>
42
+ </ul>
43
+
44
+ <p>What's missing:</p>
45
+ <ul>
46
+ <li>Make sure only a single root element exists at the document level</li>
47
+ <li>Multi-line attributes should NOT indent</li>
48
+ <li>Start tags are not painted red when they have no matching end tags (is this really wrong?)</li>
49
+ </ul>
50
+
51
+ <p><strong>MIME types defined:</strong> <code>application/xml</code>, <code>text/xml</code>.</p>
52
+
53
+ <p><b>@author</b>: Dror BG (<i>deebug.dev[at]gmail.com</i>)<br/>
54
+ <p><b>@date</b>: August, 2011<br/>
55
+ <p><b>@github</b>: <a href='https://github.com/deebugger/CodeMirror2' target='blank'>https://github.com/deebugger/CodeMirror2</a></p>
56
+
57
+ <p><strong>MIME types defined:</strong> <code>application/xml</code>, <code>text/xml</code>.</p>
58
+ </body>
59
+ </html>