finishing saving edited file online and redo dev.rake modification
This commit is contained in:
parent
9eb80d7424
commit
1839269581
|
@ -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| %>
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace :dev do
|
|||
Site.create!( :valid_locales => [ 'en', 'zh_tw' ], :in_use_locales => [ 'zh_tw', 'en' ] )
|
||||
|
||||
user = User.new( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :active_roles => ['teacher'])
|
||||
user.user_roles.build(:key => 'teacher', :discipline_en => 'Database', :discipline_zh_tw => '數據庫' )
|
||||
user.user_roles.build(:key => 'teacher', :discipline_en => 'Database', :discipline_zh_tw => '資料庫' )
|
||||
user.save!
|
||||
|
||||
I18nVariable.create!( :document_class => 'language', :key => 'en', :en => 'English', :zh_tw => '英文' )
|
||||
|
@ -50,21 +50,21 @@ namespace :dev do
|
|||
uim_1.save!
|
||||
|
||||
|
||||
layout = Layout.create!( :name => 'root', :description => 'root', :content => File.open("#{RAILS_ROOT}/lib/template/root.layout").read )
|
||||
layout.layout_parts.create!( :name => 'header', :content => File.open("#{RAILS_ROOT}/lib/template/nav.snippet").read )
|
||||
layout = Layout.create!( :name => 'root', :description => 'root', :content => File.open("#{Rails.root}/lib/template/root.layout").read )
|
||||
layout.layout_parts.create!( :name => 'header', :content => File.open("#{Rails.root}/lib/template/nav.snippet").read )
|
||||
layout.layout_parts.create!( :name => 'main_content', :editable => true )
|
||||
layout.layout_parts.create!( :name => 'footer', :content => File.open("#{RAILS_ROOT}/lib/template/footer.snippet").read )
|
||||
layout.layout_parts.create!( :name => 'footer', :content => File.open("#{Rails.root}/lib/template/footer.snippet").read )
|
||||
|
||||
home = Page.create!( :i18n_variable_id => var_10.id, :layout_id => layout.id, :name => 'home', :is_published => true )
|
||||
home.page_parts.create!( :name => 'main_content', :content => File.open("#{RAILS_ROOT}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id )
|
||||
home.page_parts.create!( :name => 'main_content', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id )
|
||||
|
||||
about = Page.create!( :i18n_variable_id => var_11.id, :layout_id => layout.id, :name => 'about', :is_published => true, :parent_id => home.id )
|
||||
about.page_parts.create!( :name => 'main_content', :content => File.open("#{RAILS_ROOT}/lib/template/about.page").read, :kind => 'text', :i18n_variable_id => var_14.id )
|
||||
about.page_parts.create!( :name => 'main_content', :content => File.open("#{Rails.root}/lib/template/about.page").read, :kind => 'text', :i18n_variable_id => var_14.id )
|
||||
|
||||
Link.create!( :i18n_variable_id => var_12.id, :name => 'google', :is_published => true, :parent_id => home.id, :url => 'www.google.com' )
|
||||
|
||||
["nav", "footer"].each do |page_name|
|
||||
Snippet.create!( :name => page_name, :parent_id => home.id, :content => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.snippet").read )
|
||||
Snippet.create!( :name => page_name, :parent_id => home.id, :content => File.open("#{Rails.root}/lib/template/#{page_name}.snippet").read )
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Reference in New Issue