Commit 31d7ff735b528433fd68d749ed9a9e9fefdc9b48
1 parent
dd840bc5
Exists in
master
and in
28 other branches
ActionItem0: finalizing refactoring
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@143 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
8 changed files
with
15 additions
and
91 deletions
Show diff stats
app/controllers/application.rb
@@ -2,10 +2,6 @@ | @@ -2,10 +2,6 @@ | ||
2 | # available in all controllers. | 2 | # available in all controllers. |
3 | class ApplicationController < ActionController::Base | 3 | class ApplicationController < ActionController::Base |
4 | 4 | ||
5 | - ICONS_DIR_PATH = "#{RAILS_ROOT}/public/icons" | ||
6 | - THEME_DIR_PATH = "#{RAILS_ROOT}/public/themes" | ||
7 | - | ||
8 | - | ||
9 | before_filter :detect_stuff_by_domain | 5 | before_filter :detect_stuff_by_domain |
10 | attr_reader :virtual_community | 6 | attr_reader :virtual_community |
11 | 7 | ||
@@ -19,49 +15,6 @@ class ApplicationController < ActionController::Base | @@ -19,49 +15,6 @@ class ApplicationController < ActionController::Base | ||
19 | end | 15 | end |
20 | end | 16 | end |
21 | 17 | ||
22 | - before_filter :load_icons_theme | ||
23 | - # Load the icons belongs to a Profile and set it at @chosen_icons_theme variable. | ||
24 | - # If no profile exist the @chosen_icons_theme variable is set to 'default' | ||
25 | - def load_icons_theme | ||
26 | - if Profile.exists?(1) | ||
27 | - @owner = Profile.find(1) | ||
28 | - end | ||
29 | - @chosen_icons_theme = @owner.icons_theme.nil? ? "default" : @owner.icons_theme | ||
30 | - end | ||
31 | - | ||
32 | - | ||
33 | - # Set the default template to the profile | ||
34 | - def set_default_template | ||
35 | - p = Profile.find(params[:object_id]) | ||
36 | - set_template(p,params[:template_name]) | ||
37 | - end | ||
38 | - | ||
39 | - # Set the default theme to the profile | ||
40 | - def set_default_theme | ||
41 | - p = Profile.find(params[:object_id]) | ||
42 | - set_theme(p,params[:theme_name]) | ||
43 | - end | ||
44 | - | ||
45 | - # Set the default icons theme to the profile | ||
46 | - def set_default_icons_theme | ||
47 | - p = Profile.find(params[:object_id]) | ||
48 | - set_icons_theme(p,params[:icons_theme_name]) | ||
49 | - end | ||
50 | - | ||
51 | - | ||
52 | - private | ||
53 | - | ||
54 | - # Set to the owner the theme choosed | ||
55 | - def set_theme(object, theme_name) | ||
56 | - object.theme = theme_name | ||
57 | - object.save | ||
58 | - end | ||
59 | - | ||
60 | - # Set to the owner the icons theme choosed | ||
61 | - def set_icons_theme(object,icons_theme_name) | ||
62 | - object.icons_theme = icons_theme_name | ||
63 | - object.save | ||
64 | - end | ||
65 | 18 | ||
66 | protected | 19 | protected |
67 | 20 |
app/helpers/application_helper.rb
1 | # Methods added to this helper will be available to all templates in the application. | 1 | # Methods added to this helper will be available to all templates in the application. |
2 | module ApplicationHelper | 2 | module ApplicationHelper |
3 | 3 | ||
4 | - ICONS_DIR_PATH = "#{RAILS_ROOT}/public/icons" | ||
5 | - | ||
6 | - | ||
7 | - # Generate a select option to choose one of the available icons themes. | ||
8 | - # The available icons themes are those in 'public/icons' | ||
9 | - def select_icons_theme(object, chosen_icons_theme = nil) | ||
10 | - return '' if object.nil? | ||
11 | - available_icons_themes = Dir.new("#{ICONS_DIR_PATH}").to_a - REJECTED_DIRS | ||
12 | - icons_theme_options = options_for_select(available_icons_themes.map{|icons_theme| [icons_theme, icons_theme] }, chosen_icons_theme) | ||
13 | - select_tag('icons_theme_name', icons_theme_options ) + | ||
14 | - change_icons_theme('icons_theme_name', object) | ||
15 | - end | ||
16 | - | ||
17 | - # Generate a observer to reload a page when a icons theme is selected | ||
18 | - def change_icons_theme(observed_field, object) | ||
19 | - observe_field( observed_field, | ||
20 | - :url => {:action => 'set_default_icons_theme'}, | ||
21 | - :with =>"'icons_theme_name=' + escape(value) + '&object_id=' + escape(#{object.id})", | ||
22 | - :complete => "document.location.reload();" | ||
23 | - ) | ||
24 | - end | ||
25 | - | ||
26 | - #Display a given icon passed as argument | ||
27 | - #The icon path should be '/icons/{icons_theme}/{icon_image}' | ||
28 | - def display_icon(icon , icons_theme = "default", options = {}) | ||
29 | - image_tag("/icons/#{icons_theme}/#{icon}.png", options) | ||
30 | - end | ||
31 | - | ||
32 | 4 | ||
33 | # Displays context help. You can pass the content of the help message as the | 5 | # Displays context help. You can pass the content of the help message as the |
34 | # first parameter or using template code inside a block passed to this | 6 | # first parameter or using template code inside a block passed to this |
app/views/home/index.rhtml
1 | <%= flash[:notice] %> | 1 | <%= flash[:notice] %> |
2 | Start page of Virtual Community <%= @virtual_community.name %> | 2 | Start page of Virtual Community <%= @virtual_community.name %> |
3 | 3 | ||
4 | -<%= @boxes.length %> | ||
5 | 4 | ||
6 | Teste: | 5 | Teste: |
7 | <%= @ft_config[:template].inspect %> | 6 | <%= @ft_config[:template].inspect %> |
7 | +<%= @ft_config[:owner].template %> | ||
8 | caralho | 8 | caralho |
9 | 9 |
app/views/layouts/_box_template.rhtml
@@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
1 | -<%= edit_blocks(@box) %> |
app/views/layouts/application.rhtml
@@ -21,34 +21,34 @@ | @@ -21,34 +21,34 @@ | ||
21 | <div id="header"> | 21 | <div id="header"> |
22 | <h1> | 22 | <h1> |
23 | <a href="index.html">1024<span class="fade">px</span></a> | 23 | <a href="index.html">1024<span class="fade">px</span></a> |
24 | - </h1> | 24 | + </h1> |
25 | <p id="slogan">when 800px just isn't enough...</p> | 25 | <p id="slogan">when 800px just isn't enough...</p> |
26 | </div> | 26 | </div> |
27 | 27 | ||
28 | <%= link_to _('Show Layout'), :controller => 'home' %> | 28 | <%= link_to _('Show Layout'), :controller => 'home' %> |
29 | <%= link_to _('Edit Layout'), :controller => 'edit_template' %> | 29 | <%= link_to _('Edit Layout'), :controller => 'edit_template' %> |
30 | 30 | ||
31 | - <%= select_template(@owner, @chosen_template) %> | ||
32 | - <%= select_theme(@owner, @chosen_theme) %> | ||
33 | - <%= select_icons_theme(@owner, @chosen_icons_theme) %> | 31 | + <%= select_template %> |
32 | + <%= select_theme %> | ||
33 | + <%= select_icons_theme %> | ||
34 | 34 | ||
35 | - <%= display_icon('back', @chosen_icons_theme )%> | 35 | + <%= display_icon('back')%> |
36 | 36 | ||
37 | <%= flash[:notice] %> | 37 | <%= flash[:notice] %> |
38 | 38 | ||
39 | - <%= display_boxes(@boxes, yield) %> | 39 | + <%= display_boxes(yield) %> |
40 | <div class="clearfix"></div> | 40 | <div class="clearfix"></div> |
41 | 41 | ||
42 | - <div id="footer"> | 42 | + <div id="footer"> |
43 | <p> | 43 | <p> |
44 | <a href="#">Contact us</a> | | 44 | <a href="#">Contact us</a> | |
45 | <a href="#">Privacy policy</a> | | 45 | <a href="#">Privacy policy</a> | |
46 | <a href="#">Sitemap</a> | | 46 | <a href="#">Sitemap</a> | |
47 | <a href="#">RSS</a> | | 47 | <a href="#">RSS</a> | |
48 | - <a href="#header">Back to top</a><br /> | 48 | + <a href="#header">Back to top</a><br /> |
49 | © 2007 <a href="#">Your Name</a> | Design by <a href="http://andreasviklund.com/">Andreas Viklund</a> | 49 | © 2007 <a href="#">Your Name</a> | Design by <a href="http://andreasviklund.com/">Andreas Viklund</a> |
50 | - </p> | ||
51 | - </div> | 50 | + </p> |
51 | + </div> | ||
52 | </div> | 52 | </div> |
53 | </div> | 53 | </div> |
54 | 54 |
public/themes/default/blue.css
public/themes/pink/pink.css