swagr 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/Rakefile +20 -0
  2. data/bin/swagr +37 -9
  3. data/examples/examples01/app.rb +5 -1
  4. data/examples/examples01/views/edit.slim +31 -0
  5. data/examples/examples01/views/footer.slim +1 -1
  6. data/examples/examples01/views/layout.slim +23 -5
  7. data/examples/examples01/views/navbar.slim +17 -16
  8. data/lib/swagr/version.rb +3 -1
  9. data/templates/app.rb +5 -1
  10. data/templates/static/js/codemirror/keymap/vim.js +279 -66
  11. data/templates/static/js/codemirror/lib/codemirror.css +10 -9
  12. data/templates/static/js/codemirror/lib/codemirror.js +385 -152
  13. data/templates/static/js/codemirror/mode/apl/apl.js +160 -0
  14. data/templates/static/js/codemirror/mode/apl/index.html +61 -0
  15. data/templates/static/js/codemirror/mode/asterisk/asterisk.js +183 -0
  16. data/templates/static/js/codemirror/mode/asterisk/index.html +142 -0
  17. data/templates/static/js/codemirror/mode/clike/clike.js +2 -0
  18. data/templates/static/js/codemirror/mode/clike/index.html +1 -1
  19. data/templates/static/js/codemirror/mode/clike/scala.html +1 -1
  20. data/templates/static/js/codemirror/mode/clojure/clojure.js +3 -3
  21. data/templates/static/js/codemirror/mode/css/css.js +2 -2
  22. data/templates/static/js/codemirror/mode/css/test.js +76 -471
  23. data/templates/static/js/codemirror/mode/d/d.js +205 -0
  24. data/templates/static/js/codemirror/mode/d/index.html +262 -0
  25. data/templates/static/js/codemirror/mode/erlang/index.html +1 -1
  26. data/templates/static/js/codemirror/mode/gfm/gfm.js +2 -1
  27. data/templates/static/js/codemirror/mode/gfm/index.html +1 -2
  28. data/templates/static/js/codemirror/mode/gfm/test.js +84 -225
  29. data/templates/static/js/codemirror/mode/go/index.html +1 -1
  30. data/templates/static/js/codemirror/mode/groovy/index.html +1 -1
  31. data/templates/static/js/codemirror/mode/haskell/index.html +1 -1
  32. data/templates/static/js/codemirror/mode/javascript/index.html +2 -2
  33. data/templates/static/js/codemirror/mode/javascript/javascript.js +13 -2
  34. data/templates/static/js/codemirror/mode/less/index.html +1 -1
  35. data/templates/static/js/codemirror/mode/lua/index.html +1 -1
  36. data/templates/static/js/codemirror/mode/markdown/index.html +1 -1
  37. data/templates/static/js/codemirror/mode/markdown/markdown.js +8 -7
  38. data/templates/static/js/codemirror/mode/markdown/test.js +579 -1266
  39. data/templates/static/js/codemirror/mode/meta.js +71 -0
  40. data/templates/static/js/codemirror/mode/mysql/index.html +2 -0
  41. data/templates/static/js/codemirror/mode/ocaml/index.html +1 -1
  42. data/templates/static/js/codemirror/mode/php/index.html +1 -1
  43. data/templates/static/js/codemirror/mode/plsql/index.html +2 -0
  44. data/templates/static/js/codemirror/mode/python/index.html +1 -1
  45. data/templates/static/js/codemirror/mode/ruby/index.html +1 -1
  46. data/templates/static/js/codemirror/mode/sass/index.html +54 -0
  47. data/templates/static/js/codemirror/mode/sass/sass.js +349 -0
  48. data/templates/static/js/codemirror/mode/shell/index.html +1 -1
  49. data/templates/static/js/codemirror/mode/sieve/LICENSE +0 -4
  50. data/templates/static/js/codemirror/mode/sieve/sieve.js +37 -10
  51. data/templates/static/js/codemirror/mode/smalltalk/index.html +1 -1
  52. data/templates/static/js/codemirror/mode/sparql/index.html +1 -1
  53. data/templates/static/js/codemirror/mode/sql/index.html +68 -0
  54. data/templates/static/js/codemirror/mode/sql/sql.js +268 -0
  55. data/templates/static/js/codemirror/mode/stex/test.js +104 -343
  56. data/templates/static/js/codemirror/mode/tiddlywiki/index.html +1 -1
  57. data/templates/static/js/codemirror/mode/vb/index.html +1 -1
  58. data/templates/static/js/codemirror/mode/xquery/test.js +54 -67
  59. data/templates/static/js/codemirror/mode/xquery/xquery.js +8 -8
  60. data/templates/static/js/crossfilter.min.js +1 -0
  61. data/templates/views/edit.slim +31 -0
  62. data/templates/views/footer.slim +1 -1
  63. data/templates/views/layout.slim +23 -5
  64. data/templates/views/navbar.slim +17 -16
  65. metadata +16 -30
  66. data/examples/examples01/static/css/codemirror.css +0 -1247
  67. data/examples/examples01/static/js/codemirror-compressed-3-0.js +0 -5
  68. data/examples/examples01/views/about.slim +0 -15
  69. data/examples/examples01/views/application.slim +0 -0
  70. data/examples/examples01/views/layout_cm.slim +0 -17
  71. data/templates/static/js/codemirror/lib/util/closetag.js +0 -85
  72. data/templates/static/js/codemirror/lib/util/colorize.js +0 -29
  73. data/templates/static/js/codemirror/lib/util/continuecomment.js +0 -36
  74. data/templates/static/js/codemirror/lib/util/continuelist.js +0 -28
  75. data/templates/static/js/codemirror/lib/util/dialog.css +0 -32
  76. data/templates/static/js/codemirror/lib/util/dialog.js +0 -75
  77. data/templates/static/js/codemirror/lib/util/foldcode.js +0 -182
  78. data/templates/static/js/codemirror/lib/util/formatting.js +0 -108
  79. data/templates/static/js/codemirror/lib/util/javascript-hint.js +0 -137
  80. data/templates/static/js/codemirror/lib/util/loadmode.js +0 -51
  81. data/templates/static/js/codemirror/lib/util/match-highlighter.js +0 -46
  82. data/templates/static/js/codemirror/lib/util/matchbrackets.js +0 -63
  83. data/templates/static/js/codemirror/lib/util/multiplex.js +0 -95
  84. data/templates/static/js/codemirror/lib/util/overlay.js +0 -59
  85. data/templates/static/js/codemirror/lib/util/pig-hint.js +0 -117
  86. data/templates/static/js/codemirror/lib/util/runmode-standalone.js +0 -90
  87. data/templates/static/js/codemirror/lib/util/runmode.js +0 -52
  88. data/templates/static/js/codemirror/lib/util/search.js +0 -119
  89. data/templates/static/js/codemirror/lib/util/searchcursor.js +0 -119
  90. data/templates/static/js/codemirror/lib/util/simple-hint.css +0 -16
  91. data/templates/static/js/codemirror/lib/util/simple-hint.js +0 -102
  92. data/templates/static/js/codemirror/lib/util/xml-hint.js +0 -131
  93. data/templates/views/about.slim +0 -15
