Add sub_menu to site_info

This commit is contained in:
Christophe Vilayphiou committed 2012-05-08 17:27:02 +08:00
1 parent caba8ce7a4
commit 5c7cf1aef2
7 files changed
+43 -8

No files matched your search

+1
View File
@@ -29,6 +29,7 @@ module ParserBackEnd
public_r_tags = parse_content_edits(body, page, id)
parse_images(body, page)
parse_footer(body, page, true)
parse_sub_menu(body, page, true)
public_r_tags.each do |tag|
send("parse_#{tag}s", body, page,id)
+24 -6
View File
@@ -116,14 +116,32 @@ module ParserCommon
end
end
# page_menu
# page_footer
def parse_footer(body, page, edit=nil)
page_footer = body.css('.page_footer').first
res = "<div, id='footer', class='footer'>"
res << @site.footer[I18n.locale]
res << "</div>"
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
page_footer.swap(fragment) rescue nil
if page_footer
res = "<div id='#{page_footer['id']}', class='#{page_footer['class']}'>"
res << @site.footer[I18n.locale] rescue nil
res << "</div>"
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
page_footer.swap(fragment) rescue nil
else
''
end
end
# page_sub_menu
def parse_sub_menu(body, page, edit=nil)
page_sub_menu = body.css('.page_sub_menu').first
if page_sub_menu
res = "<div id='#{page_sub_menu['id']}', class='#{page_sub_menu['class']}'>"
res << @site.sub_menu[I18n.locale] rescue nil
res << "</div>"
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
page_sub_menu.swap(fragment) rescue nil
else
''
end
end
end
+2 -1
View File
@@ -26,7 +26,8 @@ module ParserFrontEnd
parse_menu(body, page)
public_r_tags = parse_contents(body, page, id,params[:preview])
parse_images(body, page)
parse_footer(body, page, true)
parse_footer(body, page)
parse_sub_menu(body, page)
public_r_tags.each do |tag|
send("parse_#{tag}s", body, page,id)