diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index 63744182..ad146fc5 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -37,7 +37,7 @@ class Admin::LinksController < Admin::ItemsController link = Link.find(params[:id]) m = {} m["public"] = link.is_published ? 1 : 0 - m["link"] = @site_valid_locales.inject([]) do |result, locale| + m["link"] = @site_in_use_locales.inject([]) do |result, locale| result << [locale, (link.enabled_for && link.enabled_for.include?(locale)) ? 1 : 0, (link.menu_enabled_for && link.menu_enabled_for[locale].eql?("true")) ? 1 :0] end render json: JSON.pretty_generate(m) diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index ef16c878..7f3ecde4 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -73,7 +73,7 @@ class Admin::PagesController < Admin::ItemsController m["category"] = page.category.present? ? page.category.map{|c| c.to_s} : [] m["tags"] = page.tag.present? ? page.tag.map{|c| c.to_s} : [] m["public"] = page.is_published ? 1 : 0 - m["link"] = @site_valid_locales.inject([]) do |link, locale| + m["link"] = @site_in_use_locales.inject([]) do |link, locale| link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale].eql?('true')) ? 1 :0] end m["count"] = page.frontend_data_count diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 96088f42..50d399a9 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -21,6 +21,7 @@ class Admin::SitesController < OrbitBackendController end def update + params[:site][:defalut_locale] = "zh_tw" if params[:site][:default_locale].blank? @site.update_attributes(params[:site]) redirect_to :back end @@ -71,6 +72,13 @@ class Admin::SitesController < OrbitBackendController end + def reset_default_locale + @site.defalut_locale = params[:default_locale] + if @site.save + render :nothing => true + end + end + def change_design design = Design.find(params[:site_id]) rescue nil update_design(design) if design diff --git a/app/helpers/admin/assets_helper.rb b/app/helpers/admin/assets_helper.rb index 9a2fd0a3..acc65c11 100644 --- a/app/helpers/admin/assets_helper.rb +++ b/app/helpers/admin/assets_helper.rb @@ -2,7 +2,7 @@ module Admin::AssetsHelper def show_all_fields(asset, field) a = [] - @site_valid_locales.each do |locale| + @site_in_use_locales.each do |locale| a << asset.send("#{field}_translations")[locale] rescue nil end a.join(' - ') diff --git a/app/helpers/admin/tags_helper.rb b/app/helpers/admin/tags_helper.rb index a9c48c3a..4d195e63 100644 --- a/app/helpers/admin/tags_helper.rb +++ b/app/helpers/admin/tags_helper.rb @@ -6,7 +6,7 @@ module Admin::TagsHelper end def show_names_slash(tag) - span_names = @site_valid_locales.inject([]) do |names, locale| + span_names = @site_in_use_locales.inject([]) do |names, locale| names << content_tag(:span, tag.name_translations[locale], class: "tag") end span_names.join(" / ").html_safe diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 2bfc4eeb..88760a32 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -59,7 +59,8 @@ class User validates :user_id, :presence => { :message => I18n.t("users.user_id_not_null") } , - :length => {:minimum => 3, :maximum => 50, :message => I18n.t("users.user_id_length") } + :length => {:minimum => 3, :maximum => 50, :message => I18n.t("users.user_id_length") }, + :uniqueness => true def email_required? false diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 71d6dbf4..1ddecf8b 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -166,7 +166,7 @@ - <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <%= asset_category.title_translations[locale] rescue nil %> <% end %> diff --git a/app/views/admin/asset_categories/_form.html.erb b/app/views/admin/asset_categories/_form.html.erb index 12a4693b..81c8973f 100644 --- a/app/views/admin/asset_categories/_form.html.erb +++ b/app/views/admin/asset_categories/_form.html.erb @@ -11,7 +11,7 @@
<%= f.fields_for :title_translations do |f| %> - <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %>
<%= label_tag "name-#{locale}", "#{t(:name)}-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
diff --git a/app/views/admin/asset_categories/index.html.erb b/app/views/admin/asset_categories/index.html.erb index 0ca08b7b..9725a43e 100644 --- a/app/views/admin/asset_categories/index.html.erb +++ b/app/views/admin/asset_categories/index.html.erb @@ -8,7 +8,7 @@ <%= t(:key) %> - <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> <% end %> @@ -23,7 +23,7 @@ - <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <% end %> diff --git a/app/views/admin/assets/_asset.html.erb b/app/views/admin/assets/_asset.html.erb index b7c30fe9..fd76be26 100644 --- a/app/views/admin/assets/_asset.html.erb +++ b/app/views/admin/assets/_asset.html.erb @@ -2,7 +2,7 @@ <%= check_box_tag 'files[]', asset.id, false, :class => "checkbox_in_list" %> - <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> <% end %> diff --git a/app/views/admin/assets/_form.html.erb b/app/views/admin/assets/_form.html.erb index 1e080678..830b8e19 100644 --- a/app/views/admin/assets/_form.html.erb +++ b/app/views/admin/assets/_form.html.erb @@ -1,10 +1,10 @@
- <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %>
">
<%= f.label :title , t('asset.title'), :class=>"control-label muted" %> diff --git a/app/views/admin/assets/file_upload.html.erb b/app/views/admin/assets/file_upload.html.erb index ddb0c1b0..bded6944 100644 --- a/app/views/admin/assets/file_upload.html.erb +++ b/app/views/admin/assets/file_upload.html.erb @@ -16,7 +16,7 @@
<%= f.fields_for :title_translations do |f| %>
- <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <%= content_tag :label do -%>
<%= I18nVariable.from_locale(locale) %> @@ -33,7 +33,7 @@
<%= f.fields_for :description_translations do |f| %>
- <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <%= content_tag :label do -%>
<%= I18nVariable.from_locale(locale) %> diff --git a/app/views/admin/attributes/_attribute_field.html.erb b/app/views/admin/attributes/_attribute_field.html.erb index 15e0d0e7..23f8f6e8 100644 --- a/app/views/admin/attributes/_attribute_field.html.erb +++ b/app/views/admin/attributes/_attribute_field.html.erb @@ -4,7 +4,7 @@ <%= f.check_box :locale %> <%= f.fields_for :title_translations do |f| %> - <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <%= f.text_field locale, :style => "width:130px", :value => (attribute_field.title_translations[locale] rescue nil) %> <% end %> <% end %> diff --git a/app/views/admin/attributes/new.html.erb b/app/views/admin/attributes/new.html.erb index 404a2db5..2ecf57a7 100644 --- a/app/views/admin/attributes/new.html.erb +++ b/app/views/admin/attributes/new.html.erb @@ -30,7 +30,7 @@
- <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> "> diff --git a/app/views/admin/categories/_category.html.erb b/app/views/admin/categories/_category.html.erb index bab1a194..fca22a5d 100644 --- a/app/views/admin/categories/_category.html.erb +++ b/app/views/admin/categories/_category.html.erb @@ -1,5 +1,5 @@ - <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> <%= category.title_translations[locale] %> <% if i == 0 %> diff --git a/app/views/admin/categories/_form.html.erb b/app/views/admin/categories/_form.html.erb index b741a24f..510f8de3 100644 --- a/app/views/admin/categories/_form.html.erb +++ b/app/views/admin/categories/_form.html.erb @@ -2,7 +2,7 @@ <%= f.error_messages %> <%= f.fields_for :title_translations do |f| %> - <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <%= label_tag "name-#{locale}", "#{t(:name)} (#{I18nVariable.from_locale(locale)})" %> <%= f.text_field locale, :class => 'input-large', :value => (@category.title_translations[locale] rescue ''), placeholder: t(:name), id: locale %> <% end %> diff --git a/app/views/admin/categories/_index.html.erb b/app/views/admin/categories/_index.html.erb index efd77dc8..6687692d 100644 --- a/app/views/admin/categories/_index.html.erb +++ b/app/views/admin/categories/_index.html.erb @@ -1,7 +1,7 @@ - <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> <% end %> diff --git a/app/views/admin/items/_form_link.html.erb b/app/views/admin/items/_form_link.html.erb index 57069624..2d3c546c 100644 --- a/app/views/admin/items/_form_link.html.erb +++ b/app/views/admin/items/_form_link.html.erb @@ -7,7 +7,7 @@ <%= f.text_field :name, class: 'input-xlarge', placeholder: t(:name), id: 'name' %> <%= t("front_page.name_field_helper") %> - <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <%= f.fields_for :title_translations do |f| %> <%= f.label :locale, "#{t(:title)} #{I18nVariable.from_locale(locale)}" %> <%= f.text_field locale, class: 'input-xlarge', placeholder: "#{t(:title)} #{I18nVariable.from_locale(locale)}", id: locale %> @@ -31,7 +31,7 @@ - <% @site_valid_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %> <% end %> diff --git a/app/views/admin/role_filters/_role_filter.html.erb b/app/views/admin/role_filters/_role_filter.html.erb index a2a9d733..47fe438a 100644 --- a/app/views/admin/role_filters/_role_filter.html.erb +++ b/app/views/admin/role_filters/_role_filter.html.erb @@ -2,7 +2,7 @@ <% if @types.is_localized?(:title) %> - <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %>
<%= t(:_locale, :locale => locale) %>
Key<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= role_filter.key %> <%= role_filter.title_translations[locale] rescue nil %> <% if i == 0 %> diff --git a/app/views/admin/roles/add_sub_role.html.erb b/app/views/admin/roles/add_sub_role.html.erb index 305281c1..3f7f111f 100644 --- a/app/views/admin/roles/add_sub_role.html.erb +++ b/app/views/admin/roles/add_sub_role.html.erb @@ -8,7 +8,7 @@
<%= @sub_attribute.key%>
<% end %> - <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> "> diff --git a/app/views/admin/roles/edit.html.erb b/app/views/admin/roles/edit.html.erb index ece8ccc8..93211673 100644 --- a/app/views/admin/roles/edit.html.erb +++ b/app/views/admin/roles/edit.html.erb @@ -8,7 +8,7 @@
<%= @attribute.key%>
<% end %> - <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> " value="<%= @attribute.title_translations[locale] rescue nil %>"> diff --git a/app/views/admin/roles/edit_sub_role.html.erb b/app/views/admin/roles/edit_sub_role.html.erb index 1ac50570..7700f6a9 100644 --- a/app/views/admin/roles/edit_sub_role.html.erb +++ b/app/views/admin/roles/edit_sub_role.html.erb @@ -8,7 +8,7 @@
<%= @sub_attribute.key%>
<% end %> - <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> " value="<%= @sub_attribute.title_translations[locale] rescue nil %>"> diff --git a/app/views/admin/roles/new.html.erb b/app/views/admin/roles/new.html.erb index 6d48013f..e50684ce 100644 --- a/app/views/admin/roles/new.html.erb +++ b/app/views/admin/roles/new.html.erb @@ -9,7 +9,7 @@
<%= @attribute.key%>
<% end %> - <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> "> diff --git a/app/views/admin/sites/preference.html.erb b/app/views/admin/sites/preference.html.erb index fd4b8525..45d5c37b 100644 --- a/app/views/admin/sites/preference.html.erb +++ b/app/views/admin/sites/preference.html.erb @@ -146,14 +146,14 @@
- <%= f.check_box :enable_language_detection, :class => "toggle-check", data: {disabled: true} %> + <%= f.check_box :enable_language_detection, :class => "toggle-check reset_default_locale", data: {disabled: true} %>
- <% @site_valid_locales.each do |valid_locale| %> + <% @site_in_use_locales.each do |valid_locale| %> <%= check_box_tag "site[in_use_locales][]", valid_locale, @site.in_use_locales.include?(valid_locale), :class=>"toggle-check in_use_locales", :data => { :title => "#{I18nVariable.from_locale(valid_locale)}", disabled: true }, "data-deploy"=>"inline" %> <% end %>
@@ -258,4 +258,17 @@ var locales = <%= @site.in_use_locales.to_json.html_safe %>; }) }) delete locales; - \ No newline at end of file + +<% content_for :page_specific_javascript do %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/sites/search_engine.html.erb b/app/views/admin/sites/search_engine.html.erb index 5a8f6261..e7e79a95 100644 --- a/app/views/admin/sites/search_engine.html.erb +++ b/app/views/admin/sites/search_engine.html.erb @@ -49,11 +49,11 @@
- <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> " href="#textarea_<%= locale %>_0" data-toggle="tab"><%= I18nVariable.from_locale(locale) %> <% end %>
- <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %>
" id="textarea_<%= locale %>_0"> <%= f.fields_for :keywords do |f| %> <%= f.text_area locale, :class=>'resizable', :value => (@site.keywords(locale) rescue nil), :placeholder => I18nVariable.from_locale(locale), :rows=>"3" %> @@ -69,11 +69,11 @@
- <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %> " href="#textarea_<%= locale %>_0" data-toggle="tab"><%= I18nVariable.from_locale(locale) %> <% end %>
- <% @site_valid_locales.each_with_index do |locale, i| %> + <% @site_in_use_locales.each_with_index do |locale, i| %>
" id="textarea_<%= locale %>_0"> <%= f.fields_for :description do |f| %> <%= f.text_area locale, :class=>'resizable', :value => (@site.description(locale) rescue nil), :placeholder => I18nVariable.from_locale(locale), :rows=>"3" %> diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index 0e5ef848..588fdcaa 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -23,8 +23,7 @@ @@ -32,7 +31,7 @@
- <% @site_valid_locales.each do |locale|%> + <% @site_in_use_locales.each do |locale|%> <%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %>
@@ -56,7 +55,7 @@
- <% @site_valid_locales.each do |locale|%> + <% @site_in_use_locales.each do |locale|%> <%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %>
@@ -81,7 +80,7 @@
- <% @site_valid_locales.each do |locale|%> + <% @site_in_use_locales.each do |locale|%> <%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %>
@@ -105,7 +104,7 @@
- <% @site_valid_locales.each do |locale|%> + <% @site_in_use_locales.each do |locale|%> <%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %>
diff --git a/app/views/admin/sites/sitemap.html.erb b/app/views/admin/sites/sitemap.html.erb index 499f707f..575913c7 100644 --- a/app/views/admin/sites/sitemap.html.erb +++ b/app/views/admin/sites/sitemap.html.erb @@ -14,7 +14,7 @@ <% end %>