Commit b6f11d12d09372caad557b2e4735b266ce714b40
Committed by
Rafael Reggiani Manzo
1 parent
2b143a6d
Exists in
web_steps_improvements
and in
9 other branches
moved HTML out of all core blocks
Showing
9 changed files
with
77 additions
and
65 deletions
Show diff stats
app/models/blog_archives_block.rb
app/models/disabled_enterprise_message_block.rb
app/models/product_categories_block.rb
... | ... | @@ -14,22 +14,9 @@ class ProductCategoriesBlock < Block |
14 | 14 | end |
15 | 15 | |
16 | 16 | def content(args={}) |
17 | - profile = owner | |
17 | + block = self | |
18 | 18 | proc do |
19 | - if @categories.nil? or @categories.length == 0 | |
20 | - categories = ProductCategory.on_level(nil).order(:name) | |
21 | - if @categories and @categories.length == 0 | |
22 | - notice = _('There are no sub-categories for %s') % @category.name | |
23 | - end | |
24 | - else | |
25 | - categories = @categories | |
26 | - end | |
27 | - render :file => 'blocks/product_categories', | |
28 | - :locals => { | |
29 | - :profile => profile, | |
30 | - :categories => categories, | |
31 | - :notice => notice | |
32 | - } | |
19 | + render :file => 'blocks/product_categories', :locals => { :block => block } | |
33 | 20 | end |
34 | 21 | end |
35 | 22 | ... | ... |
app/models/profile_list_block.rb
... | ... | @@ -41,22 +41,9 @@ result = public_profiles.all(:limit => get_limit, :order => 'profiles.updated_at |
41 | 41 | end |
42 | 42 | |
43 | 43 | def content(args={}) |
44 | - profiles = self.profile_list | |
45 | - title = self.view_title | |
46 | - nl = "\n" | |
47 | - proc do |context| | |
48 | - count=0 | |
49 | - list = profiles.map {|item| | |
50 | - count+=1 | |
51 | - send(:profile_image_link, item, :minor ) | |
52 | - }.join("\n ") | |
53 | - if list.empty? | |
54 | - list = content_tag 'div', _('None'), :class => 'common-profile-list-block-none' | |
55 | - else | |
56 | - list = content_tag 'ul', nl +' '+ list + nl | |
57 | - end | |
58 | - block_title(title) + nl + | |
59 | - content_tag('div', nl + list + nl + tag('br', :style => 'clear:both')) | |
44 | + block = self | |
45 | + proc do | |
46 | + render :file => 'blocks/profile_list', :locals => { :block => block } | |
60 | 47 | end |
61 | 48 | end |
62 | 49 | ... | ... |
app/models/tags_block.rb
... | ... | @@ -29,24 +29,10 @@ class TagsBlock < Block |
29 | 29 | end |
30 | 30 | |
31 | 31 | def content(args={}) |
32 | - is_env = owner.class == Environment | |
33 | - tags = is_env ? owner.tag_counts : owner.article_tags | |
34 | - return '' if tags.empty? | |
35 | - | |
36 | - if limit | |
37 | - tags_tmp = tags.sort_by{ |k,v| -v }[0..(limit-1)] | |
38 | - tags = {} | |
39 | - tags_tmp.map{ |k,v| tags[k] = v } | |
32 | + block = self | |
33 | + proc do | |
34 | + render :file => 'blocks/tags', :locals => { :block => block } | |
40 | 35 | end |
41 | - | |
42 | - url = is_env ? {:host=>owner.default_hostname, :controller=>'search', :action => 'tag'} : | |
43 | - owner.public_profile_url.merge(:controller => 'profile', :action => 'content_tagged') | |
44 | - tagname_option = is_env ? :tag : :id | |
45 | - | |
46 | - block_title(title) + | |
47 | - "\n<div class='tag_cloud'>\n".html_safe+ | |
48 | - tag_cloud( tags, tagname_option, url, :max_size => 16, :min_size => 9 ) + | |
49 | - "\n</div><!-- end class='tag_cloud' -->\n".html_safe | |
50 | 36 | end |
51 | 37 | |
52 | 38 | def footer | ... | ... |
app/views/blocks/blog_archives.html.erb
1 | -<%= block_title(block.title) %> | |
1 | +<% if block.blog %> | |
2 | + <%= block_title(block.title) %> | |
2 | 3 | |
3 | -<ul class='blog-archives'> | |
4 | - <% block.blog.total_number_of_posts(:by_year).each do |year, count| %> | |
5 | - <%= content_tag('li', content_tag('strong', "#{year.to_i} (#{count})")) %> | |
6 | - <ul class='<%= year.to_i %>-archive'> | |
7 | - <% block.blog.total_number_of_posts(:by_month, year).each do |month, count| %> | |
8 | - <%= content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", block.blog.url.merge(year: year.to_i, month: month.to_i))) %> | |
9 | - <% end %> | |
10 | - </ul> | |
11 | - <% end %> | |
12 | -</ul> | |
4 | + <ul class='blog-archives'> | |
5 | + <% block.blog.total_number_of_posts(:by_year).each do |year, count| %> | |
6 | + <%= content_tag('li', content_tag('strong', "#{year.to_i} (#{count})")) %> | |
7 | + <ul class='<%= year.to_i %>-archive'> | |
8 | + <% block.blog.total_number_of_posts(:by_month, year).each do |month, count| %> | |
9 | + <%= content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", block.blog.url.merge(year: year.to_i, month: month.to_i))) %> | |
10 | + <% end %> | |
11 | + </ul> | |
12 | + <% end %> | |
13 | + </ul> | |
13 | 14 | |
14 | -<%= content_tag('div', link_to(_('Subscribe RSS Feed'), block.blog.feed.url), :class => 'subscribe-feed') %> | |
15 | + <%= content_tag('div', link_to(_('Subscribe RSS Feed'), block.blog.feed.url), :class => 'subscribe-feed') %> | |
16 | +<% end %> | ... | ... |
app/views/blocks/product_categories.html.erb
1 | -<%= link_to _('Catalog start'), profile.catalog_url, :class=>'catalog-home-link' %> | |
1 | +<% | |
2 | + if @categories.nil? or @categories.length == 0 | |
3 | + categories = ProductCategory.on_level(nil).order(:name) | |
4 | + else | |
5 | + categories = @categories | |
6 | + end | |
7 | +%> | |
8 | + | |
9 | +<%= link_to _('Catalog start'), block.owner.catalog_url, :class=>'catalog-home-link' %> | |
2 | 10 | <ul class="catalog-categories-list"> |
3 | 11 | <% categories.each do |category| %> |
4 | 12 | <%= category_with_sub_list(category) %> |
5 | 13 | <% end %> |
6 | 14 | </ul> |
7 | -<% if notice %> | |
8 | - <div class="catalog-categories-notice"><%= notice %></div> | |
15 | +<% if @categories and @categories.length == 0 %> | |
16 | + <div class="catalog-categories-notice"> | |
17 | + <%= _('There are no sub-categories for %s') % @category.name %> | |
18 | + </div> | |
9 | 19 | <% end %> | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +<%= block_title(block.view_title) %> | |
2 | + | |
3 | +<% | |
4 | + count=0 | |
5 | + list = block.profile_list.map {|item| count+=1 block.send(:profile_image_link, item, :minor)}.join("\n ") | |
6 | +%> | |
7 | + | |
8 | +<div> | |
9 | + <% if list.empty? %> | |
10 | + <div class='common-profile-list-block-none'><%= _('None') %></div> | |
11 | + <% else %> | |
12 | + <ul><%= list %></ul> | |
13 | + <% end %> | |
14 | +</div> | |
15 | + | |
16 | +<br style='clear:both'/> | ... | ... |
... | ... | @@ -0,0 +1,25 @@ |
1 | +<%= block_title(block.title) %> | |
2 | + | |
3 | +<% | |
4 | + is_env = block.owner.class == Environment | |
5 | + tags = is_env ? block.owner.tag_counts : block.owner.article_tags | |
6 | + if block.limit | |
7 | + tags_tmp = tags.sort_by{ |k,v| -v }[0..(block.limit-1)] | |
8 | + tags = {} | |
9 | + tags_tmp.map{ |k,v| tags[k] = v } | |
10 | + end | |
11 | +%> | |
12 | + | |
13 | +<% unless tags.empty? %> | |
14 | + <div class='tag_cloud'> | |
15 | + <% if is_env %> | |
16 | + <%= tag_cloud(tags, :tag, | |
17 | + {:host=>block.owner.default_hostname, :controller=>'search', :action => 'tag'}, | |
18 | + :max_size => 16, :min_size => 9) %> | |
19 | + <% else %> | |
20 | + <%= tag_cloud(tags, :id, | |
21 | + owner.public_profile_url.merge(:controller => 'profile', :action => 'content_tagged'), | |
22 | + :max_size => 16, :min_size => 9) %> | |
23 | + <% end %> | |
24 | + </div> | |
25 | +<% end %> | ... | ... |