add function : redirect to homepage

This commit is contained in:
Ruling-iMac 2015-04-30 18:31:40 +08:00
parent 927b08edeb
commit d386174c97
5 changed files with 16 additions and 1 deletions

View File

@ -119,7 +119,11 @@ class PagesController < ApplicationController
end
render :html => render_final_page("#{module_app}/#{params[:target_action]}",page,layout).html_safe
else
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => :not_found
if Site.first.enable_redirect_index
redirect_to root_url
else
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => :not_found
end
end
else
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => :not_found

View File

@ -23,6 +23,7 @@ class Site
field :mobile_api_openness_on, :type => Boolean, :default => false
field :desktop_closed, :type => Boolean, :default => false
field :enable_language_detection, :type => Boolean, :default => false
field :enable_redirect_index, :type => Boolean, :default => false
field :enable_zh_cn, :type => Boolean, :default => true
field :default_locale, :default => "zh_tw"
field :mobile_on, :type => Boolean, :default => false

View File

@ -185,6 +185,14 @@
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('preferences.redirect_index') %>
</label>
<div class="controls">
<%= f.check_box :enable_redirect_index, :class => "toggle-check reset_default_locale", data: {disabled: true} %>
</div>
</div>
</div>
<!-- OrbitBar Them -->

View File

@ -422,6 +422,7 @@ en:
lang_enabled: Enable Language
lang_default: Default Language
lang_detection: Enable User Language Detection
redirect_index: Redirect to home if page not found
nav_enabled: Enable Sidebar Sub Nav
openness: Openness
orbitbar_theme: OrbitBar Theme

View File

@ -429,6 +429,7 @@ zh_tw:
icon: 圖示
language: 語系設定
lang_detection: 開啟使用者語系偵測
redirect_index: 切換語系倒回首頁
lang_enabled: 開啟語系
lang_default: 預設語系
nav_enabled: 開啟側欄導引