Commit 8cd2832ee0e7920c6cad76d16dbbd4a594ad1aef
Committed by
Rafael Reggiani Manzo
1 parent
5e476c5e
Exists in
web_steps_improvements
and in
9 other branches
removing content() method from all blocks
also: * rename login_block.html.erb -> login.html.erb * created symlinks for ProfileListBlock subclasses
Showing
33 changed files
with
47 additions
and
183 deletions
Show diff stats
app/helpers/boxes_helper.rb
@@ -87,8 +87,13 @@ module BoxesHelper | @@ -87,8 +87,13 @@ module BoxesHelper | ||
87 | box_decorator == DontMoveBlocks | 87 | box_decorator == DontMoveBlocks |
88 | end | 88 | end |
89 | 89 | ||
90 | - def display_block_content(block, person, main_content = nil) | ||
91 | - content = block.main? ? wrap_main_content(main_content) : block.content({:person => person}) | 90 | + def render_block_content(block) |
91 | + # TODO: se nao existe retornar nil | ||
92 | + render :file => "blocks/#{block.name.underscore.gsub('_block', '')}", :locals => { :block => block } | ||
93 | + end | ||
94 | + | ||
95 | + def display_block_content(block, main_content = nil) | ||
96 | + content = block.main? ? wrap_main_content(main_content) : render_block_content(block) | ||
92 | result = extract_block_content(content) | 97 | result = extract_block_content(content) |
93 | footer_content = extract_block_content(block.footer) | 98 | footer_content = extract_block_content(block.footer) |
94 | unless footer_content.blank? | 99 | unless footer_content.blank? |
app/models/article_block.rb
@@ -18,13 +18,6 @@ class ArticleBlock < Block | @@ -18,13 +18,6 @@ class ArticleBlock < Block | ||
18 | _('This block displays one of your articles. You can edit the block to select which one of your articles is going to be displayed in the block.') | 18 | _('This block displays one of your articles. You can edit the block to select which one of your articles is going to be displayed in the block.') |
19 | end | 19 | end |
20 | 20 | ||
21 | - def content(args={}) | ||
22 | - block = self | ||
23 | - proc do | ||
24 | - render :file => 'blocks/article', :locals => { :block => block } | ||
25 | - end | ||
26 | - end | ||
27 | - | ||
28 | def article_id | 21 | def article_id |
29 | self.settings[:article_id] | 22 | self.settings[:article_id] |
30 | end | 23 | end |
app/models/blog_archives_block.rb
@@ -21,13 +21,6 @@ class BlogArchivesBlock < Block | @@ -21,13 +21,6 @@ class BlogArchivesBlock < Block | ||
21 | blog_id && owner.blogs.exists?(blog_id) ? owner.blogs.find(blog_id) : owner.blog | 21 | blog_id && owner.blogs.exists?(blog_id) ? owner.blogs.find(blog_id) : owner.blog |
22 | end | 22 | end |
23 | 23 | ||
24 | - def content(args={}) | ||
25 | - block = self | ||
26 | - proc do | ||
27 | - render :file => 'blocks/blog_archives', :locals => { :block => block } | ||
28 | - end | ||
29 | - end | ||
30 | - | ||
31 | def self.expire_on | 24 | def self.expire_on |
32 | { :profile => [:article], :environment => [:article] } | 25 | { :profile => [:article], :environment => [:article] } |
33 | end | 26 | end |
app/models/categories_block.rb
@@ -30,13 +30,6 @@ class CategoriesBlock < Block | @@ -30,13 +30,6 @@ class CategoriesBlock < Block | ||
30 | Category.top_level_for(self.owner).from_types(self.category_types) | 30 | Category.top_level_for(self.owner).from_types(self.category_types) |
31 | end | 31 | end |
32 | 32 | ||
33 | - def content(args={}) | ||
34 | - block = self | ||
35 | - proc do | ||
36 | - render :file => 'blocks/categories', :locals => { :block => block } | ||
37 | - end | ||
38 | - end | ||
39 | - | ||
40 | def self.expire_on | 33 | def self.expire_on |
41 | { :profile => [], :environment => [:category] } | 34 | { :profile => [], :environment => [:category] } |
42 | end | 35 | end |
app/models/communities_block.rb
@@ -32,7 +32,7 @@ class CommunitiesBlock < ProfileListBlock | @@ -32,7 +32,7 @@ class CommunitiesBlock < ProfileListBlock | ||
32 | suggestions = self.suggestions | 32 | suggestions = self.suggestions |
33 | return '' unless owner.kind_of?(Profile) || owner.kind_of?(Environment) | 33 | return '' unless owner.kind_of?(Profile) || owner.kind_of?(Environment) |
34 | proc do | 34 | proc do |
35 | - render :file => 'blocks/communities', :locals => { :owner => owner, :suggestions => suggestions } | 35 | + render :file => 'blocks/communities_footer', :locals => { :owner => owner, :suggestions => suggestions } |
36 | end | 36 | end |
37 | end | 37 | end |
38 | 38 |
app/models/disabled_enterprise_message_block.rb
@@ -12,13 +12,6 @@ class DisabledEnterpriseMessageBlock < Block | @@ -12,13 +12,6 @@ class DisabledEnterpriseMessageBlock < Block | ||
12 | _('Message') | 12 | _('Message') |
13 | end | 13 | end |
14 | 14 | ||
15 | - def content(args={}) | ||
16 | - block = self | ||
17 | - proc do | ||
18 | - render :file => 'blocks/disabled_enterprise_message', :locals => { :block => block } | ||
19 | - end | ||
20 | - end | ||
21 | - | ||
22 | def editable?(user=nil) | 15 | def editable?(user=nil) |
23 | false | 16 | false |
24 | end | 17 | end |
app/models/featured_products_block.rb
@@ -32,11 +32,4 @@ class FeaturedProductsBlock < Block | @@ -32,11 +32,4 @@ class FeaturedProductsBlock < Block | ||
32 | self.owner.highlighted_products_with_image | 32 | self.owner.highlighted_products_with_image |
33 | end | 33 | end |
34 | 34 | ||
35 | - def content(args={}) | ||
36 | - block = self | ||
37 | - proc do | ||
38 | - render :file => 'blocks/featured_products', :locals => { :block => block } | ||
39 | - end | ||
40 | - end | ||
41 | - | ||
42 | end | 35 | end |
app/models/feed_reader_block.rb
app/models/highlights_block.rb
@@ -43,13 +43,6 @@ class HighlightsBlock < Block | @@ -43,13 +43,6 @@ class HighlightsBlock < Block | ||
43 | end | 43 | end |
44 | end | 44 | end |
45 | 45 | ||
46 | - def content(args={}) | ||
47 | - block = self | ||
48 | - proc do | ||
49 | - render :file => 'blocks/highlights', :locals => { :block => block } | ||
50 | - end | ||
51 | - end | ||
52 | - | ||
53 | def folder_choices | 46 | def folder_choices |
54 | owner.image_galleries | 47 | owner.image_galleries |
55 | end | 48 | end |
app/models/link_list_block.rb
@@ -59,13 +59,6 @@ class LinkListBlock < Block | @@ -59,13 +59,6 @@ class LinkListBlock < Block | ||
59 | _('Link list') | 59 | _('Link list') |
60 | end | 60 | end |
61 | 61 | ||
62 | - def content(args={}) | ||
63 | - block = self | ||
64 | - proc do | ||
65 | - render :file => 'blocks/link_list', :locals => { :block => block } | ||
66 | - end | ||
67 | - end | ||
68 | - | ||
69 | def expand_address(address) | 62 | def expand_address(address) |
70 | add = if owner.respond_to?(:identifier) | 63 | add = if owner.respond_to?(:identifier) |
71 | address.gsub('{profile}', owner.identifier) | 64 | address.gsub('{profile}', owner.identifier) |
app/models/location_block.rb
@@ -13,11 +13,4 @@ class LocationBlock < Block | @@ -13,11 +13,4 @@ class LocationBlock < Block | ||
13 | _('Shows where the profile is on the material world.') | 13 | _('Shows where the profile is on the material world.') |
14 | end | 14 | end |
15 | 15 | ||
16 | - def content(args={}) | ||
17 | - block = self | ||
18 | - proc do | ||
19 | - render :file => 'blocks/location', :locals => {:block => block} | ||
20 | - end | ||
21 | - end | ||
22 | - | ||
23 | end | 16 | end |
app/models/login_block.rb
@@ -8,12 +8,6 @@ class LoginBlock < Block | @@ -8,12 +8,6 @@ class LoginBlock < Block | ||
8 | _('This block presents a login/logout block.') | 8 | _('This block presents a login/logout block.') |
9 | end | 9 | end |
10 | 10 | ||
11 | - def content(args={}) | ||
12 | - lambda do |context| | ||
13 | - render :file => 'blocks/login_block' | ||
14 | - end | ||
15 | - end | ||
16 | - | ||
17 | def cacheable? | 11 | def cacheable? |
18 | false | 12 | false |
19 | end | 13 | end |
app/models/main_block.rb
@@ -8,10 +8,6 @@ class MainBlock < Block | @@ -8,10 +8,6 @@ class MainBlock < Block | ||
8 | _('This block presents the main content of your pages.') | 8 | _('This block presents the main content of your pages.') |
9 | end | 9 | end |
10 | 10 | ||
11 | - def content(args={}) | ||
12 | - nil | ||
13 | - end | ||
14 | - | ||
15 | def main? | 11 | def main? |
16 | true | 12 | true |
17 | end | 13 | end |
app/models/my_network_block.rb
@@ -14,13 +14,6 @@ class MyNetworkBlock < Block | @@ -14,13 +14,6 @@ class MyNetworkBlock < Block | ||
14 | _('This block displays some info about your networking.') | 14 | _('This block displays some info about your networking.') |
15 | end | 15 | end |
16 | 16 | ||
17 | - def content(args={}) | ||
18 | - block = self | ||
19 | - proc do | ||
20 | - render :file => 'blocks/my_network', :locals => { :block => block } | ||
21 | - end | ||
22 | - end | ||
23 | - | ||
24 | def cacheable? | 17 | def cacheable? |
25 | false | 18 | false |
26 | end | 19 | end |
app/models/product_categories_block.rb
@@ -13,13 +13,6 @@ class ProductCategoriesBlock < Block | @@ -13,13 +13,6 @@ class ProductCategoriesBlock < Block | ||
13 | _('Helps to filter the products catalog.') | 13 | _('Helps to filter the products catalog.') |
14 | end | 14 | end |
15 | 15 | ||
16 | - def content(args={}) | ||
17 | - block = self | ||
18 | - proc do | ||
19 | - render :file => 'blocks/product_categories', :locals => { :block => block } | ||
20 | - end | ||
21 | - end | ||
22 | - | ||
23 | DISPLAY_OPTIONS = DISPLAY_OPTIONS.merge('catalog_only' => _('Only on the catalog')) | 16 | DISPLAY_OPTIONS = DISPLAY_OPTIONS.merge('catalog_only' => _('Only on the catalog')) |
24 | 17 | ||
25 | def display | 18 | def display |
app/models/products_block.rb
@@ -19,13 +19,6 @@ class ProductsBlock < Block | @@ -19,13 +19,6 @@ class ProductsBlock < Block | ||
19 | _('This block presents a list of your products.') | 19 | _('This block presents a list of your products.') |
20 | end | 20 | end |
21 | 21 | ||
22 | - def content(args={}) | ||
23 | - block = self | ||
24 | - proc do | ||
25 | - render :file => 'blocks/products', :locals => { :block => block } | ||
26 | - end | ||
27 | - end | ||
28 | - | ||
29 | def footer | 22 | def footer |
30 | link_to(_('View all products'), owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) | 23 | link_to(_('View all products'), owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) |
31 | end | 24 | end |
app/models/profile_image_block.rb
@@ -12,13 +12,6 @@ class ProfileImageBlock < Block | @@ -12,13 +12,6 @@ class ProfileImageBlock < Block | ||
12 | _('This block presents the profile image') | 12 | _('This block presents the profile image') |
13 | end | 13 | end |
14 | 14 | ||
15 | - def content(args={}) | ||
16 | - block = self | ||
17 | - proc do | ||
18 | - render :file => 'blocks/profile_image', :locals => { :block => block } | ||
19 | - end | ||
20 | - end | ||
21 | - | ||
22 | def cacheable? | 15 | def cacheable? |
23 | false | 16 | false |
24 | end | 17 | end |
app/models/profile_info_block.rb
@@ -16,13 +16,6 @@ class ProfileInfoBlock < Block | @@ -16,13 +16,6 @@ class ProfileInfoBlock < Block | ||
16 | _('Basic information about <i>%{user}</i>: how long <i>%{user}</i> is part of <i>%{env}</i> and useful links.') % { :user => self.owner.name(), :env => self.owner.environment.name() } | 16 | _('Basic information about <i>%{user}</i>: how long <i>%{user}</i> is part of <i>%{env}</i> and useful links.') % { :user => self.owner.name(), :env => self.owner.environment.name() } |
17 | end | 17 | end |
18 | 18 | ||
19 | - def content(args={}) | ||
20 | - block = self | ||
21 | - proc do | ||
22 | - render :file => 'blocks/profile_info', :locals => { :block => block } | ||
23 | - end | ||
24 | - end | ||
25 | - | ||
26 | def cacheable? | 19 | def cacheable? |
27 | false | 20 | false |
28 | end | 21 | end |
app/models/profile_search_block.rb
@@ -4,11 +4,4 @@ class ProfileSearchBlock < Block | @@ -4,11 +4,4 @@ class ProfileSearchBlock < Block | ||
4 | _('Display a form to search the profile') | 4 | _('Display a form to search the profile') |
5 | end | 5 | end |
6 | 6 | ||
7 | - def content(args={}) | ||
8 | - block = self | ||
9 | - proc do | ||
10 | - render :file => 'blocks/profile_search', :locals => { :block => block } | ||
11 | - end | ||
12 | - end | ||
13 | - | ||
14 | end | 7 | end |
app/models/raw_html_block.rb
@@ -12,13 +12,6 @@ class RawHTMLBlock < Block | @@ -12,13 +12,6 @@ class RawHTMLBlock < Block | ||
12 | 12 | ||
13 | attr_accessible :html | 13 | attr_accessible :html |
14 | 14 | ||
15 | - def content(args={}) | ||
16 | - block = self | ||
17 | - proc do | ||
18 | - render :file => 'blocks/raw_html', :locals => { :block => block } | ||
19 | - end | ||
20 | - end | ||
21 | - | ||
22 | def has_macro? | 15 | def has_macro? |
23 | true | 16 | true |
24 | end | 17 | end |
app/models/recent_documents_block.rb
@@ -22,13 +22,6 @@ class RecentDocumentsBlock < Block | @@ -22,13 +22,6 @@ class RecentDocumentsBlock < Block | ||
22 | 22 | ||
23 | settings_items :limit, :type => :integer, :default => 5 | 23 | settings_items :limit, :type => :integer, :default => 5 |
24 | 24 | ||
25 | - def content(args={}) | ||
26 | - block = self | ||
27 | - proc do | ||
28 | - render :file => 'blocks/recent_documents', :locals => { :block => block } | ||
29 | - end | ||
30 | - end | ||
31 | - | ||
32 | def footer | 25 | def footer |
33 | return nil unless self.owner.is_a?(Profile) | 26 | return nil unless self.owner.is_a?(Profile) |
34 | 27 |
app/models/sellers_search_block.rb
@@ -22,10 +22,4 @@ class SellersSearchBlock < Block | @@ -22,10 +22,4 @@ class SellersSearchBlock < Block | ||
22 | _('This block presents a search engine for products.') | 22 | _('This block presents a search engine for products.') |
23 | end | 23 | end |
24 | 24 | ||
25 | - def content(args={}) | ||
26 | - block = self | ||
27 | - proc do | ||
28 | - render :file => 'blocks/sellers_search', :locals => { :block => block } | ||
29 | - end | ||
30 | - end | ||
31 | end | 25 | end |
app/models/slideshow_block.rb
@@ -33,13 +33,6 @@ class SlideshowBlock < Block | @@ -33,13 +33,6 @@ class SlideshowBlock < Block | ||
33 | gallery.images.reject {|item| item.folder?} | 33 | gallery.images.reject {|item| item.folder?} |
34 | end | 34 | end |
35 | 35 | ||
36 | - def content(args={}) | ||
37 | - block = self | ||
38 | - proc do | ||
39 | - render :file => 'blocks/slideshow', :locals => { :block => block } | ||
40 | - end | ||
41 | - end | ||
42 | - | ||
43 | def folder_choices | 36 | def folder_choices |
44 | owner.image_galleries | 37 | owner.image_galleries |
45 | end | 38 | end |
app/models/tags_block.rb
@@ -28,13 +28,6 @@ class TagsBlock < Block | @@ -28,13 +28,6 @@ class TagsBlock < Block | ||
28 | Try to add some tags to some articles and you'l see your tag cloud growing.") | 28 | Try to add some tags to some articles and you'l see your tag cloud growing.") |
29 | end | 29 | end |
30 | 30 | ||
31 | - def content(args={}) | ||
32 | - block = self | ||
33 | - proc do | ||
34 | - render :file => 'blocks/tags', :locals => { :block => block } | ||
35 | - end | ||
36 | - end | ||
37 | - | ||
38 | def footer | 31 | def footer |
39 | if owner.class == Environment | 32 | if owner.class == Environment |
40 | proc do | 33 | proc do |
app/views/blocks/communities.html.erb
@@ -1,17 +0,0 @@ | @@ -1,17 +0,0 @@ | ||
1 | -<% if owner.kind_of?(Profile) %> | ||
2 | - <%= link_to s_('communities|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %> | ||
3 | -<% elsif owner.kind_of?(Environment) %> | ||
4 | - <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %> | ||
5 | -<% end %> | ||
6 | - | ||
7 | -<% if user && user == profile && suggestions && !suggestions.empty? %> | ||
8 | - <div class='suggestions-block common-profile-list-block'> | ||
9 | - <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> | ||
10 | - <div class='profiles-suggestions'> | ||
11 | - <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions, :per_page => 3 } %> | ||
12 | - </div> | ||
13 | - <div class='more-suggestions'> | ||
14 | - <%= link_to _('See all suggestions'), profile.communities_suggestions_url %> | ||
15 | - </div> | ||
16 | - </div> | ||
17 | -<% end %> |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<% if owner.kind_of?(Profile) %> | ||
2 | + <%= link_to s_('communities|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %> | ||
3 | +<% elsif owner.kind_of?(Environment) %> | ||
4 | + <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %> | ||
5 | +<% end %> | ||
6 | + | ||
7 | +<% if user && user == profile && suggestions && !suggestions.empty? %> | ||
8 | + <div class='suggestions-block common-profile-list-block'> | ||
9 | + <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> | ||
10 | + <div class='profiles-suggestions'> | ||
11 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions, :per_page => 3 } %> | ||
12 | + </div> | ||
13 | + <div class='more-suggestions'> | ||
14 | + <%= link_to _('See all suggestions'), profile.communities_suggestions_url %> | ||
15 | + </div> | ||
16 | + </div> | ||
17 | +<% end %> |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<% if user.present? %> | ||
2 | + <div class="logged-user-info"> | ||
3 | + <h2><%= _('Logged in as %s') % user.identifier %></h2> | ||
4 | + <ul> | ||
5 | + <li><%= _('User since %s/%s') % [user.created_at.month, user.created_at.year] %></li> | ||
6 | + <li><%= link_to _('Homepage'), user.public_profile_url %></li> | ||
7 | + </ul> | ||
8 | + <div class="user-actions"> | ||
9 | + <%= button(:'menu-logout', _('Logout'), :controller => 'account', :action => 'logout') %> | ||
10 | + </div> | ||
11 | + </div> | ||
12 | +<% else %> | ||
13 | + <div class='not-logged-user'> | ||
14 | + <%= render :file => 'account/login_block' %> | ||
15 | + </div> | ||
16 | +<% end%> |
app/views/blocks/login_block.html.erb
@@ -1,16 +0,0 @@ | @@ -1,16 +0,0 @@ | ||
1 | -<% if user.present? %> | ||
2 | - <div class="logged-user-info"> | ||
3 | - <h2><%= _('Logged in as %s') % user.identifier %></h2> | ||
4 | - <ul> | ||
5 | - <li><%= _('User since %s/%s') % [user.created_at.month, user.created_at.year] %></li> | ||
6 | - <li><%= link_to _('Homepage'), user.public_profile_url %></li> | ||
7 | - </ul> | ||
8 | - <div class="user-actions"> | ||
9 | - <%= button(:'menu-logout', _('Logout'), :controller => 'account', :action => 'logout') %> | ||
10 | - </div> | ||
11 | - </div> | ||
12 | -<% else %> | ||
13 | - <div class='not-logged-user'> | ||
14 | - <%= render :file => 'account/login_block' %> | ||
15 | - </div> | ||
16 | -<% end%> |
app/views/shared/block.html.erb
1 | <% if block.cacheable? && use_cache %> | 1 | <% if block.cacheable? && use_cache %> |
2 | <% cache_timeout(block.cache_key(language, user), block.timeout) do %> | 2 | <% cache_timeout(block.cache_key(language, user), block.timeout) do %> |
3 | - <%= display_block_content(block, user, main_content) %> | 3 | + <%= display_block_content(block, main_content) %> |
4 | <% end %> | 4 | <% end %> |
5 | <% else %> | 5 | <% else %> |
6 | - <%= display_block_content(block, user, main_content) %> | 6 | + <%= display_block_content(block, main_content) %> |
7 | <% end %> | 7 | <% end %> |