Commit bb680e0a authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents 4e172922 4c28a5ae
......@@ -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
......
......@@ -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 protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\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 ""
......@@ -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 <[email protected]>\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"
......@@ -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)
......
......@@ -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
......
......@@ -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)
......
<% 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
......@@ -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' %>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment