preferred theme

This commit is contained in:
Andreas Stephanides
2015-06-03 08:28:09 +02:00
parent 6c2238e740
commit d3e97ff422
5 changed files with 27 additions and 13 deletions

View File

@@ -37,24 +37,20 @@
end end
end end
def get_theme def get_theme
u=current_user
# if params[:theme]== "default" || params[:theme]=="2003" || params[:theme].nil? if ! u.try(:preferredtheme).nil? and ThemesForRails.available_theme_names.include?(u.preferredtheme)
# params[:theme]="blue1" u.preferredtheme
# end
if ThemesForRails.available_theme_names.include?(params[:theme]) and can? :showintern,Thema
params[:theme]
else else
"blue1" "blue1"
end end
end end
def current_ability def current_ability
@current_ability ||= Ability.new(current_user, request) @current_ability ||= Ability.new(current_user, request)
end end
def default_url_options def default_url_options
{locale: I18n.locale, theme: (theme_name=="blue1") ? nil : theme_name , ansicht: nil} {locale: I18n.locale, theme: nil , ansicht: nil}
end end
end end

View File

@@ -113,4 +113,17 @@ m.save
url.path=path url.path=path
return url return url
end end
def get_theme_help(u)
# if params[:theme]== "default" || params[:theme]=="2003" || params[:theme].nil?
# params[:theme]="blue1"
# end
if ! u.try(:preferredtheme).nil? and ThemesForRails.available_theme_names.include?(u.preferredtheme)
u.preferredtheme
else
"blue1"
end
end
end end

View File

@@ -28,7 +28,7 @@
<div id="maincontainer" class="container-fluid"> <div id="maincontainer" class="container-fluid">
<div class="row-fluid"> <div class="row-fluid">
<div class="span10 offset1 header_span"> <div class="span10 offset1 header_span">
<% cache("menu_u"+user_signed_in?.to_s+current_user.try(:id).to_s+"l"+I18n.locale.to_s+ can?(:seeintern, User).to_s+ can?(:index,Gallery).to_s, expires_in: 24.hours) do %> <% cache("menu_u"+user_signed_in?.to_s+current_user.try(:id).to_s+"l"+I18n.locale.to_s+ can?(:seeintern, User).to_s+ can?(:index,Gallery).to_s+params[:theme].to_s, expires_in: 24.hours) do %>
<div class="header_wrap"> <div class="header_wrap">
<div class="header hidden-print"> <div class="header hidden-print">
<%= link_to home_index_path do %> <%= link_to home_index_path do %>

View File

@@ -54,7 +54,7 @@
</div> </div>
<div class="span3"> <div class="span3">
<% cache("calendar_" + cache_array_key(@calentries)+params[:month].to_s+params[:year].to_s) do %> <% cache("calendar_" + cache_array_key(@calentries)+params[:month].to_s+params[:year].to_s+params[:theme].to_s) do %>
<%= render 'calendars/calentries', :object=>@calentries %> <%= render 'calendars/calentries', :object=>@calentries %>
<% end %> <% end %>

View File

@@ -0,0 +1,5 @@
class AddPreferredthemeToUsers < ActiveRecord::Migration
def change
add_column :users, :preferredtheme, :string
end
end