diff --git a/app/controllers/application.rb b/app/controllers/application.rb index f7a3f7f..6cc41f6 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -9,34 +9,14 @@ class ApplicationController < ActionController::Base before_filter :detect_stuff_by_domain attr_reader :virtual_community - uses_flexible_template :owner => 'owner' - def flexible_template_owner - Profile.find(1) - end - - before_filter :load_template - # Load the template belongs to a Profile and set it at @chosen_template variable. - # If no profile exist the @chosen_template variable is set to 'default' - def load_template + before_filter :load_owner + # Load the owner + def load_owner # TODO: this should not be hardcoded if Profile.exists?(1) @owner = Profile.find(1) end - @chosen_template = @owner.template.nil? ? "default" : @owner.template - self.chosen_template = @chosen_template - end - - before_filter :load_boxes - - before_filter :load_theme - # Load the theme belongs to a Profile and set it at @chosen_theme variable. - # If no profile exist the @chosen_theme variable is set to 'default' - def load_theme - if Profile.exists?(1) - @owner = Profile.find(1) - end - @chosen_theme = @owner.theme.nil? ? "default" : @owner.theme end before_filter :load_icons_theme diff --git a/app/controllers/edit_template_controller.rb b/app/controllers/edit_template_controller.rb index 1aa6097..bf1ae2e 100644 --- a/app/controllers/edit_template_controller.rb +++ b/app/controllers/edit_template_controller.rb @@ -1,10 +1,9 @@ class EditTemplateController < ApplicationController -# before_filter :leila - uses_flexible_template :edit => true, :owner => 'owner' + uses_flexible_template(:edit => true, :owner => 'owner') -# def leila -# @owner = Profile.find(1) -# end + def flexible_template_owner + Profile.find(1) + end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index a9768a7..3174682 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,8 +1,9 @@ class HomeController < ApplicationController - def index - end + uses_flexible_template :owner => 'owner' - uses_flexible_template :edit => false, :owner => 'owner' + def flexible_template_owner + Profile.find(1) + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 58d6297..5b4dd3f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,35 +1,7 @@ # Methods added to this helper will be available to all templates in the application. module ApplicationHelper - # Directories to be rejected of the directories list when needed. - # TODO I think the better way is create a Dir class method that returns a list of files of a given path - REJECTED_DIRS = %w[ - . - .. - .svn - ] - ICONS_DIR_PATH = "#{RAILS_ROOT}/public/icons" - THEME_DIR_PATH = "#{RAILS_ROOT}/public/themes" - - # Generate a select option to choose one of the available themes. - # The available themes are those in 'public/themes' - def select_theme(object, chosen_theme = nil) - return '' if object.nil? - available_themes = Dir.new("#{THEME_DIR_PATH}").to_a - REJECTED_DIRS - theme_options = options_for_select(available_themes.map{|theme| [theme, theme] }, chosen_theme) - select_tag('theme_name', theme_options ) + - change_theme('theme_name', object) - end - - # Generate a observer to reload a page when a theme is selected - def change_theme(observed_field, object) - observe_field( observed_field, - :url => {:action => 'set_default_theme'}, - :with =>"'theme_name=' + escape(value) + '&object_id=' + escape(#{object.id})", - :complete => "document.location.reload();" - ) - end # Generate a select option to choose one of the available icons themes. @@ -57,23 +29,6 @@ module ApplicationHelper image_tag("/icons/#{icons_theme}/#{icon}.png", options) end - # Load all the css files of a existing theme with the theme_name passed as argument. - # - # The files loaded are in the path: - # - # 'public/themes/#{theme_name}/*' - # If a invalid theme it's passed the 'default' theme is applied - def stylesheet_link_tag_theme(theme_name) - if !File.exists? "#{THEME_DIR_PATH}/#{theme_name}" - flash[:notice] = _("The theme %s it's not a valid theme") % theme_name - theme_name = 'default' - end - - d = Dir.new("#{THEME_DIR_PATH}/#{theme_name}/").to_a - REJECTED_DIRS - d.map do |filename| - stylesheet_link_tag("/themes/#{theme_name}/#{filename}") - end - end # Displays context help. You can pass the content of the help message as the # first parameter or using template code inside a block passed to this diff --git a/app/views/home/index.rhtml b/app/views/home/index.rhtml index f8421ee..fc58b31 100644 --- a/app/views/home/index.rhtml +++ b/app/views/home/index.rhtml @@ -1,8 +1,9 @@ <%= flash[:notice] %> Start page of Virtual Community <%= @virtual_community.name %> +<%= @boxes.length %> + Teste: -<%= @bla %> -<%= @bli.inspect %> +<%= @ft_config[:template].inspect %> caralho diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index d3c3de4..21310f5 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -1,9 +1,9 @@ <%= javascript_include_tag :defaults %> - <%= javascript_include_tag_template @chosen_template %> - <%= stylesheet_link_tag_template @chosen_template %> - <%= stylesheet_link_tag_theme @chosen_theme %> + <%= javascript_include_tag_template %> + <%= stylesheet_link_tag_template %> + <%= stylesheet_link_tag_theme %> -- libgit2 0.21.2