From 20afb23a5f5ae1340fa00b60ea04089bdc47a908 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 18 Aug 2011 16:27:04 +0800 Subject: [PATCH] Embed layout_parts in layout and correct typo --- app/controllers/admin/purchases_controller.rb | 4 ++-- app/models/design/layout.rb | 2 +- app/models/design/layout_part.rb | 2 +- lib/parser.rb | 4 ---- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb index 82b6a92b0..7ef2907e3 100644 --- a/app/controllers/admin/purchases_controller.rb +++ b/app/controllers/admin/purchases_controller.rb @@ -34,7 +34,6 @@ class Admin::PurchasesController < ApplicationController temp_file.write response.body temp_file.rewind zip_name = response['content-disposition'].split('filename=')[1].gsub(/[\\\"]|.zip/, '') rescue '' - debugger unzip_design(temp_file, zip_name) temp_file.close temp_file.unlink @@ -61,11 +60,12 @@ class Admin::PurchasesController < ApplicationController temp = File.new(dir + '/' + title, 'w+') temp.write orig_zip.read(zip_name + '/' + title) design.layout.file = temp + design.layout.to_save = true title = design.structure_css_filename temp = File.new(dir + '/' + title, 'w+') temp.write orig_zip.read(zip_name + '/' + title) - design.layout.file = temp + design.structure_css = temp ['themes', 'javascripts', 'images'].each do |type| eval("design.#{type}").each do |object| diff --git a/app/models/design/layout.rb b/app/models/design/layout.rb index 0502e7610..10b4b692f 100644 --- a/app/models/design/layout.rb +++ b/app/models/design/layout.rb @@ -3,7 +3,7 @@ class Layout < DesignFile embedded_in :design attr_reader :content - has_many :layout_parts + embeds_many :layout_parts def content self.file.read diff --git a/app/models/design/layout_part.rb b/app/models/design/layout_part.rb index 49baf9434..c0d8c09aa 100644 --- a/app/models/design/layout_part.rb +++ b/app/models/design/layout_part.rb @@ -9,6 +9,6 @@ class LayoutPart field :class_tag field :content - belongs_to :layout + embedded_in :layout end diff --git a/lib/parser.rb b/lib/parser.rb index 7812d551c..b9cfc2e79 100644 --- a/lib/parser.rb +++ b/lib/parser.rb @@ -230,12 +230,8 @@ module Parser def parser_layout_layout_part(layout ) Radius::Context.new do |c| c.define_tag 'javascripts' do |tag| - contents = tag.expand - contents.to_s end c.define_tag 'stylesheets' do |tag| - contents = tag.expand - contents.to_s end c.define_tag 'layout_part' do |tag| data={}