Commit 80cb621a5316e7d8a27cd334c34cde985fb11b96
1 parent
4399cbfe
Exists in
master
and in
5 other branches
Add Categories and Tags block
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
5 changed files
with
65 additions
and
2 deletions
Show diff stats
| @@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
| 1 | +class CategoriesAndTagsBlock < Block | ||
| 2 | + | ||
| 3 | + attr_accessible :show_name | ||
| 4 | + | ||
| 5 | + settings_items :show_name, :type => :boolean, :default => false | ||
| 6 | + | ||
| 7 | + def self.description | ||
| 8 | + _('Categories and Tags') | ||
| 9 | + end | ||
| 10 | + | ||
| 11 | + def help | ||
| 12 | + _('This block displays the categories and tags of a software.') | ||
| 13 | + end | ||
| 14 | + | ||
| 15 | + def content(args={}) | ||
| 16 | + block = self | ||
| 17 | + s = show_name | ||
| 18 | + lambda do |object| | ||
| 19 | + render( | ||
| 20 | + :file => 'blocks/categories_and_tags', | ||
| 21 | + :locals => { :block => block, :show_name => s } | ||
| 22 | + ) | ||
| 23 | + end | ||
| 24 | + end | ||
| 25 | + | ||
| 26 | + def cacheable? | ||
| 27 | + false | ||
| 28 | + end | ||
| 29 | +end |
lib/mpog_software_plugin.rb
| @@ -130,7 +130,8 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -130,7 +130,8 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
| 130 | SoftwareInformationBlock => {:type => [Community] }, | 130 | SoftwareInformationBlock => {:type => [Community] }, |
| 131 | InstitutionsBlock => {:type => [Environment, Person]}, | 131 | InstitutionsBlock => {:type => [Environment, Person]}, |
| 132 | DownloadBlock => {:type => [Community]}, | 132 | DownloadBlock => {:type => [Community]}, |
| 133 | - RepositoryBlock => {:type => [Community]} | 133 | + RepositoryBlock => {:type => [Community]}, |
| 134 | + CategoriesAndTagsBlock => {:type => [Community]} | ||
| 134 | } | 135 | } |
| 135 | end | 136 | end |
| 136 | 137 |
| @@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
| 1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
| 2 | +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
| 3 | + | ||
| 4 | +class CategoriesAndTagsBlockTest < ActiveSupport::TestCase | ||
| 5 | + include PluginTestHelper | ||
| 6 | + should 'inherit from Block' do | ||
| 7 | + assert_kind_of Block, CategoriesAndTagsBlock.new | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + should 'declare its default title' do | ||
| 11 | + CategoriesAndTagsBlock.any_instance.stubs(:profile_count).returns(0) | ||
| 12 | + assert_equal Block.new.default_title, CategoriesAndTagsBlock.new.default_title | ||
| 13 | + end | ||
| 14 | + | ||
| 15 | + should 'describe itself' do | ||
| 16 | + assert_not_equal Block.description, CategoriesAndTagsBlock.description | ||
| 17 | + end | ||
| 18 | + | ||
| 19 | +end |
| @@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
| 1 | +<h3 class="block-title"><span><%= _("Categories") %></span></h3> | ||
| 2 | + | ||
| 3 | +<div class="category_cloud"> | ||
| 4 | +<% block.owner.categories.each do |category| %> | ||
| 5 | + <%= link_to category.name , category.path, :id => "select-category-1-link", :class => "select-subcategory-link", :target => "_blank" %> | ||
| 6 | +<% end %> | ||
| 7 | +</div><!-- end class='category_cloud' --> | ||
| 8 | + | ||
| 9 | +<h3 class="block-title"><span><%= _("Tags") %></span></h3> | ||
| 10 | +<div class="tag_cloud"> | ||
| 11 | +<% block.owner.tag_list.each do |tag| %> | ||
| 12 | + <%= link_to tag , "#", :id => "select-category-1-link", :class => "select-subcategory-link"%> | ||
| 13 | +<% end %> | ||
| 14 | +</div> | ||
| 0 | \ No newline at end of file | 15 | \ No newline at end of file |
views/blocks/repository.html.erb
| 1 | -<%= link_to _("Repositorio") , block.link, :id => "bt_repositorio", :target => "_blank" %> | ||
| 2 | \ No newline at end of file | 1 | \ No newline at end of file |
| 2 | +<%= link_to _("Repository") , block.link, :id => "bt_repositorio", :target => "_blank" %> | ||
| 3 | \ No newline at end of file | 3 | \ No newline at end of file |