bee_api 0.0.5

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 (108) hide show
  1. data/bin/bee_api +84 -0
  2. data/lib/mdpreview.rb +80 -0
  3. data/lib/mdpreview/translator.rb +60 -0
  4. data/lib/mdpreview/version.rb +3 -0
  5. data/test/mdptest.rb +100 -0
  6. data/vendor/HISTORY.md +237 -0
  7. data/vendor/Jakefile.js +316 -0
  8. data/vendor/LICENSE +176 -0
  9. data/vendor/NOTICE +17 -0
  10. data/vendor/README.md +102 -0
  11. data/vendor/app/chrome/documentation.txt +12 -0
  12. data/vendor/app/chrome/manifest.json +24 -0
  13. data/vendor/app/web/ajax.js +43 -0
  14. data/vendor/app/web/app.css +292 -0
  15. data/vendor/app/web/app.js +377 -0
  16. data/vendor/app/web/beta/index.html +17 -0
  17. data/vendor/app/web/datapolicy.txt +48 -0
  18. data/vendor/app/web/doc/doc.css +60 -0
  19. data/vendor/app/web/doc/img/actions_menu.png +0 -0
  20. data/vendor/app/web/doc/img/button_actions_menu.png +0 -0
  21. data/vendor/app/web/doc/img/button_dragarea.png +0 -0
  22. data/vendor/app/web/doc/img/jsoneditor.png +0 -0
  23. data/vendor/app/web/doc/img/jsonformatter.png +0 -0
  24. data/vendor/app/web/doc/img/main_menu.png +0 -0
  25. data/vendor/app/web/doc/img/splitter.png +0 -0
  26. data/vendor/app/web/doc/index.html +201 -0
  27. data/vendor/app/web/favicon.ico +0 -0
  28. data/vendor/app/web/fileretriever.css +54 -0
  29. data/vendor/app/web/fileretriever.js +567 -0
  30. data/vendor/app/web/fileretriever.php +120 -0
  31. data/vendor/app/web/googlea47c4a0b36d11021.html +1 -0
  32. data/vendor/app/web/hash.js +133 -0
  33. data/vendor/app/web/img/description.txt +20 -0
  34. data/vendor/app/web/img/header_background.png +0 -0
  35. data/vendor/app/web/img/icon_128.png +0 -0
  36. data/vendor/app/web/img/icon_16.png +0 -0
  37. data/vendor/app/web/img/icon_gray.svg +151 -0
  38. data/vendor/app/web/img/icon_gray_16.svg +150 -0
  39. data/vendor/app/web/img/icon_orange.svg +151 -0
  40. data/vendor/app/web/img/logo.png +0 -0
  41. data/vendor/app/web/img/logo.xcf +0 -0
  42. data/vendor/app/web/img/logo_app.png +0 -0
  43. data/vendor/app/web/img/logo_app.xcf +0 -0
  44. data/vendor/app/web/index.html +191 -0
  45. data/vendor/app/web/notify.js +150 -0
  46. data/vendor/app/web/queryparams.js +71 -0
  47. data/vendor/app/web/robots.txt +0 -0
  48. data/vendor/app/web/splitter.js +179 -0
  49. data/vendor/app/web/test.html +224 -0
  50. data/vendor/component.json +33 -0
  51. data/vendor/docs/api.md +188 -0
  52. data/vendor/docs/usage.md +137 -0
  53. data/vendor/examples/01_basic_usage.html +45 -0
  54. data/vendor/examples/02_viewer.html +38 -0
  55. data/vendor/examples/03_switch_mode.html +98 -0
  56. data/vendor/examples/cur.file +1 -0
  57. data/vendor/examples/jquery.js +2 -0
  58. data/vendor/examples/meta.js +1 -0
  59. data/vendor/examples/requirejs_demo/requirejs_demo.html +19 -0
  60. data/vendor/examples/requirejs_demo/scripts/main.js +25 -0
  61. data/vendor/examples/requirejs_demo/scripts/require.js +35 -0
  62. data/vendor/img/jsoneditor-icons.png +0 -0
  63. data/vendor/jsoneditor-min.css +1 -0
  64. data/vendor/jsoneditor-min.js +34 -0
  65. data/vendor/jsoneditor.css +597 -0
  66. data/vendor/jsoneditor.js +6069 -0
  67. data/vendor/jsoneditor/css/contextmenu.css +219 -0
  68. data/vendor/jsoneditor/css/img/description.txt +13 -0
  69. data/vendor/jsoneditor/css/img/export.sh +16 -0
  70. data/vendor/jsoneditor/css/img/jsoneditor-icons.png +0 -0
  71. data/vendor/jsoneditor/css/img/jsoneditor-icons.svg +861 -0
  72. data/vendor/jsoneditor/css/jsoneditor.css +220 -0
  73. data/vendor/jsoneditor/css/menu.css +81 -0
  74. data/vendor/jsoneditor/css/searchbox.css +73 -0
  75. data/vendor/jsoneditor/js/appendnode.js +211 -0
  76. data/vendor/jsoneditor/js/contextmenu.js +440 -0
  77. data/vendor/jsoneditor/js/header.js +32 -0
  78. data/vendor/jsoneditor/js/highlighter.js +82 -0
  79. data/vendor/jsoneditor/js/history.js +218 -0
  80. data/vendor/jsoneditor/js/jsoneditor.js +206 -0
  81. data/vendor/jsoneditor/js/module.js +50 -0
  82. data/vendor/jsoneditor/js/node.js +2864 -0
  83. data/vendor/jsoneditor/js/searchbox.js +288 -0
  84. data/vendor/jsoneditor/js/texteditor.js +311 -0
  85. data/vendor/jsoneditor/js/treeeditor.js +770 -0
  86. data/vendor/jsoneditor/js/util.js +582 -0
  87. data/vendor/lib/ace/ace.js +11 -0
  88. data/vendor/lib/ace/mode-json.js +1 -0
  89. data/vendor/lib/ace/theme-jsoneditor.js +144 -0
  90. data/vendor/lib/ace/theme-textmate.js +163 -0
  91. data/vendor/lib/ace/worker-json.js +1 -0
  92. data/vendor/lib/jsonlint/README.md +62 -0
  93. data/vendor/lib/jsonlint/jsonlint.js +432 -0
  94. data/vendor/misc/screenshots/actionsmenu_640x400.png +0 -0
  95. data/vendor/misc/screenshots/codeeditor_640x400.png +0 -0
  96. data/vendor/misc/screenshots/description.json +17 -0
  97. data/vendor/misc/screenshots/jsoneditoronline.png +0 -0
  98. data/vendor/misc/screenshots/jsoneditoronline_640x400.png +0 -0
  99. data/vendor/misc/screenshots/search_640x400.png +0 -0
  100. data/vendor/misc/screenshots/small_tile.xcf +0 -0
  101. data/vendor/misc/screenshots/small_tile_440x280.png +0 -0
  102. data/vendor/misc/todo.txt +101 -0
  103. data/vendor/package.json +28 -0
  104. data/vendor/test/couchdbeditor.html +100 -0
  105. data/vendor/test/largefile.json +12605 -0
  106. data/vendor/test/test_ace.html +60 -0
  107. data/vendor/test/test_editable_div.html +449 -0
  108. metadata +154 -0
