[Git][noosfero/noosfero][master] 2 commits: Add option to context_content to use parent folder name instead of block title
Daniela Feitosa
gitlab at mg.gitlab.com
Tue Jan 5 11:15:29 BRST 2016
Daniela Feitosa pushed to branch master at Noosfero / noosfero
Commits:
c0a1a0bd by Arthur Del Esposte at 2016-01-05T10:07:45Z
Add option to context_content to use parent folder name instead of block title
Also: Improve ContextContent plugin's view text
See merge request !713
- - - - -
4c28a5ae by Daniela Soares Feitosa at 2016-01-05T10:08:36Z
Update ContextContent plugin's translations
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
- - - - -
8 changed files:
- plugins/context_content/lib/context_content_plugin/context_content_block.rb
- plugins/context_content/po/context_content.pot
- plugins/context_content/po/pt/context_content.po
- plugins/context_content/test/functional/content_viewer_controller_test.rb
- plugins/context_content/test/functional/profile_design_controller_test.rb
- plugins/context_content/test/unit/context_content_block_test.rb
- plugins/context_content/views/blocks/context_content.html.erb
- plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb
Changes:
=====================================
plugins/context_content/lib/context_content_plugin/context_content_block.rb
=====================================
--- a/plugins/context_content/lib/context_content_plugin/context_content_block.rb
+++ b/plugins/context_content/lib/context_content_plugin/context_content_block.rb
@@ -2,11 +2,12 @@ class ContextContentPlugin::ContextContentBlock < Block
settings_items :show_name, :type => :boolean, :default => true
settings_items :show_image, :type => :boolean, :default => true
+ settings_items :use_parent_title, :type => :boolean, :default => false
settings_items :show_parent_content, :type => :boolean, :default => true
settings_items :types, :type => Array, :default => ['UploadedFile']
settings_items :limit, :type => :integer, :default => 6
- attr_accessible :show_image, :show_name, :show_parent_content, :types
+ attr_accessible :show_image, :show_name, :use_parent_title, :show_parent_content, :types
alias :profile :owner
@@ -65,6 +66,11 @@ class ContextContentPlugin::ContextContentBlock < Block
end
end
+ def parent_title(contents)
+ return nil if contents.blank?
+ contents.first.parent.name
+ end
+
def footer
block = self
proc do
@@ -82,9 +88,9 @@ class ContextContentPlugin::ContextContentBlock < Block
block = self
proc do
contents = block.contents(@page)
+ parent_title = block.parent_title(contents)
if !contents.blank?
- block_title(block.title) + content_tag('div',
- render(:file => 'blocks/context_content', :locals => {:block => block, :contents => contents}), :class => 'contents', :id => "context_content_#{block.id}")
+ render(:file => 'blocks/context_content', :locals => {:block => block, :contents => contents, :parent_title => parent_title})
else
''
end
=====================================
plugins/context_content/po/context_content.pot
=====================================
--- a/plugins/context_content/po/context_content.pot
+++ b/plugins/context_content/po/context_content.pot
@@ -6,9 +6,10 @@
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: 1.3~rc2-1-ga15645d\n"
-"POT-Creation-Date: 2015-10-30 16:35-0300\n"
-"PO-Revision-Date: 2015-08-06 17:21-0300\n"
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-01-05 12:32+0000\n"
+"PO-Revision-Date: 2016-01-05 12:32+0000\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
"Language: \n"
@@ -17,34 +18,44 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-#: plugins/context_content/lib/context_content_plugin.rb:8
+#: ../lib/context_content_plugin.rb:8
msgid "A plugin that display content based on page context."
msgstr ""
-#: plugins/context_content/lib/context_content_plugin/context_content_block.rb:16
+#: ../lib/context_content_plugin/context_content_block.rb:17
msgid "Display context content"
msgstr ""
-#: plugins/context_content/lib/context_content_plugin/context_content_block.rb:20
+#: ../lib/context_content_plugin/context_content_block.rb:21
msgid "This block displays content based on context."
msgstr ""
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:3
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:3
msgid "Show content name"
msgstr ""
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:4
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:4
msgid "Show content image"
msgstr ""
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:5
-msgid "Show parent content when children is empty"
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:5
+msgid "Use the name of the source folder as block title"
msgstr ""
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:8
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:6
+msgid "Show block on all existing pages in the source folder"
+msgstr ""
+
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:9
msgid "Display content types:"
msgstr ""
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:14
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:15
msgid "more"
msgstr ""
=====================================
plugins/context_content/po/pt/context_content.po
=====================================
--- a/plugins/context_content/po/pt/context_content.po
+++ b/plugins/context_content/po/pt/context_content.po
@@ -12,11 +12,11 @@
msgid ""
msgstr ""
"Project-Id-Version: 1.3~rc2-1-ga15645d\n"
-"POT-Creation-Date: 2015-10-30 16:35-0300\n"
+"POT-Creation-Date: 2016-01-05 12:32+0000\n"
"PO-Revision-Date: 2014-12-18 18:40-0200\n"
"Last-Translator: Luciano Prestes Cavalcanti <lucianopcbr at gmail.com>\n"
-"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/"
-"noosfero/pt/>\n"
+"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/noosfe"
+"ro/pt/>\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -24,34 +24,49 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 2.0\n"
-#: plugins/context_content/lib/context_content_plugin.rb:8
+#: ../lib/context_content_plugin.rb:8
msgid "A plugin that display content based on page context."
msgstr "Um plugin que mostra conteúdo baseado do contexto da página."
-#: plugins/context_content/lib/context_content_plugin/context_content_block.rb:16
+#: ../lib/context_content_plugin/context_content_block.rb:17
msgid "Display context content"
msgstr "Mostrar conteúdo contextual"
-#: plugins/context_content/lib/context_content_plugin/context_content_block.rb:20
+#: ../lib/context_content_plugin/context_content_block.rb:21
msgid "This block displays content based on context."
msgstr "Este bloco apresenta conteúdo baseado no contexto."
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:3
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:3
msgid "Show content name"
msgstr "Mostrar o nome do conteúdo"
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:4
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:4
msgid "Show content image"
msgstr "Mostrar imagem do conteúdo"
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:5
-msgid "Show parent content when children is empty"
-msgstr "Mostrar conteúdo do pai quando os filhos estão vazios"
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:5
+msgid "Use the name of the source folder as block title"
+msgstr "Usar o nome da pasta de origem como título do bloco"
+
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:6
+msgid "Show block on all existing pages in the source folder"
+msgstr "Exibir o bloco em todas as páginas existentes na pasta de origem"
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:8
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:9
msgid "Display content types:"
msgstr "Mostrar tipos de conteúdos:"
-#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:14
+#:
+#: ../views/box_organizer/context_content_plugin/_context_content_block.html.erb:15
msgid "more"
msgstr "mais"
+
+#:
+#: plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb:5
+#~ msgid "Show parent content when children is empty"
+#~ msgstr "Mostrar conteúdo do pai quando os filhos estão vazios"
=====================================
plugins/context_content/test/functional/content_viewer_controller_test.rb
=====================================
--- a/plugins/context_content/test/functional/content_viewer_controller_test.rb
+++ b/plugins/context_content/test/functional/content_viewer_controller_test.rb
@@ -4,12 +4,13 @@ class ContentViewerControllerTest < ActionController::TestCase
def setup
@profile = fast_create(Community)
- @page = fast_create(Folder, :profile_id => @profile.id)
+ @page = fast_create(Folder, :profile_id => @profile.id, :name => "New Folder")
box = Box.create!(:owner => @profile)
@block = ContextContentPlugin::ContextContentBlock.new(:box_id => box.id)
@block.types = ['TinyMceArticle']
@block.limit = 1
+ @block.title = "New Context Block"
@block.save!
end
@@ -27,6 +28,24 @@ class ContentViewerControllerTest < ActionController::TestCase
assert_match /article1/, @response.body
end
+ should 'display context content block title if it is not configured to use_parent_title' do
+ @block.use_parent_title = false
+ @block.save
+ article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1')
+ get :view_page, @page.url
+ assert_tag 'h3', :attributes => {:class => 'block-title'}, :content => @block.title
+ assert_no_tag 'h3', :attributes => {:class => 'block-title'}, :content => @page.name
+ end
+
+ should 'display context content with folder title if it is configured to use_parent_title' do
+ @block.use_parent_title = true
+ @block.save
+ article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1')
+ get :view_page, @page.url
+ assert_tag 'h3', :attributes => {:class => 'block-title'}, :content => @page.name
+ assert_no_tag 'h3', :attributes => {:class => 'block-title'}, :content => @block.title
+ end
+
should 'display context content block with pagination' do
article1 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id)
article2 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id)
=====================================
plugins/context_content/test/functional/profile_design_controller_test.rb
=====================================
--- a/plugins/context_content/test/functional/profile_design_controller_test.rb
+++ b/plugins/context_content/test/functional/profile_design_controller_test.rb
@@ -27,6 +27,7 @@ class ProfileDesignControllerTest < ActionController::TestCase
assert_tag :tag => 'input', :attributes => { :id => 'block_title' }
assert_tag :tag => 'input', :attributes => { :id => 'block_show_image' }
assert_tag :tag => 'input', :attributes => { :id => 'block_show_name' }
+ assert_tag :tag => 'input', :attributes => { :id => 'block_use_parent_title' }
assert_tag :tag => 'input', :attributes => { :id => 'block_show_parent_content' }
assert_tag :tag => 'input', :attributes => { :name => 'block[types][]' }
end
=====================================
plugins/context_content/test/unit/context_content_block_test.rb
=====================================
--- a/plugins/context_content/test/unit/context_content_block_test.rb
+++ b/plugins/context_content/test/unit/context_content_block_test.rb
@@ -27,9 +27,7 @@ class ContextContentBlockTest < ActiveSupport::TestCase
should 'render context content block view' do
@page = fast_create(Folder)
article = fast_create(TinyMceArticle, :parent_id => @page.id)
- expects(:block_title).with(@block.title).returns('').once
- expects(:content_tag).returns('').once
- expects(:render).with(:file => 'blocks/context_content', :locals => {:block => @block, :contents => [article]})
+ expects(:render).with(:file => 'blocks/context_content', :locals => {:block => @block, :contents => [article], :parent_title => @page.name})
instance_eval(&@block.content)
end
@@ -39,6 +37,16 @@ class ContextContentBlockTest < ActiveSupport::TestCase
assert_equal [article], @block.contents(folder)
end
+ should 'return parent name of the contents' do
+ folder = fast_create(Folder, :name => " New Folder")
+ article = fast_create(TinyMceArticle, :parent_id => folder.id)
+ assert_equal folder.name, @block.parent_title([article])
+ end
+
+ should 'return no parent name if there is no content' do
+ assert_nil @block.parent_title([])
+ end
+
should 'limit number of children to display' do
@block.limit = 2
folder = fast_create(Folder)
=====================================
plugins/context_content/views/blocks/context_content.html.erb
=====================================
--- a/plugins/context_content/views/blocks/context_content.html.erb
+++ b/plugins/context_content/views/blocks/context_content.html.erb
@@ -1,13 +1,21 @@
-<% contents.each do |content| %>
- <% content = FilePresenter.for(content) %>
- <span class="item">
- <a href="<%= url_for(content.view_url) %>">
- <div class="image">
- <%= instance_eval(&block.content_image(content)) if block.show_image %>
- </div>
- <% if block.show_name %>
- <div class="name"><%= content.name %></div>
- <% end %>
- </a>
- </span>
+<% if block.use_parent_title %>
+ <%= block_title(parent_title) %>
+<% else %>
+ <%= block_title(block.title) %>
<% end %>
+
+<div class='contents' id='<%="context_content_#{block.id}"%>'>
+ <% contents.each do |content| %>
+ <% content = FilePresenter.for(content) %>
+ <span class="item">
+ <a href="<%= url_for(content.view_url) %>">
+ <div class="image">
+ <%= instance_eval(&block.content_image(content)) if block.show_image %>
+ </div>
+ <% if block.show_name %>
+ <div class="name"><%= content.name %></div>
+ <% end %>
+ </a>
+ </span>
+ <% end %>
+</div>
\ No newline at end of file
=====================================
plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb
=====================================
--- a/plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb
+++ b/plugins/context_content/views/box_organizer/context_content_plugin/_context_content_block.html.erb
@@ -2,7 +2,8 @@
<%= labelled_form_field c_('Limit of items'), text_field(:block, :limit, :size => 3) %>
<%= labelled_form_field check_box(:block, :show_name) + _('Show content name'), '' %>
<%= labelled_form_field check_box(:block, :show_image) + _('Show content image'), '' %>
- <%= labelled_form_field check_box(:block, :show_parent_content) + _('Show parent content when children is empty'), '' %>
+ <%= labelled_form_field check_box(:block, :use_parent_title) + _('Use the name of the source folder as block title'), '' %>
+ <%= labelled_form_field check_box(:block, :show_parent_content) + _('Show block on all existing pages in the source folder'), '' %>
<br/>
<%= label :block, :types, _('Display content types:'), :class => 'formlabel' %>
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/1e450b5b4204722870e87e0b8a062f53e603343f...4c28a5aea7b2b35f86ebb1d9ae458c42ce51a46c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160105/886086b1/attachment-0001.html>
More information about the Noosfero-dev
mailing list