Commit e91068dcdcd10b5f6faabf49aac32f871c50aa3a
Committed by
Arthur Esposte
1 parent
f81b2eaf
Exists in
master
and in
5 other branches
Add search catalog block
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
4 changed files
with
63 additions
and
1 deletions
Show diff stats
lib/mpog_software_plugin.rb
... | ... | @@ -127,7 +127,8 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
127 | 127 | DownloadBlock => {:type => [Community]}, |
128 | 128 | RepositoryBlock => {:type => [Community]}, |
129 | 129 | CategoriesAndTagsBlock => {:type => [Community]}, |
130 | - CategoriesSoftwareBlock => {:type => [Environment]} | |
130 | + CategoriesSoftwareBlock => {:type => [Environment]}, | |
131 | + SearchCatalogBlock => {:type => [Environment]} | |
131 | 132 | } |
132 | 133 | end |
133 | 134 | ... | ... |
... | ... | @@ -0,0 +1,30 @@ |
1 | +class SearchCatalogBlock < Block | |
2 | + | |
3 | + attr_accessible :show_name | |
4 | + | |
5 | + settings_items :show_name, :type => :boolean, :default => false | |
6 | + | |
7 | + def self.description | |
8 | + _('Search Softwares catalog') | |
9 | + end | |
10 | + | |
11 | + def help | |
12 | + _('This block displays the search categories field ') | |
13 | + | |
14 | + end | |
15 | + | |
16 | + def content(args={}) | |
17 | + block = self | |
18 | + s = show_name | |
19 | + lambda do |object| | |
20 | + render( | |
21 | + :file => 'blocks/search_catalog', | |
22 | + :locals => { :block => block, :show_name => s } | |
23 | + ) | |
24 | + end | |
25 | + end | |
26 | + | |
27 | + def cacheable? | |
28 | + false | |
29 | + end | |
30 | +end | ... | ... |
... | ... | @@ -0,0 +1,19 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | |
3 | + | |
4 | +class SearchCatalogBlockTest < ActiveSupport::TestCase | |
5 | + include PluginTestHelper | |
6 | + should 'inherit from Block' do | |
7 | + assert_kind_of Block, SearchCatalogBlock.new | |
8 | + end | |
9 | + | |
10 | + should 'declare its default title' do | |
11 | + SearchCatalogBlock.any_instance.stubs(:profile_count).returns(0) | |
12 | + assert_equal Block.new.default_title, SearchCatalogBlock.new.default_title | |
13 | + end | |
14 | + | |
15 | + should 'describe itself' do | |
16 | + assert_not_equal Block.description, SearchCatalogBlock.description | |
17 | + end | |
18 | + | |
19 | +end | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +<div id="catalogo-software-search"> | |
2 | + <h1><%= _("Catalog of Public Software") %></h1> | |
3 | + <%= form_tag(controller: "search", action: "software_infos", method: "get") do %> | |
4 | + <%= text_field(:query, "software", :placeholder => "e.g: control, municipal or java", :class=>"searchField", :id=>"search-Gadget") %> | |
5 | + <%= submit_tag("Search", {:class=>"searchButton-catalog"})%> | |
6 | + <% end %> | |
7 | + | |
8 | + <div id="search-catalog-footer"> | |
9 | + <p><%= _("Access the complete catalog")%> | |
10 | + <%= link_to "", "/search/software_infos" , {:id => "bt_catalog-search"}%></p> | |
11 | + </div> | |
12 | +</div> | ... | ... |