Commit cf443b587929c72c3dfec3561547bc2771e18593
Committed by
Álvaro Fernando Matos de Souza
1 parent
c27d0ec5
Exists in
master
and in
5 other branches
Add SoftwareHighlightBlock
Signed-off-by: Hebert Douglas <hebertdougl@gmail.com> Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Showing
4 changed files
with
31 additions
and
1 deletions
Show diff stats
lib/ext/search_controller.rb
| ... | ... | @@ -59,8 +59,14 @@ class SearchController |
| 59 | 59 | |
| 60 | 60 | def get_filtered_software_list |
| 61 | 61 | params[:query] ||= "" |
| 62 | + | |
| 62 | 63 | filtered_software_list = SoftwareInfo.search_by_query(params[:query]) |
| 63 | 64 | |
| 65 | + if params[:only_softwares] | |
| 66 | + params[:only_softwares].collect!{ |software_name| software_name.to_slug } | |
| 67 | + filtered_software_list = SoftwareInfo.all.select{ |s| params[:only_softwares].include?(s.identifier) } | |
| 68 | + end | |
| 69 | + | |
| 64 | 70 | category_ids = get_filter_category_ids |
| 65 | 71 | |
| 66 | 72 | unless category_ids.empty? | ... | ... |
lib/software_communities_plugin.rb
| ... | ... | @@ -39,7 +39,8 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin |
| 39 | 39 | RepositoryBlock => { :type => [Community] }, |
| 40 | 40 | CategoriesAndTagsBlock => { :type => [Community] }, |
| 41 | 41 | CategoriesSoftwareBlock => { :type => [Environment] }, |
| 42 | - SearchCatalogBlock => { :type => [Environment] } | |
| 42 | + SearchCatalogBlock => { :type => [Environment] }, | |
| 43 | + SoftwareHighlightsBlock => { :type => [Environment] } | |
| 43 | 44 | } |
| 44 | 45 | end |
| 45 | 46 | ... | ... |
| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | +class SoftwareHighlightsBlock < HighlightsBlock | |
| 2 | + | |
| 3 | + def self.description | |
| 4 | + _('Software Highlights Block') | |
| 5 | + end | |
| 6 | + | |
| 7 | + def help | |
| 8 | + _('This block displays the softwares icon into a highlight') | |
| 9 | + end | |
| 10 | + | |
| 11 | + def content(args={}) | |
| 12 | + softwares = self.settings[:images].collect {|h| h[:address].split('/').last} | |
| 13 | + block = self | |
| 14 | + proc do | |
| 15 | + render :file => 'blocks/software_highlights', :locals => { :block => block, :softwares => softwares} | |
| 16 | + end | |
| 17 | + end | |
| 18 | + | |
| 19 | + | |
| 20 | +end | ... | ... |