@@ -0,0 +1,160 @@
1
+ CodeMirror.defineMode("apl", function() {
2
+ var builtInOps = {
3
+ ".": "innerProduct",
4
+ "\\": "scan",
5
+ "/": "reduce",
6
+ "⌿": "reduce1Axis",
7
+ "⍀": "scan1Axis",
8
+ "¨": "each",
9
+ "⍣": "power"
10
+ };
11
+ var builtInFuncs = {
12
+ "+": ["conjugate", "add"],
13
+ "−": ["negate", "subtract"],
14
+ "×": ["signOf", "multiply"],
15
+ "÷": ["reciprocal", "divide"],
16
+ "⌈": ["ceiling", "greaterOf"],
17
+ "⌊": ["floor", "lesserOf"],
18
+ "∣": ["absolute", "residue"],
19
+ "⍳": ["indexGenerate", "indexOf"],
20
+ "?": ["roll", "deal"],
21
+ "⋆": ["exponentiate", "toThePowerOf"],
22
+ "⍟": ["naturalLog", "logToTheBase"],
23
+ "○": ["piTimes", "circularFuncs"],
24
+ "!": ["factorial", "binomial"],
25
+ "⌹": ["matrixInverse", "matrixDivide"],
26
+ "<": [null, "lessThan"],
27
+ "≤": [null, "lessThanOrEqual"],
28
+ "=": [null, "equals"],
29
+ ">": [null, "greaterThan"],
30
+ "≥": [null, "greaterThanOrEqual"],
31
+ "≠": [null, "notEqual"],
32
+ "≡": ["depth", "match"],
33
+ "≢": [null, "notMatch"],
34
+ "∈": ["enlist", "membership"],
35
+ "⍷": [null, "find"],
36
+ "∪": ["unique", "union"],
37
+ "∩": [null, "intersection"],
38
+ "∼": ["not", "without"],
39
+ "∨": [null, "or"],
40
+ "∧": [null, "and"],
41
+ "⍱": [null, "nor"],
42
+ "⍲": [null, "nand"],
43
+ "⍴": ["shapeOf", "reshape"],
44
+ ",": ["ravel", "catenate"],
45
+ "⍪": [null, "firstAxisCatenate"],
46
+ "⌽": ["reverse", "rotate"],
47
+ "⊖": ["axis1Reverse", "axis1Rotate"],
48
+ "⍉": ["transpose", null],
49
+ "↑": ["first", "take"],
50
+ "↓": [null, "drop"],
51
+ "⊂": ["enclose", "partitionWithAxis"],
52
+ "⊃": ["diclose", "pick"],
53
+ "⌷": [null, "index"],
54
+ "⍋": ["gradeUp", null],
55
+ "⍒": ["gradeDown", null],
56
+ "⊤": ["encode", null],
57
+ "⊥": ["decode", null],
58
+ "⍕": ["format", "formatByExample"],
59
+ "⍎": ["execute", null],
60
+ "⊣": ["stop", "left"],
61
+ "⊢": ["pass", "right"]
62
+ };
63
+
64
+ var isOperator = /[\.\/⌿⍀¨⍣]/;
65
+ var isNiladic = /⍬/;
66
+ var isFunction = /[\+−×÷⌈⌊∣⍳\?⋆⍟○!⌹<≤=>≥≠≡≢∈⍷∪∩∼∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢]/;
67
+ var isArrow = /←/;
68
+ var isComment = /[⍝#].*$/;
69
+
70
+ var stringEater = function(type) {
71
+ var prev;
72
+ prev = false;
73
+ return function(c) {
74
+ prev = c;
75
+ if (c === type) {
76
+ return prev === "\\";
77
+ }
78
+ return true;
79
+ };
80
+ };
81
+ return {
82
+ startState: function() {
83
+ return {
84
+ prev: false,
85
+ func: false,
86
+ op: false,
87
+ string: false,
88
+ escape: false
89
+ };
90
+ },
91
+ token: function(stream, state) {
92
+ var ch, funcName, word;
93
+ if (stream.eatSpace()) {
94
+ return null;
95
+ }
96
+ ch = stream.next();
97
+ if (ch === '"' || ch === "'") {
98
+ stream.eatWhile(stringEater(ch));
99
+ stream.next();
100
+ state.prev = true;
101
+ return "string";
102
+ }
103
+ if (/[\[{\(]/.test(ch)) {
104
+ state.prev = false;
105
+ return null;
106
+ }
107
+ if (/[\]}\)]/.test(ch)) {
108
+ state.prev = true;
109
+ return null;
110
+ }
111
+ if (isNiladic.test(ch)) {
112
+ state.prev = false;
113
+ return "niladic";
114
+ }
115
+ if (/[¯\d]/.test(ch)) {
116
+ if (state.func) {
117
+ state.func = false;
118
+ state.prev = false;
119
+ } else {
120
+ state.prev = true;
121
+ }
122
+ stream.eatWhile(/[\w\.]/);
123
+ return "number";
124
+ }
125
+ if (isOperator.test(ch)) {
126
+ return "operator apl-" + builtInOps[ch];
127
+ }
128
+ if (isArrow.test(ch)) {
129
+ return "apl-arrow";
130
+ }
131
+ if (isFunction.test(ch)) {
132
+ funcName = "apl-";
133
+ if (builtInFuncs[ch] != null) {
134
+ if (state.prev) {
135
+ funcName += builtInFuncs[ch][1];
136
+ } else {
137
+ funcName += builtInFuncs[ch][0];
138
+ }
139
+ }
140
+ state.func = true;
141
+ state.prev = false;
142
+ return "function " + funcName;
143
+ }
144
+ if (isComment.test(ch)) {
145
+ stream.skipToEnd();
146
+ return "comment";
147
+ }
148
+ if (ch === "∘" && stream.peek() === ".") {
149
+ stream.next();
150
+ return "function jot-dot";
151
+ }
152
+ stream.eatWhile(/[\w\$_]/);
153
+ word = stream.current();
154
+ state.prev = true;
155
+ return "keyword";
156
+ }
157
+ };
158
+ });
159
+
160
+ CodeMirror.defineMIME("text/apl", "apl");
@@ -0,0 +1,61 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>CodeMirror: APL mode</title>
6
+ <link rel="stylesheet" href="../../doc/docs.css">
7
+ <link rel="stylesheet" href="../../lib/codemirror.css">
8
+ <script src="../../lib/codemirror.js"></script>
9
+ <script src="../../addon/edit/matchbrackets.js"></script>
10
+ <script src="./apl.js"></script>
11
+ <style>
12
+ .CodeMirror { border: 2px inset #dee; }
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <h1>CodeMirror: APL mode</h1>
17
+
18
+ <form><textarea id="code" name="code">
19
+ ⍝ Conway's game of life
20
+
21
+ ⍝ This example was inspired by the impressive demo at
22
+ ⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
23
+
24
+ ⍝ Create a matrix:
25
+ ⍝ 0 1 1
26
+ ⍝ 1 1 0
27
+ ⍝ 0 1 0
28
+ creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
29
+ creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider
30
+
31
+ ⍝ Place the creature on a larger board, near the centre
32
+ board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
33
+
34
+ ⍝ A function to move from one generation to the next
35
+ life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
36
+
37
+ ⍝ Compute n-th generation and format it as a
38
+ ⍝ character matrix
39
+ gen ← {' #'[(life ⍣ ⍵) board]}
40
+
41
+ ⍝ Show first three generations
42
+ (gen 1) (gen 2) (gen 3)
43
+ </textarea></form>
44
+
45
+ <script>
46
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
47
+ lineNumbers: true,
48
+ matchBrackets: true,
49
+ mode: "text/apl"
50
+ });
51
+ </script>
52
+
53
+ <p>Simple mode that tries to handle APL as well as it can.</p>
54
+ <p>It attempts to label functions/operators based upon
55
+ monadic/dyadic usage (but this is far from fully fleshed out).
56
+ This means there are meaningful classnames so hover states can
57
+ have popups etc.</p>
58
+
59
+ <p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
60
+ </body>
61
+ </html>
@@ -0,0 +1,183 @@
1
+ /*
2
+ * =====================================================================================
3
+ *
4
+ * Filename: mode/asterisk/asterisk.js
5
+ *
6
+ * Description: CodeMirror mode for Asterisk dialplan
7
+ *
8
+ * Created: 05/17/2012 09:20:25 PM
9
+ * Revision: none
10
+ *
11
+ * Author: Stas Kobzar (stas@modulis.ca),
12
+ * Company: Modulis.ca Inc.
13
+ *
14
+ * =====================================================================================
15
+ */
16
+
17
+ CodeMirror.defineMode("asterisk", function() {
18
+ var atoms = ["exten", "same", "include","ignorepat","switch"],
19
+ dpcmd = ["#include","#exec"],
20
+ apps = [
21
+ "addqueuemember","adsiprog","aelsub","agentlogin","agentmonitoroutgoing","agi",
22
+ "alarmreceiver","amd","answer","authenticate","background","backgrounddetect",
23
+ "bridge","busy","callcompletioncancel","callcompletionrequest","celgenuserevent",
24
+ "changemonitor","chanisavail","channelredirect","chanspy","clearhash","confbridge",
25
+ "congestion","continuewhile","controlplayback","dahdiacceptr2call","dahdibarge",
26
+ "dahdiras","dahdiscan","dahdisendcallreroutingfacility","dahdisendkeypadfacility",
27
+ "datetime","dbdel","dbdeltree","deadagi","dial","dictate","directory","disa",
28
+ "dumpchan","eagi","echo","endwhile","exec","execif","execiftime","exitwhile","extenspy",
29
+ "externalivr","festival","flash","followme","forkcdr","getcpeid","gosub","gosubif",
30
+ "goto","gotoif","gotoiftime","hangup","iax2provision","ices","importvar","incomplete",
31
+ "ivrdemo","jabberjoin","jabberleave","jabbersend","jabbersendgroup","jabberstatus",
32
+ "jack","log","macro","macroexclusive","macroexit","macroif","mailboxexists","meetme",
33
+ "meetmeadmin","meetmechanneladmin","meetmecount","milliwatt","minivmaccmess","minivmdelete",
34
+ "minivmgreet","minivmmwi","minivmnotify","minivmrecord","mixmonitor","monitor","morsecode",
35
+ "mp3player","mset","musiconhold","nbscat","nocdr","noop","odbc","odbc","odbcfinish",
36
+ "originate","ospauth","ospfinish","osplookup","ospnext","page","park","parkandannounce",
37
+ "parkedcall","pausemonitor","pausequeuemember","pickup","pickupchan","playback","playtones",
38
+ "privacymanager","proceeding","progress","queue","queuelog","raiseexception","read","readexten",
39
+ "readfile","receivefax","receivefax","receivefax","record","removequeuemember",
40
+ "resetcdr","retrydial","return","ringing","sayalpha","saycountedadj","saycountednoun",
41
+ "saycountpl","saydigits","saynumber","sayphonetic","sayunixtime","senddtmf","sendfax",
42
+ "sendfax","sendfax","sendimage","sendtext","sendurl","set","setamaflags",
43
+ "setcallerpres","setmusiconhold","sipaddheader","sipdtmfmode","sipremoveheader","skel",
44
+ "slastation","slatrunk","sms","softhangup","speechactivategrammar","speechbackground",
45
+ "speechcreate","speechdeactivategrammar","speechdestroy","speechloadgrammar","speechprocessingsound",
46
+ "speechstart","speechunloadgrammar","stackpop","startmusiconhold","stopmixmonitor","stopmonitor",
47
+ "stopmusiconhold","stopplaytones","system","testclient","testserver","transfer","tryexec",
48
+ "trysystem","unpausemonitor","unpausequeuemember","userevent","verbose","vmauthenticate",
49
+ "vmsayname","voicemail","voicemailmain","wait","waitexten","waitfornoise","waitforring",
50
+ "waitforsilence","waitmusiconhold","waituntil","while","zapateller"
51
+ ];
52
+
53
+ function basicToken(stream,state){
54
+ var cur = '';
55
+ var ch = '';
56
+ ch = stream.next();
57
+ // comment
58
+ if(ch == ";") {
59
+ stream.skipToEnd();
60
+ return "comment";
61
+ }
62
+ // context
63
+ if(ch == '[') {
64
+ stream.skipTo(']');
65
+ stream.eat(']');
66
+ return "header";
67
+ }
68
+ // string
69
+ if(ch == '"') {
70
+ stream.skipTo('"');
71
+ return "string";
72
+ }
73
+ if(ch == "'") {
74
+ stream.skipTo("'");
75
+ return "string-2";
76
+ }
77
+ // dialplan commands
78
+ if(ch == '#') {
79
+ stream.eatWhile(/\w/);
80
+ cur = stream.current();
81
+ if(dpcmd.indexOf(cur) !== -1) {
82
+ stream.skipToEnd();
83
+ return "strong";
84
+ }
85
+ }
86
+ // application args
87
+ if(ch == '$'){
88
+ var ch1 = stream.peek();
89
+ if(ch1 == '{'){
90
+ stream.skipTo('}');
91
+ stream.eat('}');
92
+ return "variable-3";
93
+ }
94
+ }
95
+ // extension
96
+ stream.eatWhile(/\w/);
97
+ cur = stream.current();
98
+ if(atoms.indexOf(cur) !== -1) {
99
+ state.extenStart = true;
100
+ switch(cur) {
101
+ case 'same': state.extenSame = true; break;
102
+ case 'include':
103
+ case 'switch':
104
+ case 'ignorepat':
105
+ state.extenInclude = true;break;
106
+ default:break;
107
+ }
108
+ return "atom";
109
+ }
110
+ }
111
+
112
+ return {
113
+ startState: function() {
114
+ return {
115
+ extenStart: false,
116
+ extenSame: false,
117
+ extenInclude: false,
118
+ extenExten: false,
119
+ extenPriority: false,
120
+ extenApplication: false
121
+ };
122
+ },
123
+ token: function(stream, state) {
124
+
125
+ var cur = '';
126
+ var ch = '';
127
+ if(stream.eatSpace()) return null;
128
+ // extension started
129
+ if(state.extenStart){
130
+ stream.eatWhile(/[^\s]/);
131
+ cur = stream.current();
132
+ if(/^=>?$/.test(cur)){
133
+ state.extenExten = true;
134
+ state.extenStart = false;
135
+ return "strong";
136
+ } else {
137
+ state.extenStart = false;
138
+ stream.skipToEnd();
139
+ return "error";
140
+ }
141
+ } else if(state.extenExten) {
142
+ // set exten and priority
143
+ state.extenExten = false;
144
+ state.extenPriority = true;
145
+ stream.eatWhile(/[^,]/);
146
+ if(state.extenInclude) {
147
+ stream.skipToEnd();
148
+ state.extenPriority = false;
149
+ state.extenInclude = false;
150
+ }
151
+ if(state.extenSame) {
152
+ state.extenPriority = false;
153
+ state.extenSame = false;
154
+ state.extenApplication = true;
155
+ }
156
+ return "tag";
157
+ } else if(state.extenPriority) {
158
+ state.extenPriority = false;
159
+ state.extenApplication = true;
160
+ ch = stream.next(); // get comma
161
+ if(state.extenSame) return null;
162
+ stream.eatWhile(/[^,]/);
163
+ return "number";
164
+ } else if(state.extenApplication) {
165
+ stream.eatWhile(/,/);
166
+ cur = stream.current();
167
+ if(cur === ',') return null;
168
+ stream.eatWhile(/\w/);
169
+ cur = stream.current().toLowerCase();
170
+ state.extenApplication = false;
171
+ if(apps.indexOf(cur) !== -1){
172
+ return "def strong";
173
+ }
174
+ } else{
175
+ return basicToken(stream,state);
176
+ }
177
+
178
+ return null;
179
+ }
180
+ };
181
+ });
182
+
183
+ CodeMirror.defineMIME("text/x-asterisk", "asterisk");
@@ -0,0 +1,142 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>CodeMirror: Asterisk dialplan mode</title>
6
+ <link rel="stylesheet" href="../../lib/codemirror.css">
7
+ <script src="../../lib/codemirror.js"></script>
8
+ <script src="asterisk.js"></script>
9
+ <style>
10
+ .CodeMirror {border: 1px solid #999;}
11
+ .cm-s-default span.cm-arrow { color: red; }
12
+ </style>
13
+ <link rel="stylesheet" href="../../doc/docs.css">
14
+ </head>
15
+ <body>
16
+ <h1>CodeMirror: Asterisk dialplan mode</h1>
17
+ <form><textarea id="code" name="code">
18
+ ; extensions.conf - the Asterisk dial plan
19
+ ;
20
+
21
+ [general]
22
+ ;
23
+ ; If static is set to no, or omitted, then the pbx_config will rewrite
24
+ ; this file when extensions are modified. Remember that all comments
25
+ ; made in the file will be lost when that happens.
26
+ static=yes
27
+
28
+ #include "/etc/asterisk/additional_general.conf
29
+
30
+ [iaxprovider]
31
+ switch => IAX2/user:[key]@myserver/mycontext
32
+
33
+ [dynamic]
34
+ #exec /usr/bin/dynamic-peers.pl
35
+
36
+ [trunkint]
37
+ ;
38
+ ; International long distance through trunk
39
+ ;
40
+ exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
41
+ exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
42
+
43
+ [local]
44
+ ;
45
+ ; Master context for local, toll-free, and iaxtel calls only
46
+ ;
47
+ ignorepat => 9
48
+ include => default
49
+
50
+ [demo]
51
+ include => stdexten
52
+ ;
53
+ ; We start with what to do when a call first comes in.
54
+ ;
55
+ exten => s,1,Wait(1) ; Wait a second, just for fun
56
+ same => n,Answer ; Answer the line
57
+ same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
58
+ same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
59
+ same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
60
+ same => n(instruct),BackGround(demo-instruct) ; Play some instructions
61
+ same => n,WaitExten ; Wait for an extension to be dialed.
62
+
63
+ exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
64
+ exten => 2,n,Goto(s,instruct)
65
+
66
+ exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
67
+ exten => 3,n,Goto(s,restart) ; Start with the congratulations
68
+
69
+ exten => 1000,1,Goto(default,s,1)
70
+ ;
71
+ ; We also create an example user, 1234, who is on the console and has
72
+ ; voicemail, etc.
73
+ ;
74
+ exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
75
+ ; (but skip if channel is not up)
76
+ exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
77
+ exten => 1234,n,Goto(default,s,1) ; exited Voicemail
78
+
79
+ exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
80
+
81
+ exten => 1236,1,Dial(Console/dsp) ; Ring forever
82
+ exten => 1236,n,Voicemail(1234,b) ; Unless busy
83
+
84
+ ;
85
+ ; # for when they're done with the demo
86
+ ;
87
+ exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
88
+ exten => #,n,Hangup ; Hang them up.
89
+
90
+ ;
91
+ ; A timeout and "invalid extension rule"
92
+ ;
93
+ exten => t,1,Goto(#,1) ; If they take too long, give up
94
+ exten => i,1,Playback(invalid) ; "That's not valid, try again"
95
+
96
+ ;
97
+ ; Create an extension, 500, for dialing the
98
+ ; Asterisk demo.
99
+ ;
100
+ exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
101
+ exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
102
+ exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
103
+ exten => 500,n,Goto(s,6) ; Return to the start over message.
104
+
105
+ ;
106
+ ; Create an extension, 600, for evaluating echo latency.
107
+ ;
108
+ exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
109
+ exten => 600,n,Echo ; Do the echo test
110
+ exten => 600,n,Playback(demo-echodone) ; Let them know it's over
111
+ exten => 600,n,Goto(s,6) ; Start over
112
+
113
+ ;
114
+ ; You can use the Macro Page to intercom a individual user
115
+ exten => 76245,1,Macro(page,SIP/Grandstream1)
116
+ ; or if your peernames are the same as extensions
117
+ exten => _7XXX,1,Macro(page,SIP/${EXTEN})
118
+ ;
119
+ ;
120
+ ; System Wide Page at extension 7999
121
+ ;
122
+ exten => 7999,1,Set(TIMEOUT(absolute)=60)
123
+ exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
124
+
125
+ ; Give voicemail at extension 8500
126
+ ;
127
+ exten => 8500,1,VoicemailMain
128
+ exten => 8500,n,Goto(s,6)
129
+
130
+ </textarea></form>
131
+ <script>
132
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
133
+ mode: "text/x-asterisk",
134
+ matchBrackets: true,
135
+ lineNumber: true
136
+ });
137
+ </script>
138
+
139
+ <p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
140
+
141
+ </body>
142
+ </html>