Commit bb680e0a5499382ea1f478cf04f44504cdbfd1af
Exists in
master
and in
17 other branches
Merge remote-tracking branch 'origin/master'
Showing
8 changed files
with
114 additions
and
45 deletions
Show diff stats
plugins/context_content/lib/context_content_plugin/context_content_block.rb
... | ... | @@ -2,11 +2,12 @@ class ContextContentPlugin::ContextContentBlock < Block |
2 | 2 | |
3 | 3 | settings_items :show_name, :type => :boolean, :default => true |
4 | 4 | settings_items :show_image, :type => :boolean, :default => true |
5 | + settings_items :use_parent_title, :type => :boolean, :default => false | |
5 | 6 | settings_items :show_parent_content, :type => :boolean, :default => true |
6 | 7 | settings_items :types, :type => Array, :default => ['UploadedFile'] |
7 | 8 | settings_items :limit, :type => :integer, :default => 6 |
8 | 9 | |
9 | - attr_accessible :show_image, :show_name, :show_parent_content, :types | |
10 | + attr_accessible :show_image, :show_name, :use_parent_title, :show_parent_content, :types | |
10 | 11 | |
11 | 12 | alias :profile :owner |
12 | 13 | |
... | ... | @@ -65,6 +66,11 @@ class ContextContentPlugin::ContextContentBlock < Block |
65 | 66 | end |
66 | 67 | end |
67 | 68 | |
69 | + def parent_title(contents) | |
70 | + return nil if contents.blank? | |
71 | + contents.first.parent.name | |
72 | + end | |
73 | + | |
68 | 74 | def footer |
69 | 75 | block = self |
70 | 76 | proc do |
... | ... | @@ -82,9 +88,9 @@ class ContextContentPlugin::ContextContentBlock < Block |
82 | 88 | block = self |
83 | 89 | proc do |
84 | 90 | contents = block.contents(@page) |
91 | + parent_title = block.parent_title(contents) | |
85 | 92 | if !contents.blank? |
86 | - block_title(block.title) + content_tag('div', | |
87 | - render(:file => 'blocks/context_content', :locals => {:block => block, :contents => contents}), :class => 'contents', :id => "context_content_#{block.id}") | |
93 | + render(:file => 'blocks/context_content', :locals => {:block => block, :contents => contents, :parent_title => parent_title}) | |
88 | 94 | else |
89 | 95 | '' |
90 | 96 | end | ... | ... |
plugins/context_content/po/context_content.pot
... | ... | @@ -6,9 +6,10 @@ |
6 | 6 | #, fuzzy |
7 | 7 | msgid "" |
8 | 8 | msgstr "" |
9 | -"Project-Id-Version: 1.3~rc2-1-ga15645d\n" | |
10 | -"POT-Creation-Date: 2015-10-30 16:35-0300\n" | |
11 | -"PO-Revision-Date: 2015-08-06 17:21-0300\n" | |
9 | +"Project-Id-Version: PACKAGE VERSION\n" | |
10 | +"Report-Msgid-Bugs-To: \n" | |
11 | +"POT-Creation-Date: 2016-01-05 12:32+0000\n" | |
12 | +"PO-Revision-Date: 2016-01-05 12:32+0000\n" | |
12 | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
13 | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
14 | 15 | "Language: \n" |
... | ... | @@ -17,34 +18,44 @@ msgstr "" |
17 | 18 | "Content-Transfer-Encoding: 8bit\n" |
18 | 19 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" |
19 | 20 | |
20 | -#: plugins/context_content/lib/context_content_plugin.rb:8 | |
21 | +#: ../lib/context_content_plugin.rb:8 | |
21 | 22 | msgid "A plugin that display content based on page context." |
22 | 23 | msgstr "" |
23 | 24 | |
24 | -#: plugins/context_content/lib/context_content_plugin/context_content_block.rb:16 | |
25 | +#: ../lib/context_content_plugin/context_content_block.rb:17 | |
25 | 26 | msgid "Display context content" |
26 | 27 | msgstr "" |
27 | 28 | |
28 | -#: plugins/context_content/lib/context_content_plugin/context_content_block.rb:20 | |
29 | +#: ../lib/context_content_plugin/context_content_block.rb:21 | |
29 | 30 | msgid "This block displays content based on context." |
30 | 31 | msgstr "" |
31 | 32 | |
32 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:3 | |
33 | +#: | |
34 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:3 | |
33 | 35 | msgid "Show content name" |
34 | 36 | msgstr "" |
35 | 37 | |
36 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:4 | |
38 | +#: | |
39 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:4 | |
37 | 40 | msgid "Show content image" |
38 | 41 | msgstr "" |
39 | 42 | |
40 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:5 | |
41 | -msgid "Show parent content when children is empty" | |
43 | +#: | |
44 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:5 | |
45 | +msgid "Use the name of the source folder as block title" | |
42 | 46 | msgstr "" |
43 | 47 | |
44 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:8 | |
48 | +#: | |
49 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:6 | |
50 | +msgid "Show block on all existing pages in the source folder" | |
51 | +msgstr "" | |
52 | + | |
53 | +#: | |
54 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:9 | |
45 | 55 | msgid "Display content types:" |
46 | 56 | msgstr "" |
47 | 57 | |
48 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:14 | |
58 | +#: | |
59 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:15 | |
49 | 60 | msgid "more" |
50 | 61 | msgstr "" | ... | ... |
plugins/context_content/po/pt/context_content.po
... | ... | @@ -12,11 +12,11 @@ |
12 | 12 | msgid "" |
13 | 13 | msgstr "" |
14 | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | -"POT-Creation-Date: 2015-10-30 16:35-0300\n" | |
15 | +"POT-Creation-Date: 2016-01-05 12:32+0000\n" | |
16 | 16 | "PO-Revision-Date: 2014-12-18 18:40-0200\n" |
17 | 17 | "Last-Translator: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>\n" |
18 | -"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/" | |
19 | -"noosfero/pt/>\n" | |
18 | +"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/noosfe" | |
19 | +"ro/pt/>\n" | |
20 | 20 | "Language: pt\n" |
21 | 21 | "MIME-Version: 1.0\n" |
22 | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
... | ... | @@ -24,34 +24,49 @@ msgstr "" |
24 | 24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" |
25 | 25 | "X-Generator: Weblate 2.0\n" |
26 | 26 | |
27 | -#: plugins/context_content/lib/context_content_plugin.rb:8 | |
27 | +#: ../lib/context_content_plugin.rb:8 | |
28 | 28 | msgid "A plugin that display content based on page context." |
29 | 29 | msgstr "Um plugin que mostra conteúdo baseado do contexto da página." |
30 | 30 | |
31 | -#: plugins/context_content/lib/context_content_plugin/context_content_block.rb:16 | |
31 | +#: ../lib/context_content_plugin/context_content_block.rb:17 | |
32 | 32 | msgid "Display context content" |
33 | 33 | msgstr "Mostrar conteúdo contextual" |
34 | 34 | |
35 | -#: plugins/context_content/lib/context_content_plugin/context_content_block.rb:20 | |
35 | +#: ../lib/context_content_plugin/context_content_block.rb:21 | |
36 | 36 | msgid "This block displays content based on context." |
37 | 37 | msgstr "Este bloco apresenta conteúdo baseado no contexto." |
38 | 38 | |
39 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:3 | |
39 | +#: | |
40 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:3 | |
40 | 41 | msgid "Show content name" |
41 | 42 | msgstr "Mostrar o nome do conteúdo" |
42 | 43 | |
43 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:4 | |
44 | +#: | |
45 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:4 | |
44 | 46 | msgid "Show content image" |
45 | 47 | msgstr "Mostrar imagem do conteúdo" |
46 | 48 | |
47 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:5 | |
48 | -msgid "Show parent content when children is empty" | |
49 | -msgstr "Mostrar conteúdo do pai quando os filhos estão vazios" | |
49 | +#: | |
50 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:5 | |
51 | +msgid "Use the name of the source folder as block title" | |
52 | +msgstr "Usar o nome da pasta de origem como título do bloco" | |
53 | + | |
54 | +#: | |
55 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:6 | |
56 | +msgid "Show block on all existing pages in the source folder" | |
57 | +msgstr "Exibir o bloco em todas as páginas existentes na pasta de origem" | |
50 | 58 | |
51 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:8 | |
59 | +#: | |
60 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:9 | |
52 | 61 | msgid "Display content types:" |
53 | 62 | msgstr "Mostrar tipos de conteúdos:" |
54 | 63 | |
55 | -#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:14 | |
64 | +#: | |
65 | +#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:15 | |
56 | 66 | msgid "more" |
57 | 67 | msgstr "mais" |
68 | + | |
69 | +#: | |
70 | +#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:5 | |
71 | +#~ msgid "Show parent content when children is empty" | |
72 | +#~ msgstr "Mostrar conteúdo do pai quando os filhos estão vazios" | ... | ... |
plugins/context_content/test/functional/content_viewer_controller_test.rb
... | ... | @@ -4,12 +4,13 @@ class ContentViewerControllerTest < ActionController::TestCase |
4 | 4 | |
5 | 5 | def setup |
6 | 6 | @profile = fast_create(Community) |
7 | - @page = fast_create(Folder, :profile_id => @profile.id) | |
7 | + @page = fast_create(Folder, :profile_id => @profile.id, :name => "New Folder") | |
8 | 8 | |
9 | 9 | box = Box.create!(:owner => @profile) |
10 | 10 | @block = ContextContentPlugin::ContextContentBlock.new(:box_id => box.id) |
11 | 11 | @block.types = ['TinyMceArticle'] |
12 | 12 | @block.limit = 1 |
13 | + @block.title = "New Context Block" | |
13 | 14 | @block.save! |
14 | 15 | end |
15 | 16 | |
... | ... | @@ -27,6 +28,24 @@ class ContentViewerControllerTest < ActionController::TestCase |
27 | 28 | assert_match /article1/, @response.body |
28 | 29 | end |
29 | 30 | |
31 | + should 'display context content block title if it is not configured to use_parent_title' do | |
32 | + @block.use_parent_title = false | |
33 | + @block.save | |
34 | + article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') | |
35 | + get :view_page, @page.url | |
36 | + assert_tag 'h3', :attributes => {:class => 'block-title'}, :content => @block.title | |
37 | + assert_no_tag 'h3', :attributes => {:class => 'block-title'}, :content => @page.name | |
38 | + end | |
39 | + | |
40 | + should 'display context content with folder title if it is configured to use_parent_title' do | |
41 | + @block.use_parent_title = true | |
42 | + @block.save | |
43 | + article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1') | |
44 | + get :view_page, @page.url | |
45 | + assert_tag 'h3', :attributes => {:class => 'block-title'}, :content => @page.name | |
46 | + assert_no_tag 'h3', :attributes => {:class => 'block-title'}, :content => @block.title | |
47 | + end | |
48 | + | |
30 | 49 | should 'display context content block with pagination' do |
31 | 50 | article1 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id) |
32 | 51 | article2 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id) | ... | ... |
plugins/context_content/test/functional/profile_design_controller_test.rb
... | ... | @@ -27,6 +27,7 @@ class ProfileDesignControllerTest < ActionController::TestCase |
27 | 27 | assert_tag :tag => 'input', :attributes => { :id => 'block_title' } |
28 | 28 | assert_tag :tag => 'input', :attributes => { :id => 'block_show_image' } |
29 | 29 | assert_tag :tag => 'input', :attributes => { :id => 'block_show_name' } |
30 | + assert_tag :tag => 'input', :attributes => { :id => 'block_use_parent_title' } | |
30 | 31 | assert_tag :tag => 'input', :attributes => { :id => 'block_show_parent_content' } |
31 | 32 | assert_tag :tag => 'input', :attributes => { :name => 'block[types][]' } |
32 | 33 | end | ... | ... |
plugins/context_content/test/unit/context_content_block_test.rb
... | ... | @@ -27,9 +27,7 @@ class ContextContentBlockTest < ActiveSupport::TestCase |
27 | 27 | should 'render context content block view' do |
28 | 28 | @page = fast_create(Folder) |
29 | 29 | article = fast_create(TinyMceArticle, :parent_id => @page.id) |
30 | - expects(:block_title).with(@block.title).returns('').once | |
31 | - expects(:content_tag).returns('').once | |
32 | - expects(:render).with(:file => 'blocks/context_content', :locals => {:block => @block, :contents => [article]}) | |
30 | + expects(:render).with(:file => 'blocks/context_content', :locals => {:block => @block, :contents => [article], :parent_title => @page.name}) | |
33 | 31 | instance_eval(&@block.content) |
34 | 32 | end |
35 | 33 | |
... | ... | @@ -39,6 +37,16 @@ class ContextContentBlockTest < ActiveSupport::TestCase |
39 | 37 | assert_equal [article], @block.contents(folder) |
40 | 38 | end |
41 | 39 | |
40 | + should 'return parent name of the contents' do | |
41 | + folder = fast_create(Folder, :name => " New Folder") | |
42 | + article = fast_create(TinyMceArticle, :parent_id => folder.id) | |
43 | + assert_equal folder.name, @block.parent_title([article]) | |
44 | + end | |
45 | + | |
46 | + should 'return no parent name if there is no content' do | |
47 | + assert_nil @block.parent_title([]) | |
48 | + end | |
49 | + | |
42 | 50 | should 'limit number of children to display' do |
43 | 51 | @block.limit = 2 |
44 | 52 | folder = fast_create(Folder) | ... | ... |
plugins/context_content/views/blocks/context_content.html.erb
1 | -<% contents.each do |content| %> | |
2 | - <% content = FilePresenter.for(content) %> | |
3 | - <span class="item"> | |
4 | - <a href="<%= url_for(content.view_url) %>"> | |
5 | - <div class="image"> | |
6 | - <%= instance_eval(&block.content_image(content)) if block.show_image %> | |
7 | - </div> | |
8 | - <% if block.show_name %> | |
9 | - <div class="name"><%= content.name %></div> | |
10 | - <% end %> | |
11 | - </a> | |
12 | - </span> | |
1 | +<% if block.use_parent_title %> | |
2 | + <%= block_title(parent_title) %> | |
3 | +<% else %> | |
4 | + <%= block_title(block.title) %> | |
13 | 5 | <% end %> |
6 | + | |
7 | +<div class='contents' id='<%="context_content_#{block.id}"%>'> | |
8 | + <% contents.each do |content| %> | |
9 | + <% content = FilePresenter.for(content) %> | |
10 | + <span class="item"> | |
11 | + <a href="<%= url_for(content.view_url) %>"> | |
12 | + <div class="image"> | |
13 | + <%= instance_eval(&block.content_image(content)) if block.show_image %> | |
14 | + </div> | |
15 | + <% if block.show_name %> | |
16 | + <div class="name"><%= content.name %></div> | |
17 | + <% end %> | |
18 | + </a> | |
19 | + </span> | |
20 | + <% end %> | |
21 | +</div> | |
14 | 22 | \ No newline at end of file | ... | ... |
plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb
... | ... | @@ -2,7 +2,8 @@ |
2 | 2 | <%= labelled_form_field c_('Limit of items'), text_field(:block, :limit, :size => 3) %> |
3 | 3 | <%= labelled_form_field check_box(:block, :show_name) + _('Show content name'), '' %> |
4 | 4 | <%= labelled_form_field check_box(:block, :show_image) + _('Show content image'), '' %> |
5 | - <%= labelled_form_field check_box(:block, :show_parent_content) + _('Show parent content when children is empty'), '' %> | |
5 | + <%= labelled_form_field check_box(:block, :use_parent_title) + _('Use the name of the source folder as block title'), '' %> | |
6 | + <%= labelled_form_field check_box(:block, :show_parent_content) + _('Show block on all existing pages in the source folder'), '' %> | |
6 | 7 | |
7 | 8 | <br/> |
8 | 9 | <%= label :block, :types, _('Display content types:'), :class => 'formlabel' %> | ... | ... |