@@ -0,0 +1,60 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Test Ace</title>
5
+
6
+ <script src="../app/web/lib/ace/ace.js" type="text/javascript" charset="utf-8"></script>
7
+ <script src="../app/web/lib/ace/mode-json.js" type="text/javascript" charset="utf-8"></script>
8
+ <script src="../app/web/lib/ace/theme-textmate.js" type="text/javascript" charset="utf-8"></script>
9
+ <script src="../app/web/lib/ace/theme-jso.js" type="text/javascript" charset="utf-8"></script>
10
+
11
+ <style type="text/css" media="screen">
12
+ html, body {
13
+ width: 100%;
14
+ height: 100%;
15
+ margin: 0;
16
+ padding: 0;
17
+ }
18
+
19
+ #editor {
20
+ border: 1px solid gray;
21
+ width: 50%;
22
+ height: 75%;
23
+ }
24
+ </style>
25
+ </head>
26
+ <body>
27
+
28
+ <h1>Test Ace</h1>
29
+
30
+ <div id="editor"></div>
31
+
32
+ <script>
33
+ var editor = ace.edit('editor');
34
+ editor.setTheme("ace/theme/jso");
35
+ editor.setShowPrintMargin(false);
36
+ editor.setFontSize(13);
37
+ editor.getSession().setMode('ace/mode/json');
38
+ editor.getSession().setUseSoftTabs(true);
39
+ editor.getSession().setUseWrapMode(true);
40
+
41
+ var json = {
42
+ "array": [
43
+ 1,
44
+ 2,
45
+ 3
46
+ ],
47
+ "boolean": true,
48
+ "null": null,
49
+ "number": 123,
50
+ "object": {
51
+ "a": "b",
52
+ "c": "d",
53
+ "e": "f"
54
+ },
55
+ "string": "Hello World"
56
+ };
57
+ editor.setValue(JSON.stringify(json, null, 4), -1);
58
+ </script>
59
+ </body>
60
+ </html>
@@ -0,0 +1,449 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <title>test editable div</title>
6
+
7
+ <!-- http://jsbeautifier.org/ -->
8
+ <script type="text/javascript" src="http://jsbeautifier.org/beautify.js"></script>
9
+ <script type="text/javascript" src="http://jsbeautifier.org/beautify-css.js"></script>
10
+ <script type="text/javascript" src="http://jsbeautifier.org/beautify-html.js"></script>
11
+
12
+ <style type="text/css">
13
+ body {
14
+ font-size: 10pt;
15
+ font-family: verdana, arial, sans-serif;
16
+ }
17
+
18
+ #editor, #traverseText, #regexText {
19
+ width: 200px;
20
+ height: 400px;
21
+ border: 1px solid gray;
22
+ overflow: auto;
23
+ font: 10pt monospace;
24
+ color: #1a1a1a;
25
+ margin: 0;
26
+ }
27
+
28
+ #editor p { /* For IE and Opera */
29
+ margin: 0;
30
+ }
31
+
32
+ td, th {
33
+ text-align: left;
34
+ vertical-align: top;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body>
39
+
40
+ <p style="font-weight: bold;">
41
+ Test file for testing two different methods to extract the inner text (including
42
+ return characters) from and editable div.
43
+ </p>
44
+
45
+ <p>
46
+ <button onclick="test1()">test 1</button>
47
+ <button onclick="test2()">test 2</button>
48
+ <button onclick="test3()">test 3</button>
49
+ <button onclick="test4()">test 4</button>
50
+ <button onclick="test5()">test 5</button>
51
+ <button onclick="test6()">test 6</button>
52
+ <button onclick="test7()">test 7</button>
53
+ (For more testing, just start entering text, deleting text, copying/pasting text, etc...)
54
+ </p>
55
+
56
+ <p>
57
+ <button onclick="test_chrome()">test chrome</button>
58
+ <button onclick="test_firefox()">test firefox</button>
59
+ <button onclick="test_opera()">test opera</button>
60
+ <button onclick="test_ie()">test ie</button>
61
+ (typical content per browser, after some entering text and cutting/pasting within the editable div)
62
+ </p>
63
+
64
+ <table>
65
+ <tr>
66
+ <th>editable div</th>
67
+ <th>traverse</th>
68
+ <th>regex</th>
69
+ <th>innerHTML</th>
70
+ </tr>
71
+ <tr>
72
+ <td><div id="editor" contenteditable="true"></div></td>
73
+ <td><textarea id="traverseText"></textarea></td>
74
+ <td><textarea id="regexText"></textarea></td>
75
+ <td><pre id="innerHTML"></pre></td>
76
+ </tr>
77
+ </table>
78
+
79
+ <script type="text/javascript">
80
+
81
+ function prepareHtmlForEscaping (html) {
82
+ //html = JSONEditor.insertMissingEscapes(html);
83
+ html = html.replace(/<br[^>]*>\s*<div>/g, '<div>');
84
+
85
+ // DIV BR /DIV => \n
86
+ html = html.replace(/<div>\s*(?:<br[^>]*>)?\s*<\/div>/g, '\\n');
87
+
88
+ // strip trailing BR
89
+ html = html.replace(/<br[^>]*>(\s*)$/, '$1');
90
+
91
+ // BR /DIV => /DIV
92
+ html = html.replace(/<br[^>]*>\s*<\/div>/g, '</div>');
93
+
94
+ // place \n before line breaking HTML so typed line breaks get preserved
95
+ html = html.replace(/(<(?:br|div))\b/g, '\\n$1');
96
+
97
+ return html;
98
+ }
99
+
100
+ function stripHTML (html) {
101
+ // remove HTML tags
102
+ // code from nickf, http://stackoverflow.com/a/822464/1262753
103
+ return html.replace(/<(?:.|\n)*?>/gm, '');
104
+ }
105
+
106
+ /**
107
+ * get the inner text of an HTML element using regex expressions
108
+ * @param {Element} element
109
+ * @return {String} innerText
110
+ */
111
+ function getInnerTextUsingRegex (element) {
112
+ var html = prepareHtmlForEscaping(element.innerHTML);
113
+ var json = '"' + html + '"';
114
+ return stripHTML(JSON.parse(json));
115
+ }
116
+
117
+ /**
118
+ * get the inner text of an HTML element (for example a div element)
119
+ * @param {Element} element
120
+ * @return {String} innerText
121
+ */
122
+ function getInnerText_v1 (element, level) {
123
+ if (level == undefined) {
124
+ level = 0;
125
+ }
126
+
127
+ // text node
128
+ if (element.nodeValue) {
129
+ return element.nodeValue;
130
+ }
131
+
132
+ // divs or other HTML elements
133
+ if (element.hasChildNodes()) {
134
+ var childNodes = element.childNodes;
135
+ var innerText = '';
136
+
137
+ for (var i = 0, iMax = childNodes.length; i < iMax; i++) {
138
+ var child = childNodes[i];
139
+
140
+ if (child.nodeName == 'DIV' || child.nodeName == 'P') {
141
+ // check to add a return between #text and <div>
142
+ var prevChild = childNodes[i - 1];
143
+ if (prevChild && prevChild.nodeName == '#text') {
144
+ innerText += '\n';
145
+ }
146
+
147
+ innerText += getInnerText(child, level + 1);
148
+
149
+ // add text after the end of div
150
+ if ((i < iMax - 1) && (innerText[innerText.length-1] != '\n')) {
151
+ innerText += '\n';
152
+ }
153
+ }
154
+ else if (child.nodeName == 'BR') {
155
+ // insert return except when on level 0 and at the last element
156
+ if (level != 0 || i < iMax - 1) {
157
+ innerText += '\n';
158
+ }
159
+ }
160
+ else {
161
+ innerText += getInnerText(child, level + 1);
162
+ }
163
+ }
164
+
165
+ return innerText;
166
+ }
167
+
168
+ // br or unknown
169
+ return '';
170
+ }
171
+
172
+ /**
173
+ * get the inner text of an HTML element (for example a div element)
174
+ * @param {Element} element
175
+ * @return {Object} [buffer]
176
+ */
177
+ function getInnerText_v2 (element, buffer) {
178
+ if (buffer == undefined) {
179
+ buffer = {
180
+ 'text': '',
181
+ 'flush': function () {
182
+ var text = this.text;
183
+ this.text = '';
184
+ return text;
185
+ },
186
+ 'set': function (text) {
187
+ this.text = text;
188
+ },
189
+ 'add': function (text) {
190
+ this.text += text;
191
+ }
192
+ };
193
+ }
194
+
195
+ // text node
196
+ if (element.nodeValue) {
197
+ return buffer.flush() + element.nodeValue;
198
+ }
199
+
200
+ // divs or other HTML elements
201
+ if (element.hasChildNodes()) {
202
+ var childNodes = element.childNodes;
203
+ var innerText = '';
204
+
205
+ for (var i = 0, iMax = childNodes.length; i < iMax; i++) {
206
+ var child = childNodes[i];
207
+
208
+ if (child.nodeName == 'DIV' || child.nodeName == 'P') {
209
+ // check to add a return between non-block elements and
210
+ // a block element
211
+ var prevChild = childNodes[i - 1];
212
+ var prevName = prevChild ? prevChild.nodeName : undefined;
213
+ if (prevName && prevName != 'DIV' && prevName != 'P' && prevName != 'BR') {
214
+ innerText += '\n';
215
+ buffer.flush();
216
+ }
217
+
218
+ innerText += buffer.flush();
219
+
220
+ innerText += getInnerText(child, buffer);
221
+
222
+ buffer.set('\n');
223
+ }
224
+ else if (child.nodeName == 'BR') {
225
+ innerText += buffer.flush();
226
+ buffer.set('\n');
227
+ }
228
+ else {
229
+ innerText += getInnerText(child, buffer);
230
+ }
231
+ }
232
+
233
+ return innerText;
234
+ }
235
+
236
+ // br or unknown
237
+ return '';
238
+ }
239
+
240
+ /**
241
+ * get the inner text of an HTML element (for example a div element)
242
+ * @param {Element} element
243
+ * @param {Object} [buffer]
244
+ * @return {String} innerText
245
+ */
246
+ function getInnerText_v3 (element, buffer) {
247
+ var first = (buffer == undefined);
248
+ if (first) {
249
+ buffer = {
250
+ 'text': '',
251
+ 'flush': function () {
252
+ var text = this.text;
253
+ this.text = '';
254
+ return text;
255
+ },
256
+ 'set': function (text) {
257
+ this.text = text;
258
+ }
259
+ };
260
+ }
261
+
262
+ // text node
263
+ if (element.nodeValue) {
264
+ return buffer.flush() + element.nodeValue;
265
+ }
266
+
267
+ // divs or other HTML elements
268
+ if (element.hasChildNodes()) {
269
+ var childNodes = element.childNodes;
270
+ var innerText = '';
271
+
272
+ for (var i = 0, iMax = childNodes.length; i < iMax; i++) {
273
+ var child = childNodes[i];
274
+
275
+ // console.log(child.nodeName + ' ' + (child.innerHTML || child.nodeValue)); // TODO: cleanup
276
+
277
+ if (child.nodeName == 'DIV' || child.nodeName == 'P') {
278
+ var prevChild = childNodes[i - 1];
279
+ var prevName = prevChild ? prevChild.nodeName : undefined;
280
+ if (prevName && prevName != 'DIV' && prevName != 'P' && prevName != 'BR') {
281
+ innerText += '\n';
282
+ buffer.flush();
283
+ }
284
+ innerText += getInnerText(child, buffer);
285
+ buffer.set('\n');
286
+ }
287
+ else if (child.nodeName == 'BR') {
288
+ innerText += buffer.flush();
289
+ buffer.set('\n');
290
+ }
291
+ else {
292
+ innerText += getInnerText(child, buffer);
293
+ }
294
+ }
295
+
296
+ return innerText;
297
+ }
298
+ else {
299
+ if (element.nodeName == 'P' && getInternetExplorerVersion() != -1) {
300
+ // On Internet Explorer, a P with hasChildNodes()==false is
301
+ // rendered with a new line. Note that a P with
302
+ // hasChildNodes()==true is rendered without a new line
303
+ return buffer.flush();
304
+ }
305
+ }
306
+
307
+ // br or unknown
308
+ return '';
309
+ }
310
+
311
+ var getInternetExplorerVersion = function() {
312
+ var rv = -1; // Return value assumes failure.
313
+ if (navigator.appName == 'Microsoft Internet Explorer')
314
+ {
315
+ var ua = navigator.userAgent;
316
+ var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
317
+ if (re.exec(ua) != null)
318
+ rv = parseFloat( RegExp.$1 );
319
+ }
320
+ return rv;
321
+ };
322
+
323
+ var getInnerText = getInnerText_v3;
324
+
325
+ var editor = document.getElementById('editor');
326
+ var traverseText = document.getElementById('traverseText');
327
+ var regexText = document.getElementById('regexText');
328
+ var innerHTML = document.getElementById('innerHTML');
329
+
330
+ function displayInnerHTML () {
331
+ //function style_html (t) {return t.replace(/</g, '\n<');}
332
+ //*
333
+ if (editor.innerText) {
334
+ innerHTML.innerText = style_html(editor.innerHTML);
335
+ }
336
+ else {
337
+ innerHTML.textContent = style_html(editor.innerHTML);
338
+ }
339
+ //*/
340
+
341
+ traverseText.value = getInnerText(editor);
342
+ regexText.value = getInnerTextUsingRegex(editor);
343
+ }
344
+
345
+ function test1 () {
346
+ editor.innerHTML =
347
+ 'Typical Chrome...' +
348
+ '<div>1</div>' +
349
+ '<div>2</div>' +
350
+ '<div><br class="Apple-interchange-newline"></div>' +
351
+ '<div><br></div>' +
352
+ '<div>3</div>' +
353
+
354
+ 'Typical Firefox...' +
355
+ '<br>1' +
356
+ '<br>2' +
357
+ '<br>' +
358
+ '<br>3' +
359
+ '<br>' +
360
+
361
+ '<p>Typical IE...</p>' +
362
+ '<p>1</p>' +
363
+ '<p>2</p>' +
364
+ '<p>&nbsp;</p>' +
365
+ '<p>&nbsp;</p>' +
366
+ '<p>check the last return</p>';
367
+
368
+ displayInnerHTML();
369
+ }
370
+
371
+ function test2 () {
372
+ editor.innerHTML =
373
+ '<div>' +
374
+ '<div>Some weird nested divs</div>' +
375
+ '<div>' +
376
+ '<div>1</div>' +
377
+ '</div>' +
378
+ '<div><br></div>' +
379
+ '<div><br></div>' +
380
+ '</div>' +
381
+ '2' +
382
+ '</div>' +
383
+ '<div><br><br></div>' +
384
+ '<div>3</div>' +
385
+ '</div>' +
386
+ '<br>' +
387
+ '4' +
388
+ '<br>' +
389
+ '5' +
390
+ '<span>in span</span>' +
391
+ '<div>aaa</div>' +
392
+ 'check the last return' +
393
+ '<br>';
394
+
395
+ displayInnerHTML();
396
+ }
397
+
398
+ function test3 () {
399
+ editor.innerHTML = '<div>check the last return</div>';
400
+ displayInnerHTML();
401
+ }
402
+
403
+ function test4 () {
404
+ editor.innerHTML = '<br>';
405
+ displayInnerHTML();
406
+ }
407
+
408
+ function test5 () {
409
+ editor.innerHTML = '';
410
+ displayInnerHTML();
411
+ }
412
+
413
+ function test6 () {
414
+ editor.innerHTML = 'just text';
415
+ displayInnerHTML();
416
+ }
417
+
418
+ function test7 () {
419
+ editor.innerHTML = '<div>check the last return</div><div><br></div>';
420
+ displayInnerHTML();
421
+ }
422
+
423
+ function test_chrome () {
424
+ editor.innerHTML = 'abc<div><br></div><div>af</div><div><br></div><div><br></div><div>d</div><div>asd</div>';
425
+ displayInnerHTML();
426
+ }
427
+
428
+ function test_firefox () {
429
+ editor.innerHTML = 'abc<br>df<br><br>dsf<br>asdf<br><br>asdf<br>dsf<br>asdf<br><br><br>dsaf<br>';
430
+ displayInnerHTML();
431
+ }
432
+
433
+ function test_opera () {
434
+ editor.innerHTML = '<p>abc</p><p><p>df</p><p><br></p><p>d</p></p><p><p>df</p><p><br></p><p><br></p><p>d</p></p><p>asdf</p>';
435
+ displayInnerHTML();
436
+ }
437
+
438
+ function test_ie () {
439
+ editor.innerHTML = '<p>a</p><p>&nbsp;</p><p>&nbsp;</p><p>as</p><p></p><p></p><p>asdf</p><p></p><p>&nbsp;</p><p>c</p><p>&nbsp;</p><p>d</p><p>&nbsp;</p>';
440
+ displayInnerHTML();
441
+ }
442
+
443
+ editor.oninput = displayInnerHTML;
444
+ editor.onkeyup = displayInnerHTML;
445
+ editor.onblur = displayInnerHTML;
446
+ </script>
447
+
448
+ </body>
449
+ </html>