diff --git a/app/models/article.rb b/app/models/article.rb index aaa2b5c..d610dd4 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -125,8 +125,6 @@ class Article < ActiveRecord::Base acts_as_versioned - acts_as_searchable :additional_fields => [ :comment_data ] - def comment_data comments.map {|item| [item.title, item.body].join(' ') }.join(' ') end @@ -560,6 +558,32 @@ class Article < ActiveRecord::Base end private + def f_type + self.class.to_s + end + def f_publish_date + self.published_at + end + def f_profile_type + self.profile.class.to_s + end + def f_category + self.categories.collect(&:name) + end + public + + acts_as_faceted :fields => { + :f_type => {:label => _('Type')}, + :f_publish_date => {:label => _('Published')}, + :f_profile_type => {:label => _('Type of profile')}, + :f_category => {:label => _('Categories')}}, + :order => [:f_type, :f_publish_date, :f_profile_type, :f_category] + + acts_as_searchable :additional_fields => [ :comment_data, {:name => {:type => :string, :as => :name_sort, :boost => 5.0}} ] + facets.keys.map{|i| {i => :facet}}, + :include => [:profile], + :facets => facets.keys + + private def sanitize_tag_list sanitizer = HTML::FullSanitizer.new diff --git a/app/models/category.rb b/app/models/category.rb index ad6605f..02297c8 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -64,6 +64,10 @@ class Category < ActiveRecord::Base results end + def root_parent + parent_id.nil? ? self : Category.find_by_id(parent_id).root_parent + end + def is_leaf_displayable_in_menu? return false if self.display_in_menu == false self.children.find(:all, :conditions => {:display_in_menu => true}).empty? diff --git a/app/models/community.rb b/app/models/community.rb index 3c3f7e7..fa82efe 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -79,4 +79,25 @@ class Community < Organization {:title => __('Community Info and settings'), :icon => 'edit-profile-group'} end + private + def f_territory + categories.find(:all, :conditions => {:parent_id => 5}).collect(&:name) + end + def f_topic + categories.find(:all, :conditions => {:parent_id => 1}).collect(&:name) + end + def f_network + categories.find(:all, :conditions => {:parent_id => 9}).collect(&:name) + end + public + + acts_as_faceted :fields => { + :f_territory => {:label => _('Territories')}, + :f_topic => {:label => _('Thematics')}, + :f_network => {:label => _('Networks')}}, + :order => [:f_territory, :f_topic, :f_network] + + acts_as_searchable :additional_fields => [ :extra_data_for_index, {:name => {:type => :string, :as => :name_sort, :boost => 5.0}} ] + facets.keys.map{|i| {i => :facet}}, + :facets => facets.keys + end diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 280aba9..7b74af9 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -164,6 +164,27 @@ class Enterprise < Organization settings_items :enable_contact_us, :type => :boolean, :default => true + private + def f_territory + categories.find(:all, :conditions => {:parent_id => 5}).collect(&:name) + end + def f_topic + categories.find(:all, :conditions => {:parent_id => 1}).collect(&:name) + end + def f_network + categories.find(:all, :conditions => {:parent_id => 9}).collect(&:name) + end + public + + acts_as_faceted :fields => { + :f_territory => {:label => _('Territories')}, + :f_topic => {:label => _('Thematics')}, + :f_network => {:label => _('Networks')}}, + :order => [:f_territory, :f_topic, :f_network] + + acts_as_searchable :additional_fields => [ :extra_data_for_index, {:name => {:type => :string, :as => :name_sort, :boost => 5.0}} ] + facets.keys.map{|i| {i => :facet}}, + :facets => facets.keys + def enable_contact? enable_contact_us end diff --git a/app/models/environment.rb b/app/models/environment.rb index a72ea35..b3cbdeb 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -353,11 +353,11 @@ class Environment < ActiveRecord::Base end def terminology - if self.settings[:terminology] - self.settings[:terminology].constantize.instance - else + #if self.settings[:terminology] + #self.settings[:terminology].constantize.instance + #else Noosfero.terminology - end + #end end def terminology=(value) diff --git a/app/models/person.rb b/app/models/person.rb index 6c3c609..893ea7f 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -414,6 +414,27 @@ class Person < Profile user.save! end + private + def f_territory + categories.find(:all, :conditions => {:parent_id => 5}).collect(&:name) + end + def f_topic + categories.find(:all, :conditions => {:parent_id => 1}).collect(&:name) + end + def f_network + categories.find(:all, :conditions => {:parent_id => 9}).collect(&:name) + end + public + + acts_as_faceted :fields => { + :f_territory => {:label => _('Territories')}, + :f_topic => {:label => _('Thematics')}, + :f_network => {:label => _('Networks')}}, + :order => [:f_territory, :f_topic, :f_network] + + acts_as_searchable :additional_fields => [ :extra_data_for_index, {:name => {:type => :string, :as => :name_sort, :boost => 5.0}} ] + facets.keys.map{|i| {i => :facet}}, + :facets => facets.keys + protected def followed_by?(profile) diff --git a/app/models/profile.rb b/app/models/profile.rb index 4467bc6..a1e77e3 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -70,8 +70,6 @@ class Profile < ActiveRecord::Base acts_as_having_boxes - acts_as_searchable :additional_fields => [ :extra_data_for_index ] - acts_as_taggable def self.qualified_column_names @@ -177,6 +175,15 @@ class Profile < ActiveRecord::Base has_many :abuse_complaints, :foreign_key => 'requestor_id' + def top_level_categorization + ret = {} + self.profile_categorizations.each do |c| + p = c.category.root_parent + ret[p] = (ret[p] || []) + [c.category] + end + ret + end + def interests categories.select {|item| !item.is_a?(Region)} end diff --git a/app/views/search/_article.rhtml b/app/views/search/_article.rhtml index f2309da..be721cf 100644 --- a/app/views/search/_article.rhtml +++ b/app/views/search/_article.rhtml @@ -1,11 +1,21 @@ -