Add ad_banner to nokogiri
This commit is contained in:
parent
7eff06a378
commit
0f60ab9fc2
|
@ -79,7 +79,7 @@ module ParserFrontEnd
|
||||||
require 'nokogiri'
|
require 'nokogiri'
|
||||||
|
|
||||||
def parse_page_noko(page, id = nil)
|
def parse_page_noko(page, id = nil)
|
||||||
body = Nokogiri::HTML(page.design.layout.body, nil, 'UTF-8')
|
body = Nokogiri::HTML(page.design.layout.body)
|
||||||
|
|
||||||
# page_contents
|
# page_contents
|
||||||
body.css('.page_content').each do |content|
|
body.css('.page_content').each do |content|
|
||||||
|
@ -139,6 +139,29 @@ module ParserFrontEnd
|
||||||
page_image.swap(fragment)
|
page_image.swap(fragment)
|
||||||
end
|
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 << "<script type='text/javascript'>
|
||||||
|
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({delay: -1000, fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}', timeoutFn: getTimeout }); });
|
||||||
|
</script>"
|
||||||
|
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
|
||||||
|
ad_banner.ad_images.each do |ad_image|
|
||||||
|
res << "<img src='#{ad_image.file}' "
|
||||||
|
res << "alt='#{ad_image.picture_intro || ' '}' "
|
||||||
|
res << "time_to_next='#{ad_image.get_delay_time}' "
|
||||||
|
res << "link_open='#{ad_image.link_open}' "
|
||||||
|
res << "link_url='#{(ad_banner.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
|
||||||
|
res << "/>"
|
||||||
|
end
|
||||||
|
res << "</div>"
|
||||||
|
end
|
||||||
|
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||||
|
banner.swap(fragment)
|
||||||
|
end
|
||||||
|
|
||||||
body.to_html
|
body.to_html
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Reference in New Issue