Commit bca9640c35539b0539e4d9d8f4fb24db24f66dbf

Authored by LeandroNunes
1 parent 2429ca31

ActionItem0: redefining show blocks

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@128 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/application_helper.rb
@@ -11,7 +11,6 @@ module ApplicationHelper @@ -11,7 +11,6 @@ module ApplicationHelper
11 11
12 ICONS_DIR_PATH = "#{RAILS_ROOT}/public/icons" 12 ICONS_DIR_PATH = "#{RAILS_ROOT}/public/icons"
13 THEME_DIR_PATH = "#{RAILS_ROOT}/public/themes" 13 THEME_DIR_PATH = "#{RAILS_ROOT}/public/themes"
14 -  
15 14
16 # Generate a select option to choose one of the available themes. 15 # Generate a select option to choose one of the available themes.
17 # The available themes are those in 'public/themes' 16 # The available themes are those in 'public/themes'
app/models/link_block.rb
1 class LinkBlock < Block 1 class LinkBlock < Block
2 2
3 - # Redefinition of to_html Block method that show a list of links showing the Profile name.  
4 - #  
5 - # Ex:  
6 - #  
7 - # <a href="http://www.colivre.coop.br"> Colivre </a>  
8 - #  
9 - # <a href="http://www.ba.softwarelivre.org"> PSL-BA </a>  
10 - def to_html  
11 - profiles = Profile.find(:all).map do |p|  
12 - content_tag("a href='http://www.google.com.br'", p.name)  
13 - end  
14 - profiles.join(',')  
15 - end  
16 -  
17 def content 3 def content
18 - profiles = Profile.find(:all) 4 + Profile.find(:all).map{|p| p.name}
19 end 5 end
20 6
21 end 7 end
app/models/list_block.rb
1 class ListBlock < Block 1 class ListBlock < Block
2 2
3 - def to_html  
4 - content_tag(:ul, Profile.find(:all).map{|p| content_tag( :li, p.name ) }) 3 + def content
  4 + Profile.find(:all).map{|p|p.name}
5 end 5 end
6 end 6 end
db/migrate/005_manage_template_migration.rb
@@ -12,6 +12,7 @@ class ManageTemplateMigration &lt; ActiveRecord::Migration @@ -12,6 +12,7 @@ class ManageTemplateMigration &lt; ActiveRecord::Migration
12 t.column :box_id, :integer 12 t.column :box_id, :integer
13 t.column :position, :integer 13 t.column :position, :integer
14 t.column :type, :string 14 t.column :type, :string
  15 + t.column :helper, :string
15 end 16 end
16 17
17 end 18 end
test/fixtures/blocks.yml
@@ -5,6 +5,7 @@ one: @@ -5,6 +5,7 @@ one:
5 box_id: 2 5 box_id: 2
6 position: 1 6 position: 1
7 type: 'MainBlock' 7 type: 'MainBlock'
  8 + helper: 'plain_content'
8 name: 'Main Content' 9 name: 'Main Content'
9 # Link Blocks 10 # Link Blocks
10 two: 11 two:
@@ -12,12 +13,14 @@ two: @@ -12,12 +13,14 @@ two:
12 box_id: 1 13 box_id: 1
13 position: 2 14 position: 2
14 type: 'LinkBlock' 15 type: 'LinkBlock'
  16 + helper: 'list_content'
15 name: 'List of Links 1' 17 name: 'List of Links 1'
16 three: 18 three:
17 id: 3 19 id: 3
18 box_id: 1 20 box_id: 1
19 position: 3 21 position: 3
20 type: 'LinkBlock' 22 type: 'LinkBlock'
  23 + helper: 'plain_content'
21 name: 'List of Link 2' 24 name: 'List of Link 2'
22 #List Blocks 25 #List Blocks
23 four: 26 four:
@@ -25,16 +28,19 @@ four: @@ -25,16 +28,19 @@ four:
25 box_id: 1 28 box_id: 1
26 position: 1 29 position: 1
27 type: 'ListBlock' 30 type: 'ListBlock'
  31 + helper: 'list_content'
28 name: 'List of Names 1' 32 name: 'List of Names 1'
29 five: 33 five:
30 id: 5 34 id: 5
31 box_id: 3 35 box_id: 3
32 position: 1 36 position: 1
33 type: 'ListBlock' 37 type: 'ListBlock'
  38 + helper: 'list_content'
34 name: 'List of Names 2' 39 name: 'List of Names 2'
35 six: 40 six:
36 id: 6 41 id: 6
37 box_id: 3 42 box_id: 3
38 position: 2 43 position: 2
39 type: 'ListBlock' 44 type: 'ListBlock'
  45 + helper: 'list_content'
40 name: 'List of Names 3' 46 name: 'List of Names 3'