Add i18n for site_info.

Add always display site title.
Changes for menu in front-end
This commit is contained in:
Christophe Vilayphiou 2012-05-07 15:11:43 +08:00
parent e52119e258
commit 8b61314cc4
6 changed files with 47 additions and 37 deletions

View File

@ -112,7 +112,16 @@ module ApplicationHelper
end
def page_title(page)
"<title>#{page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]}</title>\n"
res = "<title>"
page_title = page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]
if page.is_home? && @site.title
res << @site.title[I18n.locale]
elsif @site.title && @site.title_always_on
res << @site.title[I18n.locale] + ' - ' + page_title
else
res << page_title
end
res << "</title>\n"
end
def page_stylesheets(page, edit=nil)
@ -123,6 +132,7 @@ module ApplicationHelper
stylesheets << "<link href='/assets/style.css' rel='stylesheet' type='text/css' />\n"
end
stylesheets << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.reset_css
# stylesheets << "<link href='/assets/menu.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.default_css
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
stylesheets << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />\n" if theme

View File

@ -11,6 +11,7 @@ class Site
field :roaming_id
field :private_key, :type => Binary
field :public_key, :type => Binary
field :title_always_on, :type => Boolean, :default => false
field :school
field :department

View File

@ -12,28 +12,29 @@
</li>
</ul>
<div class="tab-content">
<%= f.check_box :title_always_on %> <%= t 'admin.always_display_title' %>
<% @site_valid_locales.each do |locale|%>
<%= content_tag :div, :class => "tab-pane #{active_when_current_locale_eq locale}", :id => "#{locale}" do %>
<div>
<%= t :title %>
<%= t 'admin.site_title' %>
<%= f.fields_for :title, @site.title do |f| %>
<%= f.text_field locale %>
<% end %>
</div>
<div>
<%= t :keywords %>
<%= t 'admin.keywords' %>
<%= f.fields_for :keywords, @site.keywords do |f| %>
<%= f.text_field locale %>
<% end %>
</div>
<div>
<%= t :description %>
<%= t 'admin.site_description' %>
<%= f.fields_for :description, @site.description do |f| %>
<%= f.text_field locale %>
<% end %>
</div>
<div>
<%= t :footer %>
<%= t 'admin.site_footer' %>
<%= f.fields_for :footer, @site.footer do |f| %>
<%= f.text_area locale, :class => "tinymce_textarea" %>
<% end %>

View File

@ -98,6 +98,7 @@ en:
admin: Admin
action: Action
all_articles: List
always_display_title: Always displayed in the title bar
announcement: Announcement
asset: Asset
assets:
@ -147,6 +148,7 @@ en:
is_published: Is published
item: Item
key: Key
keywords: Keywords
language: Language
layout: Layout
layout_name: Layout name
@ -199,7 +201,10 @@ en:
setup_translations: Translations setup
setup_designs: Designs setup
site: Site
site_description: Site description
site_footer: Site footer
site_settings: Site Setting
site_title: Site title
super_pages: Super pages
structure: Structure
title: Title

View File

@ -91,6 +91,7 @@ zh_tw:
add_drop_down_item: 增加Orbit選單
admin: 網站管理者
all_articles: 列表
always_display_title: 永遠顯示於標題列
announcement: 公告管理
asset: 資產
assets:
@ -144,6 +145,7 @@ zh_tw:
is_published: 被出版
item: 網站架構
key: 關鍵
keywords: 關鍵字
language: 語言
layout: 佈局
layout_name: 佈局名字
@ -189,7 +191,10 @@ zh_tw:
purchase: 購買
role: 身份
roles: 身份
site_description: 網站描述
site_footer: 網站頁尾
site_settings: 基本設定
site_title: 網站標題
setup_member: 成員設置
setup_translations: 語系設定
setup_designs: 版型設定

View File

@ -3,46 +3,34 @@ module ParserCommon
def menu_level(page, current, menu, edit = false)
res = ''
if menu.levels > 0 && current <= menu.levels
if current != 0
res << "<div class='rc_dm'>"
item = rand(100000)
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl' rel='#{item}'>#{page.i18n_variable[I18n.locale]}<span class='down'></span></a>"
if page.children.size > 0
res << "<div id='#{item}' class='dm_list #{menu.values['class_#{current}']}'>"
res << "<ul class='ini_list'>"
i = nil
i = 1 if menu.values["li_incremental_#{current}"]
page.ordered_and_visible_children.each do |child|
res << menu_li(child, current, menu, i, edit)
i += 1 if i
end
res << "</ul>"
res << "</div>"
end
res << "</div>"
else
res << '<ul>'
res << "<li>" + "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl'>#{page.i18n_variable[I18n.locale]}</a>" + "</li>"
page.ordered_and_visible_children.each do |child|
res << "<li>" + menu_level(child, current + 1, menu, edit) + "</li>"
end
res << '</ul>'
if page.children.size > 0
res << "<ul class='"
res << menu.values["class_#{current}"] rescue nil
res << "'>"
i = nil
i = 1 if menu.values["li_incremental_#{current}"]
if menu.values['home'] && current == 1
res << menu_li(page, current, menu, i, edit)
end
page.ordered_and_visible_children.each do |child|
res << menu_li(child, current, menu, i, edit)
i += 1 if i
end
res << "</ul>"
end
res
end
def menu_li(page, current, menu, i, edit)
res = "<li class="
res << menu.values["li_class_#{current}"]
res << menu.values["li_class_#{current}"] rescue nil
res << "_#{i}" if i
res << ">"
if page.ordered_and_visible_children.size > 0
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}'><span>#{page.i18n_variable[I18n.locale]}</span></a>"
if page.ordered_and_visible_children.size > 0 && current <= menu.levels
res << "<span class='dot'></span>"
res << menu_level(page, current + 1, menu, edit)
else
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='nav dm_ctrl'>#{page.i18n_variable[I18n.locale]}</a>"
end
end unless (page.is_home? rescue nil)
res << "</li>"
end
@ -104,7 +92,7 @@ module ParserCommon
page_menu = body.css('.page_menu').first
home = get_homepage
menu = page.design.layout.menu
fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu, edit))
fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 1, menu, edit))
page_menu.swap(fragment)
end
@ -135,7 +123,7 @@ module ParserCommon
res << @site.footer[I18n.locale]
res << "</div>"
fragment = Nokogiri::HTML::DocumentFragment.new(body ,res)
page_footer.swap(fragment)
page_footer.swap(fragment) rescue nil
end
end