mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
set mode correctly for ace editor [#93:closed]
This commit is contained in:
parent
fe9b051c87
commit
781e85f908
2 changed files with 18 additions and 5 deletions
|
@ -110,6 +110,17 @@ end
|
||||||
get %r{\/site_files\/text_editor\/(.+)} do
|
get %r{\/site_files\/text_editor\/(.+)} do
|
||||||
require_login
|
require_login
|
||||||
@filename = params[:captures].first
|
@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
|
begin
|
||||||
@file_data = current_site.get_file @filename
|
@file_data = current_site.get_file @filename
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
|
@ -148,4 +159,4 @@ end
|
||||||
|
|
||||||
get '/site_files/mount_info' do
|
get '/site_files/mount_info' do
|
||||||
erb :'site_files/mount_info'
|
erb :'site_files/mount_info'
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
html {
|
html {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
}
|
}
|
||||||
#editor {
|
#editor {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
@ -133,14 +133,14 @@
|
||||||
$('#editorUpdates').fadeOut(); //.addClass('hidden');
|
$('#editorUpdates').fadeOut(); //.addClass('hidden');
|
||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$('#saveButton').tooltip('show')
|
$('#saveButton').tooltip('show')
|
||||||
$('#editorUpdates span').text(response)
|
$('#editorUpdates span').text(response)
|
||||||
}
|
}
|
||||||
$('#editorUpdates').fadeIn()
|
$('#editorUpdates').fadeIn()
|
||||||
$('#editorUpdates').removeClass('hidden')
|
$('#editorUpdates').removeClass('hidden')
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,9 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
editor = ace.edit("editor")
|
editor = ace.edit("editor")
|
||||||
setTheme()
|
setTheme()
|
||||||
editor.getSession().setMode("ace/mode/html")
|
<% if @ace_mode %>
|
||||||
|
editor.getSession().setMode("ace/mode/<%= @ace_mode %>")
|
||||||
|
<% end %>
|
||||||
editor.getSession().setTabSize(2)
|
editor.getSession().setTabSize(2)
|
||||||
editor.getSession().setUseWrapMode(true)
|
editor.getSession().setUseWrapMode(true)
|
||||||
editor.setFontSize(14)
|
editor.setFontSize(14)
|
||||||
|
|
Loading…
Add table
Reference in a new issue