From e52119e25808dbf1c628e7781b62aa75ec7ec21c Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 7 May 2012 13:33:29 +0800 Subject: [PATCH] Add footer parser --- lib/parsers/parser_back_end.rb | 1 + lib/parsers/parser_common.rb | 13 ++++++++++++- lib/parsers/parser_front_end.rb | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index 24b6c59f..0ebaf90b 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -28,6 +28,7 @@ module ParserBackEnd parse_menu(body, page, true) public_r_tags = parse_content_edits(body, page, id) parse_images(body, page) + parse_footer(body, page, true) public_r_tags.each do |tag| send("parse_#{tag}s", body, page,id) diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 66491232..04fe2e6c 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -1,5 +1,6 @@ module ParserCommon - + include ActionView::Helpers::TagHelper + def menu_level(page, current, menu, edit = false) res = '' if menu.levels > 0 && current <= menu.levels @@ -127,4 +128,14 @@ module ParserCommon end end + # page_menu + def parse_footer(body, page, edit=nil) + page_footer = body.css('.page_footer').first + res = "" + res << @site.footer[I18n.locale] + res << "" + fragment = Nokogiri::HTML::DocumentFragment.new(body ,res) + page_footer.swap(fragment) + end + end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index c95cac4d..d37eba30 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -26,6 +26,7 @@ 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) public_r_tags.each do |tag| send("parse_#{tag}s", body, page,id)