From c5f6dbc1c41328c9986bdd25d8c2eef9385d9e3b Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 17:57:50 +0800 Subject: [PATCH] Nokogiri in parsers --- lib/parsers/parser_front_end.rb | 91 --------------------------------- 1 file changed, 91 deletions(-) diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index fa4cb70d..c3ca1787 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -73,96 +73,5 @@ module ParserFrontEnd end public_r_tags.uniq end - - - - require 'nokogiri' - - def parse_page_noko(page, id = nil) - body = Nokogiri::HTML(page.design.layout.body) - - # page_contents - body.css('.page_content').each do |content| - ret = '' - if (content["main"] == "true" && !page.module_app.nil?) - ret << "
" - else - part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil - case part.kind - when 'text' - ret << part.i18n_variable[I18n.locale] rescue '' - when 'module_widget' - if part[:category] - ret << "
" - else - ret << "
" - end - when 'public_r_tag' - ret << "" - else - '' - end - end - scope = "<#{content.name}" - content.attributes.each_pair do |key, value| - scope << " #{key}='#{value}'" - end - scope << ">#{ret}" - fragment = Nokogiri::HTML::DocumentFragment.new(body, scope) - content.swap(fragment) - end - - # page_menu - page_menu = body.css('.page_menu').first - home = get_homepage - menu = page.design.layout.menu - fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu)) - page_menu.swap(fragment) - - # page_image - body.css('.page_image').each do |page_image| - # image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } - # image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image - if image - res = "' - end - fragment = Nokogiri::HTML::DocumentFragment.new(body, res) - page_image.swap(fragment) - end - - # ad_banner - body.css('ad_banner').each do |banner| - res = '' - ad_banner = AdBanner.find(banner["id"]) rescue nil - if ad_banner && ad_banner.display? - res << "" - res << "
" - ad_banner.ad_images.each do |ad_image| - res << "" - end - res << "
" - end - fragment = Nokogiri::HTML::DocumentFragment.new(body, res) - banner.swap(fragment) - end - - body.to_html - end end