diff --git a/app/models/site.rb b/app/models/site.rb index a3e0513d..a0116bd3 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -18,6 +18,7 @@ class Site has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :footer, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :sub_menu, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_many :site_metas, :autosave => true, :dependent => :destroy before_save :set_key @@ -33,7 +34,6 @@ class Site end def up_to_date? - p res = %x(git remote show origin) res = res.split('rails_3_1').pop.gsub('(', '').gsub(')','').strip rescue nil res.eql?('local out of date') ? false : true end @@ -46,6 +46,10 @@ class Site @footer ||= I18nVariable.first(:conditions => {:key => 'footer', :language_value_id => self.id, :language_value_type => self.class}) rescue nil end + def sub_menu + @sub_menu ||= I18nVariable.first(:conditions => {:key => 'sub_menu', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + METAS.each do |meta| define_method meta do fetch_meta = self.site_metas.where(key: meta).limit(1) @@ -66,6 +70,7 @@ class Site def set_key title.key = 'title' if title && (title.key.blank? rescue true) footer.key = 'footer' if footer && (footer.key.blank? rescue true) + sub_menu.key = 'sub_menu' if sub_menu && (sub_menu.key.blank? rescue true) end end diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index 64916d4d..96a73aac 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -55,6 +55,14 @@ <% end %> +
+ +
+ <%= f.fields_for :sub_menu, @site.sub_menu do |f| %> + <%= f.text_area locale, :class => "tinymce_textarea input-xxlarge" %> + <% end %> +
+
<% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 4713415f..8384d519 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -205,6 +205,7 @@ en: site_description: Site description site_footer: Site footer site_settings: Site Setting + site_sub_menu: Site sub-menu site_title: Site title super_pages: Super pages structure: Structure diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 8e454ec6..6170e3d5 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -195,6 +195,7 @@ zh_tw: site_description: 網站描述 site_footer: 網站頁尾 site_settings: 基本設定 + site_sub_menu: 網站次選單 site_title: 網站標題 setup_member: 成員設置 setup_translations: 語系設定 diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index 0ebaf90b..718cbcb2 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -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) diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 41d57cbb..1825d9fd 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -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 = "" - res << @site.footer[I18n.locale] - res << "" - fragment = Nokogiri::HTML::DocumentFragment.new(body ,res) - page_footer.swap(fragment) rescue nil + if page_footer + res = "
" + res << @site.footer[I18n.locale] rescue nil + res << "
" + 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 = "
" + res << @site.sub_menu[I18n.locale] rescue nil + res << "
" + fragment = Nokogiri::HTML::DocumentFragment.new(body ,res) + page_sub_menu.swap(fragment) rescue nil + else + '' + end end end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index d37eba30..2a0f38cf 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -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)