Add sub_menu to site_info
This commit is contained in:
parent
caba8ce7a4
commit
5c7cf1aef2
|
@ -18,6 +18,7 @@ class Site
|
||||||
|
|
||||||
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
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 :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
|
has_many :site_metas, :autosave => true, :dependent => :destroy
|
||||||
|
|
||||||
before_save :set_key
|
before_save :set_key
|
||||||
|
@ -33,7 +34,6 @@ class Site
|
||||||
end
|
end
|
||||||
|
|
||||||
def up_to_date?
|
def up_to_date?
|
||||||
p res = %x(git remote show origin)
|
|
||||||
res = res.split('rails_3_1').pop.gsub('(', '').gsub(')','').strip rescue nil
|
res = res.split('rails_3_1').pop.gsub('(', '').gsub(')','').strip rescue nil
|
||||||
res.eql?('local out of date') ? false : true
|
res.eql?('local out of date') ? false : true
|
||||||
end
|
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
|
@footer ||= I18nVariable.first(:conditions => {:key => 'footer', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
|
||||||
end
|
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|
|
METAS.each do |meta|
|
||||||
define_method meta do
|
define_method meta do
|
||||||
fetch_meta = self.site_metas.where(key: meta).limit(1)
|
fetch_meta = self.site_metas.where(key: meta).limit(1)
|
||||||
|
@ -66,6 +70,7 @@ class Site
|
||||||
def set_key
|
def set_key
|
||||||
title.key = 'title' if title && (title.key.blank? rescue true)
|
title.key = 'title' if title && (title.key.blank? rescue true)
|
||||||
footer.key = 'footer' if footer && (footer.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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,6 +55,14 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label"><%= t 'admin.site_sub_menu' %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.fields_for :sub_menu, @site.sub_menu do |f| %>
|
||||||
|
<%= f.text_area locale, :class => "tinymce_textarea input-xxlarge" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -205,6 +205,7 @@ en:
|
||||||
site_description: Site description
|
site_description: Site description
|
||||||
site_footer: Site footer
|
site_footer: Site footer
|
||||||
site_settings: Site Setting
|
site_settings: Site Setting
|
||||||
|
site_sub_menu: Site sub-menu
|
||||||
site_title: Site title
|
site_title: Site title
|
||||||
super_pages: Super pages
|
super_pages: Super pages
|
||||||
structure: Structure
|
structure: Structure
|
||||||
|
|
|
@ -195,6 +195,7 @@ zh_tw:
|
||||||
site_description: 網站描述
|
site_description: 網站描述
|
||||||
site_footer: 網站頁尾
|
site_footer: 網站頁尾
|
||||||
site_settings: 基本設定
|
site_settings: 基本設定
|
||||||
|
site_sub_menu: 網站次選單
|
||||||
site_title: 網站標題
|
site_title: 網站標題
|
||||||
setup_member: 成員設置
|
setup_member: 成員設置
|
||||||
setup_translations: 語系設定
|
setup_translations: 語系設定
|
||||||
|
|
|
@ -29,6 +29,7 @@ module ParserBackEnd
|
||||||
public_r_tags = parse_content_edits(body, page, id)
|
public_r_tags = parse_content_edits(body, page, id)
|
||||||
parse_images(body, page)
|
parse_images(body, page)
|
||||||
parse_footer(body, page, true)
|
parse_footer(body, page, true)
|
||||||
|
parse_sub_menu(body, page, true)
|
||||||
|
|
||||||
public_r_tags.each do |tag|
|
public_r_tags.each do |tag|
|
||||||
send("parse_#{tag}s", body, page,id)
|
send("parse_#{tag}s", body, page,id)
|
||||||
|
|
|
@ -116,14 +116,32 @@ module ParserCommon
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# page_menu
|
# page_footer
|
||||||
def parse_footer(body, page, edit=nil)
|
def parse_footer(body, page, edit=nil)
|
||||||
page_footer = body.css('.page_footer').first
|
page_footer = body.css('.page_footer').first
|
||||||
res = "<div, id='footer', class='footer'>"
|
if page_footer
|
||||||
res << @site.footer[I18n.locale]
|
res = "<div id='#{page_footer['id']}', class='#{page_footer['class']}'>"
|
||||||
|
res << @site.footer[I18n.locale] rescue nil
|
||||||
res << "</div>"
|
res << "</div>"
|
||||||
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
|
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
|
||||||
page_footer.swap(fragment) rescue nil
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,8 @@ module ParserFrontEnd
|
||||||
parse_menu(body, page)
|
parse_menu(body, page)
|
||||||
public_r_tags = parse_contents(body, page, id,params[:preview])
|
public_r_tags = parse_contents(body, page, id,params[:preview])
|
||||||
parse_images(body, page)
|
parse_images(body, page)
|
||||||
parse_footer(body, page, true)
|
parse_footer(body, page)
|
||||||
|
parse_sub_menu(body, page)
|
||||||
|
|
||||||
public_r_tags.each do |tag|
|
public_r_tags.each do |tag|
|
||||||
send("parse_#{tag}s", body, page,id)
|
send("parse_#{tag}s", body, page,id)
|
||||||
|
|
Loading…
Reference in New Issue