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 end
def page_title(page) 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 end
def page_stylesheets(page, edit=nil) def page_stylesheets(page, edit=nil)
@ -123,6 +132,7 @@ module ApplicationHelper
stylesheets << "<link href='/assets/style.css' rel='stylesheet' type='text/css' />\n" stylesheets << "<link href='/assets/style.css' rel='stylesheet' type='text/css' />\n"
end end
stylesheets << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.reset_css 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 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 } 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 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 :roaming_id
field :private_key, :type => Binary field :private_key, :type => Binary
field :public_key, :type => Binary field :public_key, :type => Binary
field :title_always_on, :type => Boolean, :default => false
field :school field :school
field :department field :department

View File

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

View File

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

View File

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

View File

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