finishing saving edited file online and redo dev.rake modification
This commit is contained in:
1 parent
9eb80d7424
commit
1839269581
4 files changed
+30
-14
No files matched your search
@@ -1,9 +1,9 @@
|
||||
function r_editor(tgetUrl,tpostUrl,tfileid,toption){
|
||||
function r_editor(tgetUrl,tpostUrl,tfilename,toption){
|
||||
if(!toption){ toption =new Array();}
|
||||
if(!toption['width']){toption['width']=400;}
|
||||
if(!toption['height']){toption['height']=300;}
|
||||
var editor = this;
|
||||
editor.fileid = tfileid;
|
||||
editor.filename = tfilename;
|
||||
editor.getUrl = tgetUrl;
|
||||
editor.postUrl = tpostUrl;
|
||||
editor.width = toption['width'];
|
||||
@@ -23,12 +23,11 @@ function r_editor(tgetUrl,tpostUrl,tfileid,toption){
|
||||
};
|
||||
editor.reload = function(){
|
||||
$.get(editor.getUrl,function(data){
|
||||
alert("reload!");
|
||||
html.children("textarea").text(data);
|
||||
});
|
||||
};
|
||||
editor.send = function(){
|
||||
$.post(editor.postUrl,{fileid:editor.fileid,context:html.text()});
|
||||
$.post(editor.postUrl,{filename:editor.filename,context:html.children("textarea").val(),authenticity_token:$('meta[name=csrf-token]').attr('content')});
|
||||
};
|
||||
editor.destroy = function(){
|
||||
html.remove();
|
||||
@@ -36,7 +35,7 @@ function r_editor(tgetUrl,tpostUrl,tfileid,toption){
|
||||
}
|
||||
|
||||
$(".r_edit").live("click",function(){
|
||||
new_editor = new r_editor($(this).attr("path"),"edit_file",$(this).attr("fileid"));
|
||||
new_editor = new r_editor($(this).attr("path"),"edit_file",$(this).attr("filename"));
|
||||
$(this).after(new_editor.init());
|
||||
});
|
||||
|
||||
|
||||
@@ -25,7 +25,24 @@ class Admin::DesignsController < ApplicationController
|
||||
|
||||
def edit_file
|
||||
@design = Design.find(params[:id])
|
||||
# debugger
|
||||
filename = params[:filename]
|
||||
files = @design.stylesheets + @design.javascripts + @design.images
|
||||
file_to_removed = files.find{ |obj|
|
||||
obj.file_filename == filename
|
||||
}
|
||||
type = file_to_removed._type
|
||||
Dir.mktmpdir('design_temp'){ |dir|
|
||||
temp_file = File.new(dir+'/'+filename,'w+')
|
||||
temp_file.write params[:context]
|
||||
replace_target = eval("@design.#{type.downcase.pluralize}")
|
||||
a = replace_target.build(:file => temp_file,:to_save=>true)
|
||||
debugger
|
||||
file_to_removed.destroy
|
||||
@design.save
|
||||
debugger
|
||||
temp_file.close
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<% li_class += 'r_destroy ' if item_destroy %>
|
||||
<% li_class += 'r_snapshot ' if item_snapshot %>
|
||||
<% li_class += 'r_edit ' if item_editable %>
|
||||
<li class="<%= li_class %>" <%= "path='#{t.file.url}' fileid='#{t._id}'" if (item_snapshot || item_editable) %> >
|
||||
<li class="<%= li_class %>" <%= "path='#{t.file.url}' filename='#{t.file_filename}'" if (item_snapshot || item_editable) %> >
|
||||
<%= t.file_filename %>
|
||||
<% if item_destroy %>
|
||||
<%=fields_for "design["+fieldname_p+"][]",t,:index=>nil do |f| %>
|
||||
|
||||
Reference in new issue
Block a user