From 2d6b70b97f8028caf3bdf7f81093f87ba380e854 Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Thu, 27 Dec 2012 15:50:05 +0800 Subject: [PATCH 1/2] regenerate pageparts --- app/models/page.rb | 5 +++-- lib/tasks/migrate.rake | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index eb2ba799..d6563e1a 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -28,7 +28,7 @@ class Page < Item before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? } after_save :generate_html - protected +# protected def create_parts @@ -38,7 +38,8 @@ class Page < Item page_design.layout.layout_parts.each do |layout_part| current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} current_part = self.page_parts.build(:name => layout_part.name) unless current_part - if current_part.name.eql?(menu_part.name) && menu_part + + if menu_part && current_part.name.eql?(menu_part.name) if current_part.new_record? current_part.kind = menu_part.kind current_part.public_r_tag = menu_part.public_r_tag diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index da07e20a..03de17e5 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -312,4 +312,11 @@ namespace :migrate do end end + task :recreate_page_parts => :environment do + Page.all.each do |page| + page.create_parts + page.save + end + end + end From 269e5b033f7c5701fc63fc1228efe12dcef1a83d Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 27 Dec 2012 16:20:40 +0800 Subject: [PATCH 2/2] Fix for page_part and widget back-end --- app/models/page.rb | 10 +++++----- lib/parsers/parser_common.rb | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index d6563e1a..5c1a7b24 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -39,7 +39,7 @@ class Page < Item current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} current_part = self.page_parts.build(:name => layout_part.name) unless current_part - if menu_part && current_part.name.eql?(menu_part.name) + if menu_part && current_part.name.eql?(menu_part.name) if current_part.new_record? current_part.kind = menu_part.kind current_part.public_r_tag = menu_part.public_r_tag @@ -52,10 +52,10 @@ class Page < Item current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id) end end - else - if current_part.new_record? - current_part.save - end + elsif current_part.new_record? + PagePart.without_callback(:save, :after, :update_parent) do + current_part.save + end end end end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 6dbec1e2..c3af57d1 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -206,7 +206,12 @@ module ParserCommon when 'text' ret << part.content rescue '' when 'module_widget' - url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true" + url = case part.widget_path + when 'default_widget' + "/panel/orbit_app/widget/#{part.widget_style}?inner=true" + else + "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true" + end options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}" ret << "
" when 'public_r_tag'