mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 17:52:39 +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
|
||||||
|
|
|
@ -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