diff --git a/lib/ext/search_controller.rb b/lib/ext/search_controller.rb index a7ea144..405f1fa 100644 --- a/lib/ext/search_controller.rb +++ b/lib/ext/search_controller.rb @@ -59,8 +59,14 @@ class SearchController def get_filtered_software_list params[:query] ||= "" + filtered_software_list = SoftwareInfo.search_by_query(params[:query]) + if params[:only_softwares] + params[:only_softwares].collect!{ |software_name| software_name.to_slug } + filtered_software_list = SoftwareInfo.all.select{ |s| params[:only_softwares].include?(s.identifier) } + end + category_ids = get_filter_category_ids unless category_ids.empty? diff --git a/lib/software_communities_plugin.rb b/lib/software_communities_plugin.rb index 68c6063..9340535 100644 --- a/lib/software_communities_plugin.rb +++ b/lib/software_communities_plugin.rb @@ -39,7 +39,8 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin RepositoryBlock => { :type => [Community] }, CategoriesAndTagsBlock => { :type => [Community] }, CategoriesSoftwareBlock => { :type => [Environment] }, - SearchCatalogBlock => { :type => [Environment] } + SearchCatalogBlock => { :type => [Environment] }, + SoftwareHighlightsBlock => { :type => [Environment] } } end diff --git a/lib/software_highlights_block.rb b/lib/software_highlights_block.rb new file mode 100644 index 0000000..a8b2a1c --- /dev/null +++ b/lib/software_highlights_block.rb @@ -0,0 +1,20 @@ +class SoftwareHighlightsBlock < HighlightsBlock + + def self.description + _('Software Highlights Block') + end + + def help + _('This block displays the softwares icon into a highlight') + end + + def content(args={}) + softwares = self.settings[:images].collect {|h| h[:address].split('/').last} + block = self + proc do + render :file => 'blocks/software_highlights', :locals => { :block => block, :softwares => softwares} + end + end + + +end diff --git a/views/blocks/software_highlights.html.erb b/views/blocks/software_highlights.html.erb new file mode 100644 index 0000000..985a50c --- /dev/null +++ b/views/blocks/software_highlights.html.erb @@ -0,0 +1,3 @@ +<%= render :file => 'blocks/highlights.html.erb', :locals => { :block => block } %> + +<%= link_to _('See all'), {:controller => :search, :action => :software_infos, :only_softwares => softwares} %> -- libgit2 0.21.2