From 5c94200b77d5d11de43345b68a407dfc872b8a40 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 29 May 2013 10:21:21 +0800 Subject: [PATCH] fix argument passing problem for more link and tag cloud, incomplete code. --- app/controllers/pages_controller.rb | 2 +- lib/parsers/parser_front_end.rb | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 578bdc5e..2796c6a5 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -32,7 +32,7 @@ class PagesController < ApplicationController if params[:clicked_field_name] render_page({"clicked_field_name"=>params["clicked_field_name"]}) unless save_from_no_lang_for_page else - render_page unless save_from_no_lang_for_page + render_page(params) unless save_from_no_lang_for_page end when 'Link' redirect_to(@item[:url]) unless save_from_no_lang_for_page diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index a4b1b53d..0ffb4f0f 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -19,8 +19,12 @@ module ParserFrontEnd end def parse_page_content(page,args=nil) - tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id] - category = params[:category_id].blank? ? page[:category] : params[:category_id] + try{ + args["category_id"] = args["category_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if args["category_id"].is_a? String + args["tag_id"] = args["tag_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if args["category_id"].is_a? String + } + # tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id] + # category = params[:category_id].blank? ? page[:category] : params[:category_id] body = Nokogiri::HTML(page.content) body.css('orbit_front').each do |front| if front['value'] @@ -29,9 +33,12 @@ module ParserFrontEnd ret = '' part = PagePart.find(front['part_id']) if front['part_id'] ret << eval("\"#{front['path']}\"") rescue '' - args.each do |index,arg| - ret << (ret.include?("?") ? "&#{index}=#{arg}": "?#{index}=#{arg}" ) + if index=="tag_id" || index=="category_id" + ret << (ret.include?("?") ? "&#{index}[]=#{arg}": "?#{index}[]=#{arg}" ) + else + ret << (ret.include?("?") ? "&#{index}=#{arg}": "?#{index}=#{arg}" ) + end end if args fragment = Nokogiri::HTML::DocumentFragment.new(body, "
") end