Implemented automatic language detection. * Closes #15.
h3rald h3rald@h3rald.com
Sat, 21 Mar 2015 10:32:27 +0100
4 files changed,
44 insertions(+),
5 deletions(-)
M
app/js/components.js
→
app/js/components.js
@@ -12,11 +12,40 @@ if (!isInitialized) {
var editor = ace.edit(e); obj.editor = editor; e.style.position = "relative"; + editor.updateMode = function(filename) { + var self = this; + var ext = ""; + try { + ext = filename.match(/\.(.+)$/)[1]; + } catch(e) { + ext = ""; + } + switch (ext){ + case 'js': + obj.mode = "javascript"; + break; + case 'css': + obj.mode = "css"; + break; + case 'html': + obj.mode = "html"; + break; + case 'json': + obj.mode = "json"; + break; + case 'md': + obj.mode = "markdown"; + break; + default: + obj.mode = "text"; + } + self.getSession().setMode("ace/mode/"+obj.mode); + }; editor.setOptions({ maxLines: Infinity }); editor.setReadOnly(obj.readOnly); editor.setShowPrintMargin(false); editor.setTheme("ace/theme/github"); - editor.getSession().setMode("ace/mode/"+obj.mode); + editor.updateMode(obj.id()); editor.getSession().setUseWrapMode(true); editor.getSession().setTabSize(2); }@@ -29,6 +58,12 @@ * - content The content of the editor
*/ app.editor.view = function(obj) { return m(".editor.panel.panal-default", {config: app.editor.config(obj)}, obj.content); + }; + +}());ontent); + }; + +}());}, obj.content); }; }());
M
app/js/modules/info.js
→
app/js/modules/info.js
@@ -17,10 +17,8 @@ m("dt", "Version"),
m("dd", info.version), m("dt", "Size"), m("dd", info.size), - m("dt", "Loaded directory"), + m("dt", "Mounted directory"), m("dd", info.directory), - m("dt", "Mirroring"), - m("dd", info.mirror), m("dt", "Read-only"), m("dd", info.read_only), m("dt", "Total Documents"),@@ -36,6 +34,12 @@ );
var v = m(".row", [ m(".col-md-6", [u.panel({title: "Datastore Information", content: infolist})]), m(".col-md-6", [u.panel({title: "Tags", content: taglist})]) + ]); + return v; + }; + u.layout(app.info); + +}());nt: taglist})]) ]); return v; };