diff --git a/lib/categories_and_tags_block.rb b/lib/categories_and_tags_block.rb new file mode 100644 index 0000000..e50f9c4 --- /dev/null +++ b/lib/categories_and_tags_block.rb @@ -0,0 +1,29 @@ +class CategoriesAndTagsBlock < Block + + attr_accessible :show_name + + settings_items :show_name, :type => :boolean, :default => false + + def self.description + _('Categories and Tags') + end + + def help + _('This block displays the categories and tags of a software.') + end + + def content(args={}) + block = self + s = show_name + lambda do |object| + render( + :file => 'blocks/categories_and_tags', + :locals => { :block => block, :show_name => s } + ) + end + end + + def cacheable? + false + end +end diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb index 159307f..dce2559 100644 --- a/lib/mpog_software_plugin.rb +++ b/lib/mpog_software_plugin.rb @@ -130,7 +130,8 @@ class MpogSoftwarePlugin < Noosfero::Plugin SoftwareInformationBlock => {:type => [Community] }, InstitutionsBlock => {:type => [Environment, Person]}, DownloadBlock => {:type => [Community]}, - RepositoryBlock => {:type => [Community]} + RepositoryBlock => {:type => [Community]}, + CategoriesAndTagsBlock => {:type => [Community]} } end diff --git a/test/unit/categories_and_tags_block_test.rb b/test/unit/categories_and_tags_block_test.rb new file mode 100644 index 0000000..a7e0bef --- /dev/null +++ b/test/unit/categories_and_tags_block_test.rb @@ -0,0 +1,19 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class CategoriesAndTagsBlockTest < ActiveSupport::TestCase + include PluginTestHelper + should 'inherit from Block' do + assert_kind_of Block, CategoriesAndTagsBlock.new + end + + should 'declare its default title' do + CategoriesAndTagsBlock.any_instance.stubs(:profile_count).returns(0) + assert_equal Block.new.default_title, CategoriesAndTagsBlock.new.default_title + end + + should 'describe itself' do + assert_not_equal Block.description, CategoriesAndTagsBlock.description + end + +end diff --git a/views/blocks/categories_and_tags.html.erb b/views/blocks/categories_and_tags.html.erb new file mode 100644 index 0000000..24f9c9f --- /dev/null +++ b/views/blocks/categories_and_tags.html.erb @@ -0,0 +1,14 @@ +

<%= _("Categories") %>

+ +
+<% block.owner.categories.each do |category| %> + <%= link_to category.name , category.path, :id => "select-category-1-link", :class => "select-subcategory-link", :target => "_blank" %> +<% end %> +
+ +

<%= _("Tags") %>

+
+<% block.owner.tag_list.each do |tag| %> + <%= link_to tag , "#", :id => "select-category-1-link", :class => "select-subcategory-link"%> +<% end %> +
\ No newline at end of file diff --git a/views/blocks/repository.html.erb b/views/blocks/repository.html.erb index 47968b0..151c943 100644 --- a/views/blocks/repository.html.erb +++ b/views/blocks/repository.html.erb @@ -1 +1 @@ -<%= link_to _("Repositorio") , block.link, :id => "bt_repositorio", :target => "_blank" %> \ No newline at end of file +<%= link_to _("Repository") , block.link, :id => "bt_repositorio", :target => "_blank" %> \ No newline at end of file -- libgit2 0.21.2