-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgistify.js
712 lines (607 loc) · 27.1 KB
/
gistify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
/*
Gistify by Destan Sarpkaya - April 2013
Visit following link for docs: https://github.com/dedeler/gistify#readme
Version: 0.1.0 - alpha
LICENSE
-------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
;(function ($, window, document) {
'use strict';
var aceLibraryUrl = 'https://raw.github.com/ajaxorg/ace-builds/master/src-min-noconflict/ace.js';
var cssUrl = 'gistify.css';
// var aceLibraryModelistUrl = 'https://raw.github.com/ajaxorg/ace/bc745dc90875152b8c82d283ad0e0361ad5ad27c/lib/ace/ext/modelist.js';
var gistApiUrl = 'https://api.github.com/gists';
var aceIsAvailable = false;
var modelist;//ace extension to decide highlight mode by file name
var loadingHtml = '<div class="gistify-loading"><img src="https://a248.e.akamai.net/assets.github.com/images/spinners/octocat-spinner-64.gif" alt="' + localize('Yükleniyor...') + '"></div>';
var modeSelectHtml = '<select class="gistify-mode-select" size="1"><option value="abap">ABAP</option><option value="asciidoc">AsciiDoc</option><option value="c9search">C9Search</option><option value="coffee">CoffeeScript</option><option value="coldfusion">ColdFusion</option><option value="csharp">C#</option><option value="css">CSS</option><option value="curly">Curly</option><option value="dart">Dart</option><option value="diff">Diff</option><option value="dot">Dot</option><option value="ftl">FreeMarker</option><option value="glsl">Glsl</option><option value="golang">Go</option><option value="groovy">Groovy</option><option value="haxe">haXe</option><option value="haml">HAML</option><option value="html">HTML</option><option value="c_cpp">C/C++</option><option value="clojure">Clojure</option><option value="jade">Jade</option><option value="java">Java</option><option value="jsp">JSP</option><option value="javascript">JavaScript</option><option value="json">JSON</option><option value="jsx">JSX</option><option value="latex">LaTeX</option><option value="less">LESS</option><option value="lisp">Lisp</option><option value="scheme">Scheme</option><option value="liquid">Liquid</option><option value="livescript">LiveScript</option><option value="logiql">LogiQL</option><option value="lua">Lua</option><option value="luapage">LuaPage</option><option value="lucene">Lucene</option><option value="lsl">LSL</option><option value="makefile">Makefile</option><option value="markdown">Markdown</option><option value="mushcode">TinyMUSH</option><option value="objectivec">Objective-C</option><option value="ocaml">OCaml</option><option value="pascal">Pascal</option><option value="perl">Perl</option><option value="pgsql">pgSQL</option><option value="php">PHP</option><option value="powershell">Powershell</option><option value="python">Python</option><option value="r">R</option><option value="rdoc">RDoc</option><option value="rhtml">RHTML</option><option value="ruby">Ruby</option><option value="scad">OpenSCAD</option><option value="scala">Scala</option><option value="scss">SCSS</option><option value="sass">SASS</option><option value="sh">SH</option><option value="sql">SQL</option><option value="stylus">Stylus</option><option value="svg">SVG</option><option value="tcl">Tcl</option><option value="tex">Tex</option><option value="text" selected>Text</option><option value="textile">Textile</option><option value="tmsnippet">tmSnippet</option><option value="toml">toml</option><option value="typescript">Typescript</option><option value="vbscript">VBScript</option><option value="velocity">Velocity</option><option value="xml">XML</option><option value="xquery">XQuery</option><option value="yaml">YAML</option></select>';
var metaForCreate = '\
<div class="gistify-meta gistify-meta-create">\
<div class="gistify-filename-input-container">\
<a href="#" class="mini-icon mini-icon-remove-close gistify-remove-button"></a>\
<input class="gistify-filename" type="text" placeholder="'+ localize('Dosyayı adlandırın...') +'">\
</div>\
<div class="gistify-filename-select-container">' + modeSelectHtml + '</div>\
</div>';
var metaForShow = '\
<div class="gistify-meta gistify-meta-show">\
<span class="mini-icon mini-icon-show mini-icon-gist"></span>\
<span class="gistify-filename"></span>\
<div class="gistify-file-actions">\
<span class="gistify-language"></span>\
<ul class="gistify-button-group">\
<li><a href="" target="_blank" class="gistify-permalink" original-title="Permalink"><span class="mini-icon mini-icon-show mini-icon-link"></span></a></li>\
<li><a href="" target="_blank" class="gistify-raw-url" original-title="View Raw"><span class="mini-icon mini-icon-show mini-icon-code"></span></a></li>\
</ul>\
</div>\
</div>';
//css injection
$(function() {
$('<link id="gistify-style" rel="stylesheet" type="text/css"></link>').appendTo('head');
$('#gistify-style').attr('href', cssUrl);
});
// Create the defaults once
var pluginName = "gistify";
var defaults = {
mode: 'create', // first run: 'create' | 'show' | 'edit' # not first run: 'save' | 'get'
description: true,
saveButton: false,//only meaningful when mode:create
height: '300px',
width: '400px',
callback: undefined //function meaningful when mode:get
};
//Gistify exception
function GistifyError(message) {
this.name = "GistifyError";
this.message = (message || "Unknown problem");
}
GistifyError.prototype = Error.prototype;
// Plugin constructor
function Plugin(element, options) {
this.element = element;
this.options = $.extend({}, defaults, options);
//show loading
if(options.mode == 'create' || options.mode == 'show' || options.mode == 'edit'){
var loadingContainerWidth = $(element).empty().append(loadingHtml).find('.gistify-loading').height(this.options.height).width(this.options.width).width();
$(element).find('.gistify-loading>img').css('left', loadingContainerWidth / 2 - 64 + 'px');
}
if(this.options.firstTime == false){
if(this.options.mode == 'save'){
this.save(element, this.options);
}
else if(this.options.mode == 'get'){
this.get(element, this.options);
}
else if(this.options.mode == 'convertToEdit'){//user enters mode as 'edit' and it is converted to 'convertToEdit' in plugin init
this.edit(element, this.options);
}
else if(this.options.mode == 'appendToForm'){
this.appendToForm(element, this.options);
}
else{
throw new GistifyError('[Invalid argument] When gistify once initialized on a DOM element, in further calls, "options.mode" can be "save", "get", "edit" or "appendToForm" but was "' + this.options.mode + '"');
}
return;
}
var thiz = this;
if(this.options.mode == 'create'){
this.loadAceLibrary(function() {
thiz.create(element, thiz.options);
});
}
else if(this.options.mode == 'show'){
this.loadAceLibrary(function() {
thiz.showOrEdit(element, thiz.options);
});
}
else if(this.options.mode == 'edit'){
this.loadAceLibrary(function() {
thiz.showOrEdit(element, thiz.options);
});
}
else{
throw new GistifyError('[Invalid argument] In first invocation on a DOM element, "options.mode" can be "create"(default), "show" or "edit" but was "' + this.options.mode + '"');
}
}
Plugin.prototype = {
loadAceLibrary: function (callback) {
if(aceIsAvailable){
if (typeof callback == 'function') {
callback();
}
return;
}
if(typeof window.ace === 'object' && typeof window.ace.edit === 'function'){
aceIsAvailable = true;
if (typeof callback == 'function') {
callback();
}
return;
}
$.ajax({
type: "GET",
url: aceLibraryUrl,
dataType: "script",
cache: true,
success: function() {
aceIsAvailable = true;
loadModeList(function() {
modelist = ace.require('ace/ext/modelist');//https://github.com/ajaxorg/ace/pull/1348
if (typeof callback == 'function') {
callback();
}
});
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('ACE library download failed.');
console.error(textStatus);
console.error(errorThrown);
}
});
},//loadAceLibrary
buildDescription: function(container, options) {
if(options.description == false){
return;
}
container.append('\
<div class="gistify-size-determiner">\
<div class="gistify-bubble">\
<div class="gistify-gist-desc-container">\
<textarea class="gistify-gist-desc" placeholder="' + localize('Gist açıklaması...') + '">'
);
$('.gistify-size-determiner').css('width', options.width).css('margin-bottom', '10px');
var descWidth = container.find('.gistify-gist-desc-container').width() - 4;
container.find('textarea')
.width(descWidth)
.css('max-width', descWidth + 'px')
.css('min-width', descWidth + 'px')
.css('resize', 'vertical');
},
buildAnEditor: function(params){
var container = params.container;
var options = params.options;
var divId = params.id;
var structure = '\
<div class="gistify-size-determiner">\
<div class="gistify-bubble">\
<div class="gistify-editor-container">\
' + params.meta + '\
<div class="gistify-ace" id="' + divId + '"></div>\
</div>\
</div>\
</div>\
';
if(container.find('.gistify-footer').length > 0){
//guaranteed to be only 1 footer by implementation, no checks needed
container.find('.gistify-footer').before('<div class="gistify-gap">');
container.find('.gistify-footer').before(structure);
}
else{
container.append(structure);
}
var sizeDeterminer = container.find('.gistify-size-determiner').last();
var bubble = sizeDeterminer.find('.gistify-bubble');
sizeDeterminer.css('height', options.height).css('width', options.width);
var height = bubble.height() - $('.gistify-meta').outerHeight() - 3;//3 for padding
bubble.find('#' + divId).css('height', height + 'px');
var el = sizeDeterminer.find('#' + divId)[0];
var aceEditor = ace.edit(el);
//determine language by extension
var mode = modelist.getModeFromPath(params.fileName);
aceEditor.getSession().setMode(mode.mode);
aceEditor.setValue('');
//set mode text
sizeDeterminer.find('.gistify-language').text(mode.desc);
aceEditor.setTheme("ace/theme/github");
$.data(sizeDeterminer.get()[0], 'gistify-aceEditor', aceEditor);
$.data(sizeDeterminer.get()[0], 'zaa', 13);
return {
aceEditor: aceEditor,
sizeDeterminer: sizeDeterminer
};
},
bindCreateEvents: function(sizeDeterminer, aceEditor){
//mode select change event
sizeDeterminer.find('.gistify-mode-select').change(function() {
aceEditor.getSession().setMode(modelist.modesByName[$(this).val()].mode);
});
//filename input change(keyup) event
sizeDeterminer.find('.gistify-filename-input-container > input').keyup(function() {
var mode = modelist.getModeFromPath($(this).val());
aceEditor.getSession().setMode(mode.mode);
sizeDeterminer.find('.gistify-mode-select').val(mode.name);
if($(this).val().length > 0){
sizeDeterminer.find('.gistify-mode-select').attr('disabled', 'true');
}
else{
sizeDeterminer.find('.gistify-mode-select').removeAttr('disabled');
}
});
//remove button click event
sizeDeterminer.find('.gistify-remove-button').click(function(event){
if(confirm(localize('Bu dosyayı silmek istediğinizden emin misiniz?'))){
sizeDeterminer.remove();
}
event.preventDefault();
});
sizeDeterminer.find('.gistify-filename-input-container > input').trigger('keyup');
},
appendFooter: function(container, options) {
var thiz = this;
//append footer
container.append('<div class="gistify-footer"><button class="gistify-new-btn gistify-btn">' + localize('Yeni dosya ekle'));
container.find('.gistify-footer').css('width', options.width);
var index = container.find('.gistify-editor-container').length + 1;//total gists in this container + 1
//bind footer new button's action
container.find('.gistify-new-btn').click(function() {
var retVal = thiz.buildAnEditor({
container: container,
options: options,
fileName: localize('Yeni dosya'),
id: 'gistifyEmbeddedGist-' + 'new' + '_' + ++index,//don't forget to increase the index, otherwise no ace editor is shown
meta: metaForCreate
});
//put filename into input field
retVal.sizeDeterminer.find('.gistify-filename-input-container > input').val(localize('Yeni dosya'));
thiz.bindCreateEvents(retVal.sizeDeterminer, retVal.aceEditor);
});
//append save button if desired
if(options.saveButton == true){
container.find('.gistify-footer').append('</button><button class="gistify-save-btn">' + localize('Gisti kaydet') + '</button>');
//bind footer save button's action
container.find('.gistify-save-btn').click(function() {
//TODO
});
}
},
create: function (element, options) {
//container is the element to be gistified
var container = $(element).addClass('gistify-container').empty();
this.buildDescription(container, options);
var index = container.find('.gistify-editor-container').length + 1;//total gists in this container + 1
var retVal = this.buildAnEditor({
container: container,
options: options,
fileName: localize('Yeni dosya'),
id: 'gistifyEmbeddedGist-' + 'new' + '_' + index,
meta: metaForCreate
});
var thiz = this;
var sizeDeterminer = retVal.sizeDeterminer;
var aceEditor = retVal.aceEditor;
if(index == 1){
sizeDeterminer.find('.gistify-remove-button').remove();
}
//put filename into input field
sizeDeterminer.find('.gistify-filename-input-container > input').val(localize('Yeni dosya'));
this.bindCreateEvents(sizeDeterminer, aceEditor);
this.appendFooter(container, options);
},
showOrEdit: function (element, options) {
var thiz = this;
jQuery.getJSON(gistApiUrl + '/' + options.gistId , function(data) {
//container is the element to be gistified
var container = $(element).addClass('gistify-container').empty();
thiz.buildDescription(container, options);
var index = 0;
for (var fileName in data.files) {
if (data.files.hasOwnProperty(fileName)) {
var divId = 'gistifyEmbeddedGist-' + options.gistId + '_' + index++;
var retVal = thiz.buildAnEditor({
container: container,
options: options,
fileName: fileName,
id: divId,
meta: metaForShow
});
var sizeDeterminer = retVal.sizeDeterminer;
var aceEditor = retVal.aceEditor;
sizeDeterminer.find('.gistify-filename').text(fileName);
var file = data.files[fileName];
sizeDeterminer.find('.gistify-raw-url').attr('href', file.raw_url);
var permalink = data.html_url + '#file-' + fileName.replace('.', '-');
permalink = permalink.toLowerCase();
sizeDeterminer.find('.gistify-permalink').attr('href', permalink);
aceEditor.setReadOnly(true);
aceEditor.setValue(file.content);
aceEditor.clearSelection();//by default all content comes as selected, don't know why
container.append('<div class="gistify-gap">');
}
}
if(options.mode == 'edit'){
thiz.edit(element, options);
}
container.find('.gistify-gap').last().remove();
return;
});
},
edit: function(element, options) {
var container = $(element);
var thiz = this;
$(element).find('.gistify-ace').each(function(index, domElement) {
var aceEditor = $.data($(domElement).closest('.gistify-size-determiner')[0], 'gistify-aceEditor');
aceEditor.setReadOnly(false);
var fileName = $(domElement).prev('.gistify-meta').find('.gistify-filename').text();
$(domElement).prev('.gistify-meta').replaceWith(metaForCreate);
var sizeDeterminer = $(domElement).closest('.gistify-size-determiner');
//put filename into input field
sizeDeterminer.find('.gistify-filename-input-container > input').val(fileName);
thiz.bindCreateEvents(sizeDeterminer, aceEditor);
});
this.appendFooter(container, options);
},
get: function(element, options) {
var files = {};
var array = $(element).find('.gistify-ace').toArray();
for(var i in array){
var item = array[i];
var $item = $(item);
var file = {};
var sizeDeterminer = $item.closest('.gistify-size-determiner');
var aceEditor = $.data(sizeDeterminer[0], 'gistify-aceEditor');
file.content = aceEditor.getValue();
var fileName = sizeDeterminer.find('.gistify-filename').val();
fileName = fileName.length ? fileName : localize('Yeni dosya ' + i);
files[fileName] = file;
}
var retVal = {
'description': $(element).find('.gistify-gist-desc').val(),
'public': true,
'files': files
};
if(typeof options.callback == 'function'){
options.callback(retVal);
}
},
save: function(element, options, success, error) {
var thiz = this;
$.ajax({
type: 'POST',
url: gistApiUrl,
data: JSON.stringify(this.get(element, options)),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data, textStatus, jqXHR) {
var id = data.id;
$(element).empty();
var opt = $.extend({}, defaults, {gistId: id});
thiz.showOrEdit(element, opt);
if(typeof success == 'function'){
success(data, textStatus, jqXHR);
}
},
error: function(jqXHR, textStatus, errorThrown) {
if(typeof error == 'function'){
error(jqXHR, textStatus, errorThrown);
}
}
});
},
appendToForm: function(element, options) {
debugger;
//TODO
var inputName = options.inputName || 'gistify';
var inputId = options.inputId || 'gistify';
if(typeof options.formSelector != 'string'){
throw new GistifyError('[Invalid argument] When using appendToForm mode, you must provide a string for options.formSelector .');
}
this.get(element, {callback: function(gistifyJson) {
debugger;
if($(options.formSelector).find('#' + inputId).length == 0){//create hidden input
$(options.formSelector)
.append('<input type="hidden" id="' + inputId + '" name="' + inputName + '">')
.find('#' + inputId).val(JSON.stringify(gistifyJson));
}
else{//update hidden input
$(options.formSelector)
.find('#' + inputId).val(JSON.stringify(gistifyJson));
}
}});
}
};//Plugin.prototype
// A really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[pluginName] = function (options, callback) {
//process options object
if(typeof options == 'string'){
if(options == 'edit'){
options = {
mode: 'convertToEdit'
};
}
else if(options == 'save'){
options = {
mode: 'save'
};
}
else if(options == 'get'){
options = {
mode: 'get',
callback: callback
};
}
else if(options == 'aceLibraryUrl'){
if(typeof callback == 'string'){
console.log("[Gistify] Ace library url changed from " + aceLibraryUrl + ' to ' + callback);
aceLibraryUrl = callback;
}
else{
throw new GistifyError('[Invalid argument] When using "aceLibraryUrl" to change Ace libarary url you must provide a url as 2nd argument.');
}
return;//return here without affecting firstRun flag.
}
else if(options == 'cssUrl'){
if(typeof callback == 'string'){
console.log("[Gistify] Gistify css url changed from " + cssUrl + ' to ' + callback);
cssUrl = callback;
}
else{
throw new GistifyError('[Invalid argument] When using "cssUrl" to change Gistify css url you must provide a url as 2nd argument.');
}
return;//return here without affecting firstRun flag.
}
}
else{
//if data-gist-id is present assume mode:show or edit
var gistId = $(this).data('gistid');
if(typeof options != 'object'){
options = {};
}
if(gistId){
options.mode = options.mode ? options.mode : 'show';
options.gistId = gistId;
}
}
return this.each(function () {
//whether the plugin invoked for first time or not
var firstTime = $.data(this, "plugin_" + pluginName) == undefined;
options = $.extend({}, {firstTime:firstTime}, options);//so that options never can be undefined
$.data(this, "plugin_" + pluginName, new Plugin(this, options));
});
};
/**
* Placeholder localization function, to be implemented in future releases.
*/
function localize(string) {
return string;
}
/** ==============================================================================================
To prevent further network traffic ace editor's modelist plugin is embedded into gistify plugin
Since this function abstracts the loading of modelist plugin,
it can be downloaded from ace's CDN urls if desired in the future
*/
function loadModeList(callback) {
ace.define('ace/ext/modelist', function(require, exports, module) {
"use strict";
var modes = [];
function getModeFromPath(path) {
var mode = modesByName.text;
var fileName = path.split(/[\/\\]/).pop();
for (var i = 0; i < modes.length; i++) {
if (modes[i].supportsFile(fileName)) {
mode = modes[i];
break;
}
}
return mode;
}
var Mode = function(name, desc, extensions) {
this.name = name;
this.desc = desc;
this.mode = "ace/mode/" + name;
if (/\^/.test(extensions)) {
var re = extensions.replace(/\|(\^)?/g, function(a, b){
return "$|" + (b ? "^" : "^.*\\.");
}) + "$";
} else {
var re = "^.*\\.(" + extensions + ")$";
}
this.extRe = new RegExp(re, "gi");
};
Mode.prototype.supportsFile = function(filename) {
return filename.match(this.extRe);
};
/**
* An object containing properties that map to rendering modes. Each property
* contains an array where element 0 is the name of the mode and element 1
* contains information about the file extensions where this mode is
* applicable.
*/
var modesByName = {
abap: ["ABAP" , "abap"],
asciidoc: ["AsciiDoc" , "asciidoc"],
c9search: ["C9Search" , "c9search_results"],
coffee: ["CoffeeScript" , "^Cakefile|coffee|cf|cson"],
coldfusion: ["ColdFusion" , "cfm"],
csharp: ["C#" , "cs"],
css: ["CSS" , "css"],
curly: ["Curly" , "curly"],
dart: ["Dart" , "dart"],
diff: ["Diff" , "diff|patch"],
dot: ["Dot" , "dot"],
ftl: ["FreeMarker" , "ftl"],
glsl: ["Glsl" , "glsl|frag|vert"],
golang: ["Go" , "go"],
groovy: ["Groovy" , "groovy"],
haxe: ["haXe" , "hx"],
haml: ["HAML" , "haml"],
html: ["HTML" , "htm|html|xhtml"],
c_cpp: ["C/C++" , "c|cc|cpp|cxx|h|hh|hpp"],
clojure: ["Clojure" , "clj"],
jade: ["Jade" , "jade"],
java: ["Java" , "java"],
jsp: ["JSP" , "jsp"],
javascript: ["JavaScript" , "js"],
json: ["JSON" , "json"],
jsx: ["JSX" , "jsx"],
latex: ["LaTeX" , "latex|tex|ltx|bib"],
less: ["LESS" , "less"],
lisp: ["Lisp" , "lisp"],
scheme: ["Scheme" , "scm|rkt"],
liquid: ["Liquid" , "liquid"],
livescript: ["LiveScript" , "ls"],
logiql: ["LogiQL" , "logic|lql"],
lua: ["Lua" , "lua"],
luapage: ["LuaPage" , "lp"], // http://keplerproject.github.com/cgilua/manual.html#templates
lucene: ["Lucene" , "lucene"],
lsl: ["LSL" , "lsl"],
makefile: ["Makefile" , "^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"],
markdown: ["Markdown" , "md|markdown"],
mushcode: ["TinyMUSH" , "mc|mush"],
objectivec: ["Objective-C" , "m"],
ocaml: ["OCaml" , "ml|mli"],
pascal: ["Pascal" , "pas|p"],
perl: ["Perl" , "pl|pm"],
pgsql: ["pgSQL" , "pgsql"],
php: ["PHP" , "php|phtml"],
powershell: ["Powershell" , "ps1"],
python: ["Python" , "py"],
r: ["R" , "r"],
rdoc: ["RDoc" , "Rd"],
rhtml: ["RHTML" , "Rhtml"],
ruby: ["Ruby" , "ru|gemspec|rake|rb"],
scad: ["OpenSCAD" , "scad"],
scala: ["Scala" , "scala"],
scss: ["SCSS" , "scss"],
sass: ["SASS" , "sass"],
sh: ["SH" , "sh|bash|bat"],
sql: ["SQL" , "sql"],
stylus: ["Stylus" , "styl|stylus"],
svg: ["SVG" , "svg"],
tcl: ["Tcl" , "tcl"],
tex: ["Tex" , "tex"],
text: ["Text" , "txt"],
textile: ["Textile" , "textile"],
tmsnippet: ["tmSnippet" , "tmSnippet"],
toml: ["toml" , "toml"],
typescript: ["Typescript" , "typescript|ts|str"],
vbscript: ["VBScript" , "vbs"],
xml: ["XML" , "xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
xquery: ["XQuery" , "xq"],
yaml: ["YAML" , "yaml"]
};
for (var name in modesByName) {
var mode = modesByName[name];
mode = new Mode(name, mode[0], mode[1]);
modesByName[name] = mode;
modes.push(mode);
}
module.exports = {
getModeFromPath: getModeFromPath,
modes: modes,
modesByName: modesByName
};
});
callback();
}//end of loadModeList
})(jQuery, window, document);