ledger_web 1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/LICENSE +7 -0
- data/README.md +140 -0
- data/Rakefile +11 -0
- data/bin/ledger_web +14 -0
- data/ledger_web.gemspec +26 -0
- data/lib/ledger_web/app.rb +69 -0
- data/lib/ledger_web/config.rb +87 -0
- data/lib/ledger_web/db/migrate/20111226180900_initial_schema.rb +38 -0
- data/lib/ledger_web/db/migrate/20111231132900_add_views.rb +37 -0
- data/lib/ledger_web/db.rb +54 -0
- data/lib/ledger_web/helpers.rb +62 -0
- data/lib/ledger_web/public/bootstrap-dropdown.js +55 -0
- data/lib/ledger_web/public/bootstrap.min.css +356 -0
- data/lib/ledger_web/public/codemirror/keymap/emacs.js +29 -0
- data/lib/ledger_web/public/codemirror/keymap/vim.js +76 -0
- data/lib/ledger_web/public/codemirror/lib/codemirror.css +104 -0
- data/lib/ledger_web/public/codemirror/lib/codemirror.js +2761 -0
- data/lib/ledger_web/public/codemirror/lib/util/dialog.css +23 -0
- data/lib/ledger_web/public/codemirror/lib/util/dialog.js +63 -0
- data/lib/ledger_web/public/codemirror/lib/util/foldcode.js +66 -0
- data/lib/ledger_web/public/codemirror/lib/util/formatting.js +291 -0
- data/lib/ledger_web/public/codemirror/lib/util/javascript-hint.js +83 -0
- data/lib/ledger_web/public/codemirror/lib/util/overlay.js +51 -0
- data/lib/ledger_web/public/codemirror/lib/util/runmode.js +27 -0
- data/lib/ledger_web/public/codemirror/lib/util/search.js +114 -0
- data/lib/ledger_web/public/codemirror/lib/util/searchcursor.js +117 -0
- data/lib/ledger_web/public/codemirror/lib/util/simple-hint.css +16 -0
- data/lib/ledger_web/public/codemirror/lib/util/simple-hint.js +66 -0
- data/lib/ledger_web/public/codemirror/mode/clike/clike.js +249 -0
- data/lib/ledger_web/public/codemirror/mode/clike/index.html +101 -0
- data/lib/ledger_web/public/codemirror/mode/clojure/clojure.js +207 -0
- data/lib/ledger_web/public/codemirror/mode/clojure/index.html +66 -0
- data/lib/ledger_web/public/codemirror/mode/coffeescript/LICENSE +22 -0
- data/lib/ledger_web/public/codemirror/mode/coffeescript/coffeescript.js +325 -0
- data/lib/ledger_web/public/codemirror/mode/coffeescript/index.html +721 -0
- data/lib/ledger_web/public/codemirror/mode/css/css.js +124 -0
- data/lib/ledger_web/public/codemirror/mode/css/index.html +55 -0
- data/lib/ledger_web/public/codemirror/mode/diff/diff.css +3 -0
- data/lib/ledger_web/public/codemirror/mode/diff/diff.js +13 -0
- data/lib/ledger_web/public/codemirror/mode/diff/index.html +99 -0
- data/lib/ledger_web/public/codemirror/mode/gfm/gfm.js +108 -0
- data/lib/ledger_web/public/codemirror/mode/gfm/index.html +47 -0
- data/lib/ledger_web/public/codemirror/mode/groovy/groovy.js +210 -0
- data/lib/ledger_web/public/codemirror/mode/groovy/index.html +71 -0
- data/lib/ledger_web/public/codemirror/mode/haskell/haskell.js +242 -0
- data/lib/ledger_web/public/codemirror/mode/haskell/index.html +60 -0
- data/lib/ledger_web/public/codemirror/mode/htmlembedded/htmlembedded.js +68 -0
- data/lib/ledger_web/public/codemirror/mode/htmlembedded/index.html +49 -0
- data/lib/ledger_web/public/codemirror/mode/htmlmixed/htmlmixed.js +83 -0
- data/lib/ledger_web/public/codemirror/mode/htmlmixed/index.html +51 -0
- data/lib/ledger_web/public/codemirror/mode/javascript/index.html +77 -0
- data/lib/ledger_web/public/codemirror/mode/javascript/javascript.js +360 -0
- data/lib/ledger_web/public/codemirror/mode/jinja2/index.html +37 -0
- data/lib/ledger_web/public/codemirror/mode/jinja2/jinja2.js +42 -0
- data/lib/ledger_web/public/codemirror/mode/lua/index.html +72 -0
- data/lib/ledger_web/public/codemirror/mode/lua/lua.js +140 -0
- data/lib/ledger_web/public/codemirror/mode/markdown/index.html +339 -0
- data/lib/ledger_web/public/codemirror/mode/markdown/markdown.js +242 -0
- data/lib/ledger_web/public/codemirror/mode/ntriples/index.html +32 -0
- data/lib/ledger_web/public/codemirror/mode/ntriples/ntriples.js +172 -0
- data/lib/ledger_web/public/codemirror/mode/pascal/LICENSE +7 -0
- data/lib/ledger_web/public/codemirror/mode/pascal/index.html +48 -0
- data/lib/ledger_web/public/codemirror/mode/pascal/pascal.js +138 -0
- data/lib/ledger_web/public/codemirror/mode/perl/LICENSE +19 -0
- data/lib/ledger_web/public/codemirror/mode/perl/index.html +62 -0
- data/lib/ledger_web/public/codemirror/mode/perl/perl.js +816 -0
- data/lib/ledger_web/public/codemirror/mode/php/index.html +48 -0
- data/lib/ledger_web/public/codemirror/mode/php/php.js +120 -0
- data/lib/ledger_web/public/codemirror/mode/plsql/index.html +62 -0
- data/lib/ledger_web/public/codemirror/mode/plsql/plsql.js +217 -0
- data/lib/ledger_web/public/codemirror/mode/python/LICENSE.txt +21 -0
- data/lib/ledger_web/public/codemirror/mode/python/index.html +122 -0
- data/lib/ledger_web/public/codemirror/mode/python/python.js +333 -0
- data/lib/ledger_web/public/codemirror/mode/r/LICENSE +24 -0
- data/lib/ledger_web/public/codemirror/mode/r/index.html +73 -0
- data/lib/ledger_web/public/codemirror/mode/r/r.js +141 -0
- data/lib/ledger_web/public/codemirror/mode/rpm/changes/changes.js +19 -0
- data/lib/ledger_web/public/codemirror/mode/rpm/changes/index.html +53 -0
- data/lib/ledger_web/public/codemirror/mode/rpm/spec/index.html +99 -0
- data/lib/ledger_web/public/codemirror/mode/rpm/spec/spec.css +5 -0
- data/lib/ledger_web/public/codemirror/mode/rpm/spec/spec.js +66 -0
- data/lib/ledger_web/public/codemirror/mode/rst/index.html +525 -0
- data/lib/ledger_web/public/codemirror/mode/rst/rst.js +326 -0
- data/lib/ledger_web/public/codemirror/mode/ruby/LICENSE +24 -0
- data/lib/ledger_web/public/codemirror/mode/ruby/index.html +171 -0
- data/lib/ledger_web/public/codemirror/mode/ruby/ruby.js +195 -0
- data/lib/ledger_web/public/codemirror/mode/rust/index.html +48 -0
- data/lib/ledger_web/public/codemirror/mode/rust/rust.js +411 -0
- data/lib/ledger_web/public/codemirror/mode/scheme/index.html +64 -0
- data/lib/ledger_web/public/codemirror/mode/scheme/scheme.js +202 -0
- data/lib/ledger_web/public/codemirror/mode/smalltalk/index.html +55 -0
- data/lib/ledger_web/public/codemirror/mode/smalltalk/smalltalk.js +139 -0
- data/lib/ledger_web/public/codemirror/mode/sparql/index.html +40 -0
- data/lib/ledger_web/public/codemirror/mode/sparql/sparql.js +143 -0
- data/lib/ledger_web/public/codemirror/mode/stex/index.html +95 -0
- data/lib/ledger_web/public/codemirror/mode/stex/stex.js +167 -0
- data/lib/ledger_web/public/codemirror/mode/tiddlywiki/index.html +183 -0
- data/lib/ledger_web/public/codemirror/mode/tiddlywiki/tiddlywiki.css +21 -0
- data/lib/ledger_web/public/codemirror/mode/tiddlywiki/tiddlywiki.js +374 -0
- data/lib/ledger_web/public/codemirror/mode/velocity/index.html +103 -0
- data/lib/ledger_web/public/codemirror/mode/velocity/velocity.js +146 -0
- data/lib/ledger_web/public/codemirror/mode/xml/index.html +44 -0
- data/lib/ledger_web/public/codemirror/mode/xml/xml.js +252 -0
- data/lib/ledger_web/public/codemirror/mode/xmlpure/index.html +59 -0
- data/lib/ledger_web/public/codemirror/mode/xmlpure/xmlpure.js +485 -0
- data/lib/ledger_web/public/codemirror/mode/yaml/index.html +67 -0
- data/lib/ledger_web/public/codemirror/mode/yaml/yaml.js +95 -0
- data/lib/ledger_web/public/codemirror/theme/cobalt.css +18 -0
- data/lib/ledger_web/public/codemirror/theme/eclipse.css +25 -0
- data/lib/ledger_web/public/codemirror/theme/elegant.css +10 -0
- data/lib/ledger_web/public/codemirror/theme/monokai.css +28 -0
- data/lib/ledger_web/public/codemirror/theme/neat.css +9 -0
- data/lib/ledger_web/public/codemirror/theme/night.css +21 -0
- data/lib/ledger_web/public/codemirror/theme/rubyblue.css +21 -0
- data/lib/ledger_web/public/jquery-1.7.1.min.js +4 -0
- data/lib/ledger_web/public/jquery.tablesorter.min.js +4 -0
- data/lib/ledger_web/public/ledger.css +14 -0
- data/lib/ledger_web/report.rb +187 -0
- data/lib/ledger_web/reports/savings_rate.erb +49 -0
- data/lib/ledger_web/version.rb +3 -0
- data/lib/ledger_web/views/error.erb +5 -0
- data/lib/ledger_web/views/help.erb +6 -0
- data/lib/ledger_web/views/layout.erb +44 -0
- data/lib/ledger_web/views/table.erb +31 -0
- data/lib/ledger_web/watcher.rb +37 -0
- data/lib/ledger_web.rb +20 -0
- metadata +229 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror: PHP mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="../xml/xml.js"></script>
|
8
|
+
<script src="../javascript/javascript.js"></script>
|
9
|
+
<script src="../css/css.js"></script>
|
10
|
+
<script src="../clike/clike.js"></script>
|
11
|
+
<script src="php.js"></script>
|
12
|
+
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
13
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<h1>CodeMirror: PHP mode</h1>
|
17
|
+
|
18
|
+
<form><textarea id="code" name="code">
|
19
|
+
<?php
|
20
|
+
function hello($who) {
|
21
|
+
return "Hello " . $who;
|
22
|
+
}
|
23
|
+
?>
|
24
|
+
<p>The program says <?= hello("World") ?>.</p>
|
25
|
+
<script>
|
26
|
+
alert("And here is some JS code"); // also colored
|
27
|
+
</script>
|
28
|
+
</textarea></form>
|
29
|
+
|
30
|
+
<script>
|
31
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
32
|
+
lineNumbers: true,
|
33
|
+
matchBrackets: true,
|
34
|
+
mode: "application/x-httpd-php",
|
35
|
+
indentUnit: 4,
|
36
|
+
indentWithTabs: true,
|
37
|
+
enterMode: "keep",
|
38
|
+
tabMode: "shift"
|
39
|
+
});
|
40
|
+
</script>
|
41
|
+
|
42
|
+
<p>Simple HTML/PHP mode based on
|
43
|
+
the <a href="../clike/">C-like</a> mode. Depends on XML,
|
44
|
+
JavaScript, CSS, and C-like modes.</p>
|
45
|
+
|
46
|
+
<p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
|
47
|
+
</body>
|
48
|
+
</html>
|
@@ -0,0 +1,120 @@
|
|
1
|
+
(function() {
|
2
|
+
function keywords(str) {
|
3
|
+
var obj = {}, words = str.split(" ");
|
4
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
5
|
+
return obj;
|
6
|
+
}
|
7
|
+
function heredoc(delim) {
|
8
|
+
return function(stream, state) {
|
9
|
+
if (stream.match(delim)) state.tokenize = null;
|
10
|
+
else stream.skipToEnd();
|
11
|
+
return "string";
|
12
|
+
}
|
13
|
+
}
|
14
|
+
var phpConfig = {
|
15
|
+
name: "clike",
|
16
|
+
keywords: keywords("abstract and array as break case catch cfunction class clone const continue declare " +
|
17
|
+
"default do else elseif enddeclare endfor endforeach endif endswitch endwhile extends " +
|
18
|
+
"final for foreach function global goto if implements interface instanceof namespace " +
|
19
|
+
"new or private protected public static switch throw try use var while xor return" +
|
20
|
+
"die echo empty exit eval include include_once isset list require require_once print unset"),
|
21
|
+
blockKeywords: keywords("catch do else elseif for foreach if switch try while"),
|
22
|
+
atoms: keywords("true false null TRUE FALSE NULL"),
|
23
|
+
multiLineStrings: true,
|
24
|
+
hooks: {
|
25
|
+
"$": function(stream, state) {
|
26
|
+
stream.eatWhile(/[\w\$_]/);
|
27
|
+
return "variable-2";
|
28
|
+
},
|
29
|
+
"<": function(stream, state) {
|
30
|
+
if (stream.match(/<</)) {
|
31
|
+
stream.eatWhile(/[\w\.]/);
|
32
|
+
state.tokenize = heredoc(stream.current().slice(3));
|
33
|
+
return state.tokenize(stream, state);
|
34
|
+
}
|
35
|
+
return false;
|
36
|
+
},
|
37
|
+
"#": function(stream, state) {
|
38
|
+
stream.skipToEnd();
|
39
|
+
return "comment";
|
40
|
+
}
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
CodeMirror.defineMode("php", function(config, parserConfig) {
|
45
|
+
var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true});
|
46
|
+
var jsMode = CodeMirror.getMode(config, "javascript");
|
47
|
+
var cssMode = CodeMirror.getMode(config, "css");
|
48
|
+
var phpMode = CodeMirror.getMode(config, phpConfig);
|
49
|
+
|
50
|
+
function dispatch(stream, state) { // TODO open PHP inside text/css
|
51
|
+
if (state.curMode == htmlMode) {
|
52
|
+
var style = htmlMode.token(stream, state.curState);
|
53
|
+
if (style == "meta" && /^<\?/.test(stream.current())) {
|
54
|
+
state.curMode = phpMode;
|
55
|
+
state.curState = state.php;
|
56
|
+
state.curClose = /^\?>/;
|
57
|
+
state.mode = 'php';
|
58
|
+
}
|
59
|
+
else if (style == "tag" && stream.current() == ">" && state.curState.context) {
|
60
|
+
if (/^script$/i.test(state.curState.context.tagName)) {
|
61
|
+
state.curMode = jsMode;
|
62
|
+
state.curState = jsMode.startState(htmlMode.indent(state.curState, ""));
|
63
|
+
state.curClose = /^<\/\s*script\s*>/i;
|
64
|
+
state.mode = 'javascript';
|
65
|
+
}
|
66
|
+
else if (/^style$/i.test(state.curState.context.tagName)) {
|
67
|
+
state.curMode = cssMode;
|
68
|
+
state.curState = cssMode.startState(htmlMode.indent(state.curState, ""));
|
69
|
+
state.curClose = /^<\/\s*style\s*>/i;
|
70
|
+
state.mode = 'css';
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return style;
|
74
|
+
}
|
75
|
+
else if (stream.match(state.curClose, false)) {
|
76
|
+
state.curMode = htmlMode;
|
77
|
+
state.curState = state.html;
|
78
|
+
state.curClose = null;
|
79
|
+
state.mode = 'html';
|
80
|
+
return dispatch(stream, state);
|
81
|
+
}
|
82
|
+
else return state.curMode.token(stream, state.curState);
|
83
|
+
}
|
84
|
+
|
85
|
+
return {
|
86
|
+
startState: function() {
|
87
|
+
var html = htmlMode.startState();
|
88
|
+
return {html: html,
|
89
|
+
php: phpMode.startState(),
|
90
|
+
curMode: parserConfig.startOpen ? phpMode : htmlMode,
|
91
|
+
curState: parserConfig.startOpen ? phpMode.startState() : html,
|
92
|
+
curClose: parserConfig.startOpen ? /^\?>/ : null,
|
93
|
+
mode: parserConfig.startOpen ? 'php' : 'html'}
|
94
|
+
},
|
95
|
+
|
96
|
+
copyState: function(state) {
|
97
|
+
var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
|
98
|
+
php = state.php, phpNew = CodeMirror.copyState(phpMode, php), cur;
|
99
|
+
if (state.curState == html) cur = htmlNew;
|
100
|
+
else if (state.curState == php) cur = phpNew;
|
101
|
+
else cur = CodeMirror.copyState(state.curMode, state.curState);
|
102
|
+
return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur, curClose: state.curClose};
|
103
|
+
},
|
104
|
+
|
105
|
+
token: dispatch,
|
106
|
+
|
107
|
+
indent: function(state, textAfter) {
|
108
|
+
if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) ||
|
109
|
+
(state.curMode == phpMode && /^\?>/.test(textAfter)))
|
110
|
+
return htmlMode.indent(state.html, textAfter);
|
111
|
+
return state.curMode.indent(state.curState, textAfter);
|
112
|
+
},
|
113
|
+
|
114
|
+
electricChars: "/{}:"
|
115
|
+
}
|
116
|
+
});
|
117
|
+
CodeMirror.defineMIME("application/x-httpd-php", "php");
|
118
|
+
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
119
|
+
CodeMirror.defineMIME("text/x-php", phpConfig);
|
120
|
+
})();
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror: Oracle PL/SQL mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="plsql.js"></script>
|
8
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
9
|
+
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h1>CodeMirror: Oracle PL/SQL mode</h1>
|
13
|
+
|
14
|
+
<form><textarea id="code" name="code">
|
15
|
+
-- Oracle PL/SQL Code Demo
|
16
|
+
/*
|
17
|
+
based on c-like mode, adapted to PL/SQL by Peter Raganitsch ( http://www.oracle-and-apex.com/ )
|
18
|
+
April 2011
|
19
|
+
*/
|
20
|
+
DECLARE
|
21
|
+
vIdx NUMBER;
|
22
|
+
vString VARCHAR2(100);
|
23
|
+
cText CONSTANT VARCHAR2(100) := 'That''s it! Have fun with CodeMirror 2';
|
24
|
+
BEGIN
|
25
|
+
vIdx := 0;
|
26
|
+
--
|
27
|
+
FOR rDATA IN
|
28
|
+
( SELECT *
|
29
|
+
FROM EMP
|
30
|
+
ORDER BY EMPNO
|
31
|
+
)
|
32
|
+
LOOP
|
33
|
+
vIdx := vIdx + 1;
|
34
|
+
vString := rDATA.EMPNO || ' - ' || rDATA.ENAME;
|
35
|
+
--
|
36
|
+
UPDATE EMP
|
37
|
+
SET SAL = SAL * 101/100
|
38
|
+
WHERE EMPNO = rDATA.EMPNO
|
39
|
+
;
|
40
|
+
END LOOP;
|
41
|
+
--
|
42
|
+
SYS.DBMS_OUTPUT.Put_Line (cText);
|
43
|
+
END;
|
44
|
+
--
|
45
|
+
</textarea></form>
|
46
|
+
|
47
|
+
<script>
|
48
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
49
|
+
lineNumbers: true,
|
50
|
+
matchBrackets: true,
|
51
|
+
indentUnit: 4,
|
52
|
+
mode: "text/x-plsql"
|
53
|
+
});
|
54
|
+
</script>
|
55
|
+
|
56
|
+
<p>
|
57
|
+
Simple mode that handles Oracle PL/SQL language (and Oracle SQL, of course).
|
58
|
+
</p>
|
59
|
+
|
60
|
+
<p><strong>MIME type defined:</strong> <code>text/x-plsql</code>
|
61
|
+
(PLSQL code)
|
62
|
+
</html>
|
@@ -0,0 +1,217 @@
|
|
1
|
+
CodeMirror.defineMode("plsql", function(config, parserConfig) {
|
2
|
+
var indentUnit = config.indentUnit,
|
3
|
+
keywords = parserConfig.keywords,
|
4
|
+
functions = parserConfig.functions,
|
5
|
+
types = parserConfig.types,
|
6
|
+
sqlplus = parserConfig.sqlplus,
|
7
|
+
multiLineStrings = parserConfig.multiLineStrings;
|
8
|
+
var isOperatorChar = /[+\-*&%=<>!?:\/|]/;
|
9
|
+
function chain(stream, state, f) {
|
10
|
+
state.tokenize = f;
|
11
|
+
return f(stream, state);
|
12
|
+
}
|
13
|
+
|
14
|
+
var type;
|
15
|
+
function ret(tp, style) {
|
16
|
+
type = tp;
|
17
|
+
return style;
|
18
|
+
}
|
19
|
+
|
20
|
+
function tokenBase(stream, state) {
|
21
|
+
var ch = stream.next();
|
22
|
+
// start of string?
|
23
|
+
if (ch == '"' || ch == "'")
|
24
|
+
return chain(stream, state, tokenString(ch));
|
25
|
+
// is it one of the special signs []{}().,;? Seperator?
|
26
|
+
else if (/[\[\]{}\(\),;\.]/.test(ch))
|
27
|
+
return ret(ch);
|
28
|
+
// start of a number value?
|
29
|
+
else if (/\d/.test(ch)) {
|
30
|
+
stream.eatWhile(/[\w\.]/);
|
31
|
+
return ret("number", "number");
|
32
|
+
}
|
33
|
+
// multi line comment or simple operator?
|
34
|
+
else if (ch == "/") {
|
35
|
+
if (stream.eat("*")) {
|
36
|
+
return chain(stream, state, tokenComment);
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
stream.eatWhile(isOperatorChar);
|
40
|
+
return ret("operator", "operator");
|
41
|
+
}
|
42
|
+
}
|
43
|
+
// single line comment or simple operator?
|
44
|
+
else if (ch == "-") {
|
45
|
+
if (stream.eat("-")) {
|
46
|
+
stream.skipToEnd();
|
47
|
+
return ret("comment", "comment");
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
stream.eatWhile(isOperatorChar);
|
51
|
+
return ret("operator", "operator");
|
52
|
+
}
|
53
|
+
}
|
54
|
+
// pl/sql variable?
|
55
|
+
else if (ch == "@" || ch == "$") {
|
56
|
+
stream.eatWhile(/[\w\d\$_]/);
|
57
|
+
return ret("word", "variable");
|
58
|
+
}
|
59
|
+
// is it a operator?
|
60
|
+
else if (isOperatorChar.test(ch)) {
|
61
|
+
stream.eatWhile(isOperatorChar);
|
62
|
+
return ret("operator", "operator");
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
// get the whole word
|
66
|
+
stream.eatWhile(/[\w\$_]/);
|
67
|
+
// is it one of the listed keywords?
|
68
|
+
if (keywords && keywords.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "keyword");
|
69
|
+
// is it one of the listed functions?
|
70
|
+
if (functions && functions.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "builtin");
|
71
|
+
// is it one of the listed types?
|
72
|
+
if (types && types.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-2");
|
73
|
+
// is it one of the listed sqlplus keywords?
|
74
|
+
if (sqlplus && sqlplus.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-3");
|
75
|
+
// default: just a "word"
|
76
|
+
return ret("word", "plsql-word");
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
function tokenString(quote) {
|
81
|
+
return function(stream, state) {
|
82
|
+
var escaped = false, next, end = false;
|
83
|
+
while ((next = stream.next()) != null) {
|
84
|
+
if (next == quote && !escaped) {end = true; break;}
|
85
|
+
escaped = !escaped && next == "\\";
|
86
|
+
}
|
87
|
+
if (end || !(escaped || multiLineStrings))
|
88
|
+
state.tokenize = tokenBase;
|
89
|
+
return ret("string", "plsql-string");
|
90
|
+
};
|
91
|
+
}
|
92
|
+
|
93
|
+
function tokenComment(stream, state) {
|
94
|
+
var maybeEnd = false, ch;
|
95
|
+
while (ch = stream.next()) {
|
96
|
+
if (ch == "/" && maybeEnd) {
|
97
|
+
state.tokenize = tokenBase;
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
maybeEnd = (ch == "*");
|
101
|
+
}
|
102
|
+
return ret("comment", "plsql-comment");
|
103
|
+
}
|
104
|
+
|
105
|
+
// Interface
|
106
|
+
|
107
|
+
return {
|
108
|
+
startState: function(basecolumn) {
|
109
|
+
return {
|
110
|
+
tokenize: tokenBase,
|
111
|
+
startOfLine: true
|
112
|
+
};
|
113
|
+
},
|
114
|
+
|
115
|
+
token: function(stream, state) {
|
116
|
+
if (stream.eatSpace()) return null;
|
117
|
+
var style = state.tokenize(stream, state);
|
118
|
+
return style;
|
119
|
+
}
|
120
|
+
};
|
121
|
+
});
|
122
|
+
|
123
|
+
(function() {
|
124
|
+
function keywords(str) {
|
125
|
+
var obj = {}, words = str.split(" ");
|
126
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
127
|
+
return obj;
|
128
|
+
}
|
129
|
+
var cKeywords = "abort accept access add all alter and any array arraylen as asc assert assign at attributes audit " +
|
130
|
+
"authorization avg " +
|
131
|
+
"base_table begin between binary_integer body boolean by " +
|
132
|
+
"case cast char char_base check close cluster clusters colauth column comment commit compress connect " +
|
133
|
+
"connected constant constraint crash create current currval cursor " +
|
134
|
+
"data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete " +
|
135
|
+
"desc digits dispose distinct do drop " +
|
136
|
+
"else elsif enable end entry escape exception exception_init exchange exclusive exists exit external " +
|
137
|
+
"fast fetch file for force form from function " +
|
138
|
+
"generic goto grant group " +
|
139
|
+
"having " +
|
140
|
+
"identified if immediate in increment index indexes indicator initial initrans insert interface intersect " +
|
141
|
+
"into is " +
|
142
|
+
"key " +
|
143
|
+
"level library like limited local lock log logging long loop " +
|
144
|
+
"master maxextents maxtrans member minextents minus mislabel mode modify multiset " +
|
145
|
+
"new next no noaudit nocompress nologging noparallel not nowait number_base " +
|
146
|
+
"object of off offline on online only open option or order out " +
|
147
|
+
"package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior " +
|
148
|
+
"private privileges procedure public " +
|
149
|
+
"raise range raw read rebuild record ref references refresh release rename replace resource restrict return " +
|
150
|
+
"returning reverse revoke rollback row rowid rowlabel rownum rows run " +
|
151
|
+
"savepoint schema segment select separate session set share snapshot some space split sql start statement " +
|
152
|
+
"storage subtype successful synonym " +
|
153
|
+
"tabauth table tables tablespace task terminate then to trigger truncate type " +
|
154
|
+
"union unique unlimited unrecoverable unusable update use using " +
|
155
|
+
"validate value values variable view views " +
|
156
|
+
"when whenever where while with work";
|
157
|
+
|
158
|
+
var cFunctions = "abs acos add_months ascii asin atan atan2 average " +
|
159
|
+
"bfilename " +
|
160
|
+
"ceil chartorowid chr concat convert cos cosh count " +
|
161
|
+
"decode deref dual dump dup_val_on_index " +
|
162
|
+
"empty error exp " +
|
163
|
+
"false floor found " +
|
164
|
+
"glb greatest " +
|
165
|
+
"hextoraw " +
|
166
|
+
"initcap instr instrb isopen " +
|
167
|
+
"last_day least lenght lenghtb ln lower lpad ltrim lub " +
|
168
|
+
"make_ref max min mod months_between " +
|
169
|
+
"new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower " +
|
170
|
+
"nls_sort nls_upper nlssort no_data_found notfound null nvl " +
|
171
|
+
"others " +
|
172
|
+
"power " +
|
173
|
+
"rawtohex reftohex round rowcount rowidtochar rpad rtrim " +
|
174
|
+
"sign sin sinh soundex sqlcode sqlerrm sqrt stddev substr substrb sum sysdate " +
|
175
|
+
"tan tanh to_char to_date to_label to_multi_byte to_number to_single_byte translate true trunc " +
|
176
|
+
"uid upper user userenv " +
|
177
|
+
"variance vsize";
|
178
|
+
|
179
|
+
var cTypes = "bfile blob " +
|
180
|
+
"character clob " +
|
181
|
+
"dec " +
|
182
|
+
"float " +
|
183
|
+
"int integer " +
|
184
|
+
"mlslabel " +
|
185
|
+
"natural naturaln nchar nclob number numeric nvarchar2 " +
|
186
|
+
"real rowtype " +
|
187
|
+
"signtype smallint string " +
|
188
|
+
"varchar varchar2";
|
189
|
+
|
190
|
+
var cSqlplus = "appinfo arraysize autocommit autoprint autorecovery autotrace " +
|
191
|
+
"blockterminator break btitle " +
|
192
|
+
"cmdsep colsep compatibility compute concat copycommit copytypecheck " +
|
193
|
+
"define describe " +
|
194
|
+
"echo editfile embedded escape exec execute " +
|
195
|
+
"feedback flagger flush " +
|
196
|
+
"heading headsep " +
|
197
|
+
"instance " +
|
198
|
+
"linesize lno loboffset logsource long longchunksize " +
|
199
|
+
"markup " +
|
200
|
+
"native newpage numformat numwidth " +
|
201
|
+
"pagesize pause pno " +
|
202
|
+
"recsep recsepchar release repfooter repheader " +
|
203
|
+
"serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber " +
|
204
|
+
"sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix " +
|
205
|
+
"tab term termout time timing trimout trimspool ttitle " +
|
206
|
+
"underline " +
|
207
|
+
"verify version " +
|
208
|
+
"wrap";
|
209
|
+
|
210
|
+
CodeMirror.defineMIME("text/x-plsql", {
|
211
|
+
name: "plsql",
|
212
|
+
keywords: keywords(cKeywords),
|
213
|
+
functions: keywords(cFunctions),
|
214
|
+
types: keywords(cTypes),
|
215
|
+
sqlplus: keywords(cSqlplus)
|
216
|
+
});
|
217
|
+
}());
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010 Timothy Farrell
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,122 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror: Python mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="python.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: Python mode</h1>
|
13
|
+
|
14
|
+
<div><textarea id="code" name="code">
|
15
|
+
# Literals
|
16
|
+
1234
|
17
|
+
0.0e101
|
18
|
+
.123
|
19
|
+
0b01010011100
|
20
|
+
0o01234567
|
21
|
+
0x0987654321abcdef
|
22
|
+
7
|
23
|
+
2147483647
|
24
|
+
3L
|
25
|
+
79228162514264337593543950336L
|
26
|
+
0x100000000L
|
27
|
+
79228162514264337593543950336
|
28
|
+
0xdeadbeef
|
29
|
+
3.14j
|
30
|
+
10.j
|
31
|
+
10j
|
32
|
+
.001j
|
33
|
+
1e100j
|
34
|
+
3.14e-10j
|
35
|
+
|
36
|
+
|
37
|
+
# String Literals
|
38
|
+
'For\''
|
39
|
+
"God\""
|
40
|
+
"""so loved
|
41
|
+
the world"""
|
42
|
+
'''that he gave
|
43
|
+
his only begotten\' '''
|
44
|
+
'that whosoever believeth \
|
45
|
+
in him'
|
46
|
+
''
|
47
|
+
|
48
|
+
# Identifiers
|
49
|
+
__a__
|
50
|
+
a.b
|
51
|
+
a.b.c
|
52
|
+
|
53
|
+
# Operators
|
54
|
+
+ - * / % & | ^ ~ < >
|
55
|
+
== != <= >= <> << >> // **
|
56
|
+
and or not in is
|
57
|
+
|
58
|
+
# Delimiters
|
59
|
+
() [] {} , : ` = ; @ . # Note that @ and . require the proper context.
|
60
|
+
+= -= *= /= %= &= |= ^=
|
61
|
+
//= >>= <<= **=
|
62
|
+
|
63
|
+
# Keywords
|
64
|
+
as assert break class continue def del elif else except
|
65
|
+
finally for from global if import lambda pass raise
|
66
|
+
return try while with yield
|
67
|
+
|
68
|
+
# Python 2 Keywords (otherwise Identifiers)
|
69
|
+
exec print
|
70
|
+
|
71
|
+
# Python 3 Keywords (otherwise Identifiers)
|
72
|
+
nonlocal
|
73
|
+
|
74
|
+
# Types
|
75
|
+
bool classmethod complex dict enumerate float frozenset int list object
|
76
|
+
property reversed set slice staticmethod str super tuple type
|
77
|
+
|
78
|
+
# Python 2 Types (otherwise Identifiers)
|
79
|
+
basestring buffer file long unicode xrange
|
80
|
+
|
81
|
+
# Python 3 Types (otherwise Identifiers)
|
82
|
+
bytearray bytes filter map memoryview open range zip
|
83
|
+
|
84
|
+
# Some Example code
|
85
|
+
import os
|
86
|
+
from package import ParentClass
|
87
|
+
|
88
|
+
@nonsenseDecorator
|
89
|
+
def doesNothing():
|
90
|
+
pass
|
91
|
+
|
92
|
+
class ExampleClass(ParentClass):
|
93
|
+
@staticmethod
|
94
|
+
def example(inputStr):
|
95
|
+
a = list(inputStr)
|
96
|
+
a.reverse()
|
97
|
+
return ''.join(a)
|
98
|
+
|
99
|
+
def __init__(self, mixin = 'Hello'):
|
100
|
+
self.mixin = mixin
|
101
|
+
|
102
|
+
</textarea></div>
|
103
|
+
<script>
|
104
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
105
|
+
mode: {name: "python",
|
106
|
+
version: 2,
|
107
|
+
singleLineStringErrors: false},
|
108
|
+
lineNumbers: true,
|
109
|
+
indentUnit: 4,
|
110
|
+
tabMode: "shift",
|
111
|
+
matchBrackets: true
|
112
|
+
});
|
113
|
+
</script>
|
114
|
+
<h2>Configuration Options:</h2>
|
115
|
+
<ul>
|
116
|
+
<li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
|
117
|
+
<li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
|
118
|
+
</ul>
|
119
|
+
|
120
|
+
<p><strong>MIME types defined:</strong> <code>text/x-python</code>.</p>
|
121
|
+
</body>
|
122
|
+
</html>
|