From b6db304579b2bff3151a40de8e1e0f64167ff62e Mon Sep 17 00:00:00 2001 From: Kaito Date: Fri, 29 Jul 2011 17:49:10 +0800 Subject: [PATCH] add nokogiri into Gemfile and fixing dup bug again... --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/assets/javascripts/design_temp.js | 2 +- app/controllers/admin/designs_controller.rb | 7 +++++++ app/models/design.rb | 6 ++++-- config/routes.rb | 1 + 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index e6ca1d1f..441a780c 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,8 @@ gem 'ckeditor' gem 'devise' gem 'mini_magick' +gem 'nokogiri' + gem 'mongoid' gem 'rake', '>=0.9.2' diff --git a/Gemfile.lock b/Gemfile.lock index ab5e7389..8cab2db4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,6 +77,7 @@ GEM mongo (~> 1.3) tzinfo (~> 0.3.22) multi_json (1.0.3) + nokogiri (1.5.0) orm_adapter (0.0.5) polyglot (0.3.1) rack (1.3.0) @@ -159,6 +160,7 @@ DEPENDENCIES jquery-rails (>= 1.0.3) mini_magick mongoid + nokogiri rails (>= 3.1.0.rc4) rake (>= 0.9.2) rcov diff --git a/app/assets/javascripts/design_temp.js b/app/assets/javascripts/design_temp.js index 00d751e1..b2aca4b1 100644 --- a/app/assets/javascripts/design_temp.js +++ b/app/assets/javascripts/design_temp.js @@ -15,7 +15,7 @@ function r_editor(tgetUrl,tpostUrl,tfilename,toption){ html = $(code); html.children("textarea").load(editor.getUrl); html.children("input.discard").click(function(){ - editor.reload(); + editor.destroy(); }); html.children("input.send").click(function(){ editor.send(); diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index aa72d82f..1b899ea3 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -23,6 +23,13 @@ class Admin::DesignsController < ApplicationController end end + def apply + @design = Design.find(params[:id]) + #TODO do somehting to validate + debugger + doc = Nokogiri::HTML(@design.layout.file.read) + end + def edit_file @design = Design.find(params[:id]) filename = params[:filename] diff --git a/app/models/design.rb b/app/models/design.rb index 8d0b31fb..5d23e663 100644 --- a/app/models/design.rb +++ b/app/models/design.rb @@ -36,8 +36,10 @@ class Design def files=(attrs) files = eval(attrs.last) attrs[0].each do |a| - if(a[:id]=='' && !a[:file].nil?) - files.build(:file => a[:file], :to_save => true) + if(a[:id]=='' && !a[:file].nil? ) + if(a[:file]!='') + files.build(:file => a[:file], :to_save => true) + end else files.each do |file| if file.id.to_s == a[:id] diff --git a/config/routes.rb b/config/routes.rb index 04735928..53123d7f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,6 +47,7 @@ PrototypeR4::Application.routes.draw do resources :designs do member do post 'edit_file' => 'designs#edit_file' + get 'apply' get 'delete' end end