set mode correctly for ace editor [#93:closed]

This commit is contained in:
Kyle Drake 2015-02-25 21:10:46 -08:00
parent fe9b051c87
commit 781e85f908
2 changed files with 18 additions and 5 deletions

View file

@ -110,6 +110,17 @@ end
get %r{\/site_files\/text_editor\/(.+)} do
require_login
@filename = params[:captures].first
extname = File.extname @filename
@ace_mode = case extname
when /htm|html/ then 'html'
when /js/ then 'javascript'
when /md/ then 'markdown'
when /css/ then 'css'
else
nil
end
begin
@file_data = current_site.get_file @filename
rescue Errno::ENOENT
@ -148,4 +159,4 @@ end
get '/site_files/mount_info' do
erb :'site_files/mount_info'
end
end

View file

@ -2,7 +2,7 @@
html {
overflow-y: hidden;
}
#editor {
#editor {
position: absolute;
top: 0;
right: 0;
@ -133,14 +133,14 @@
$('#editorUpdates').fadeOut(); //.addClass('hidden');
}, 2000)
}
} else {
$('#saveButton').tooltip('show')
$('#editorUpdates span').text(response)
}
$('#editorUpdates').fadeIn()
$('#editorUpdates').removeClass('hidden')
}
})
}
@ -150,7 +150,9 @@
$(document).ready(function() {
editor = ace.edit("editor")
setTheme()
editor.getSession().setMode("ace/mode/html")
<% if @ace_mode %>
editor.getSession().setMode("ace/mode/<%= @ace_mode %>")
<% end %>
editor.getSession().setTabSize(2)
editor.getSession().setUseWrapMode(true)
editor.setFontSize(14)