+ <%= text_field_tag :search_query, params[:search_query] %> + <%= submit_tag "Search", name: nil %> +
+<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index a9f1c496..ce6c5ec3 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -44,6 +44,7 @@ Rails.application.routes.draw do match "reload_bulletins" => "bulletins#reload_bulletins" match "reload_web_links" => "bulletins#reload_web_links" match "bulletins_side_bar" => "bulletins#bulletins_side_bar" + match "bulletins_search_block" => "bulletins#bulletins_search_block" end end end diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb index e43e90d1..540f33b2 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb @@ -10,21 +10,10 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController def index if !params[:search_query].blank? - search_query =params[:search_query].gsub(/"/,"").split(" ") - - words_query = lambda do |boolean| - search_query.each do |word| - boolean.should { string "title:#{word}" } - #boolean.should { string "sub_title:#{word}" } - #boolean.should { string "text:#{word}" } - end - end - - search_result=Tire.search('news_bulletins') do - query {boolean &words_query } - #raise to_curl - end.results.collect{|t| t.id} - + search_cond = {:is_checked=>true,:is_hidden=>false} + search_cond.merge!({:news_bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank? + search = Redis::Search.query("NewsBulletin", params[:search_query], :conditions =>search_cond) + search_result = search.collect{|t| t["id"]} @news_bulletins = NewsBulletin.all.can_display.any_in(_id:search_result).page( params[:page_main]).per(10) else date_now = Time.now @@ -50,7 +39,7 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController else @news_bulletin = NewsBulletin.all.can_display.where(_id: params[:id]).first unless @news_bulletin.disable? - impressionist(@news_bulletin) + # impressionist(@news_bulletin) get_categorys else render :nothing => true, :status => 403 diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb index 49b358df..3ad7e3ef 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb @@ -47,8 +47,9 @@ caches_page :home_banner get_categorys end - # def news_bulletins_search_block - # end + def news_bulletins_search_block + + end def home_banner if !params[:category_id].blank? diff --git a/vendor/built_in_modules/news/app/models/news_bulletin.rb b/vendor/built_in_modules/news/app/models/news_bulletin.rb index dbcd215c..97bc8dfa 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -4,6 +4,7 @@ class NewsBulletin include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + include Redis::Search include Impressionist::Impressionable BelongsToCategory = :news_bulletin_category @@ -16,7 +17,7 @@ class NewsBulletin scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false) - is_impressionable :counter_cache => { :column_name => :view_count } + # is_impressionable :counter_cache => { :column_name => :view_count } has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy @@ -89,32 +90,29 @@ class NewsBulletin "news_bulletin" end - def to_indexed_json - titles = title.zh_tw #+ title.en - sub_titles = subtitle.zh_tw #+ subtitle.en - texts = text.zh_tw #+ text.en - { - :_id => _id, - :title => Nokogiri::HTML(titles).text, - :sub_title => Nokogiri::HTML(sub_titles).text, - :text => Nokogiri::HTML(texts).text - }.to_json - end + redis_search_index(:title_field => :s_title, + :alias_field => :s_title_en, + :score_field => :view_count, + :condition_fields => [:is_checked,:is_hidden,:news_bulletin_category_id], + :ext_fields =>[]) +# def gen_title_for_search +# # [s_title,s_title_en,s_text_en,s_text_zh_tw].join(' ') +# end - def self.search( search = nil, category_id = nil ) - if category_id.to_s.size > 0 and search.to_s.size > 0 - key = /#{search}/ - find(:all, :conditions => {title: key, news_bulletin_category_id: category_id}).desc( :is_top, :postdate ) - elsif category_id.to_s.size > 0 and search.to_s.size < 1 - find(:all, :conditions => {news_bulletin_category_id: category_id}).desc( :is_top, :postdate ) - elsif search.to_s.size > 0 and category_id.to_s.size < 1 - key = /#{search}/ - find(:all, :conditions => {title: key}).desc( :is_top, :postdate ) - else - find(:all).desc( :is_top, :postdate) - end - end + def s_title + #self.title.zh_tw + end + def s_title_en + #self.title.en + end + + # def s_text_en + # Nokogiri::HTML(self.text.en).text + # end + # def s_text_zh_tw + # Nokogiri::HTML(self.text.zh_tw).text + # end def self.widget_datas( category_id = nil ) diff --git a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb index f3512afc..a1ff5639 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb @@ -1,6 +1,7 @@ <%= form_tag panel_news_front_end_news_bulletins_path, method: :get do %><%= text_field_tag :search_query, params[:search_query] %> + <%= hidden_field_tag :category_id, params[:category_id] %> <%= submit_tag "Search", name: nil %>
<% end %> \ No newline at end of file diff --git a/vendor/impressionist/Gemfile b/vendor/impressionist/Gemfile index e6cc394d..42fe3e34 100644 --- a/vendor/impressionist/Gemfile +++ b/vendor/impressionist/Gemfile @@ -7,7 +7,7 @@ platforms :jruby do end platforms :ruby, :mswin, :mingw do - # gem 'sqlite3' + gem 'sqlite3' end gemspec diff --git a/vendor/impressionist/app/models/impressionist/impressionable.rb b/vendor/impressionist/app/models/impressionist/impressionable.rb index 1df2f1c3..b4163054 100644 --- a/vendor/impressionist/app/models/impressionist/impressionable.rb +++ b/vendor/impressionist/app/models/impressionist/impressionable.rb @@ -29,22 +29,17 @@ module Impressionist end def impressionist_count(options={}) - # options.reverse_merge!(:filter=>:request_hash, :start_date=>nil, :end_date=>Time.now) - # imps = options[:start_date].blank? ? impressions : impressions.where("created_at>=? and created_at<=?",options[:start_date],options[:end_date]) - # options[:filter] == :all ? imps.count : imps.count(options[:filter], :distinct => true) - options.reverse_merge!(:filter => :request_hash, :start_date => nil, :end_date => Time.now) - imps = options[:start_date].blank? ? impressions : impressions.where(:created_at.gte => options[:start_date], :created_at.lte => options[:end_date]) - options[:filter] == :all ? imps.count : imps.distinct(options[:filter]).count + options.reverse_merge!(:filter=>:request_hash, :start_date=>nil, :end_date=>Time.now) + imps = options[:start_date].blank? ? impressions : impressions.where("created_at>=? and created_at<=?",options[:start_date],options[:end_date]) + options[:filter] == :all ? imps.count : imps.count(options[:filter], :distinct => true) end def update_impressionist_counter_cache - # cache_options = self.class.impressionist_counter_cache_options - # column_name = cache_options[:column_name].to_sym - # count = cache_options[:unique] ? impressionist_count(:filter => :ip_address) : impressionist_count - # update_attribute(column_name, count) cache_options = self.class.impressionist_counter_cache_options column_name = cache_options[:column_name].to_sym - update_attribute(column_name, self.send(cache_options[:column_name]) + 1) + count = cache_options[:unique] ? impressionist_count(:filter => :ip_address) : impressionist_count + old_count = send(column_name) || 0 + self.class.update_counters(id, column_name => (count - old_count)) end # OLD METHODS - DEPRECATE IN V0.5 diff --git a/vendor/impressionist/lib/generators/impressionist_generator.rb b/vendor/impressionist/lib/generators/impressionist_generator.rb index 30290af2..008f1ecf 100644 --- a/vendor/impressionist/lib/generators/impressionist_generator.rb +++ b/vendor/impressionist/lib/generators/impressionist_generator.rb @@ -7,6 +7,7 @@ module Impressionist def copy_config_file template 'impression.rb', 'config/initializers/impression.rb' end + end end end diff --git a/vendor/impressionist/lib/generators/templates/impression.rb b/vendor/impressionist/lib/generators/templates/impression.rb index fbdee915..5de89e47 100644 --- a/vendor/impressionist/lib/generators/templates/impression.rb +++ b/vendor/impressionist/lib/generators/templates/impression.rb @@ -1,5 +1,5 @@ # Use this hook to configure impressionist parameters Impressionist.setup do |config| - # Define ORM. Could be :active_record (default) and :mongo_mapper + # Define ORM. Could be :active_record (default), :mongo_mapper or :mongoid # config.orm = :active_record end diff --git a/vendor/impressionist/lib/impressionist/controllers/mongoid/impressionist_controller.rb b/vendor/impressionist/lib/impressionist/controllers/mongoid/impressionist_controller.rb new file mode 100644 index 00000000..426c5b86 --- /dev/null +++ b/vendor/impressionist/lib/impressionist/controllers/mongoid/impressionist_controller.rb @@ -0,0 +1,10 @@ +ImpressionistController::InstanceMethods.send(:define_method, :direct_create_statement) do |query_params={}| + # creates a statment hash that contains default values for creating an impression. + # if :impressionable_id is a valid ObjectId then convert it into one + base = (defined? Moped) ? Moped::BSON : BSON + query_params.reverse_merge!( + :impressionable_type => controller_name.singularize.camelize, + :impressionable_id=> !base::ObjectId.legal?(params[:id]) ? params[:id] : base::ObjectId.from_string(params[:id]) + ) + associative_create_statement(query_params) +end \ No newline at end of file diff --git a/vendor/impressionist/lib/impressionist/engine.rb b/vendor/impressionist/lib/impressionist/engine.rb index 8f953d75..fddb04f9 100644 --- a/vendor/impressionist/lib/impressionist/engine.rb +++ b/vendor/impressionist/lib/impressionist/engine.rb @@ -5,7 +5,7 @@ module Impressionist class Engine < Rails::Engine initializer 'impressionist.model' do |app| require "#{root}/app/models/impressionist/impressionable.rb" - if Impressionist.orm == :active_record + if Impressionist.orm == :active_record && defined? ActiveRecord require "impressionist/models/active_record/impression.rb" require "impressionist/models/active_record/impressionist/impressionable.rb" ActiveRecord::Base.send(:include, Impressionist::Impressionable) @@ -14,13 +14,16 @@ module Impressionist require "impressionist/models/mongo_mapper/impressionist/impressionable.rb" MongoMapper::Document.plugin Impressionist::Impressionable elsif Impressionist.orm == :mongoid - require "impressionist/models/mongoid/impression.rb" - require "impressionist/models/mongoid/impressionist/impressionable.rb" - # Mongoid::Document Impressionist::Impressionable + require 'impressionist/models/mongoid/impression.rb' + require 'impressionist/models/mongoid/impressionist/impressionable.rb' + Mongoid::Document.send(:include, Impressionist::Impressionable) end end initializer 'impressionist.controller' do + if Impressionist.orm == :mongoid + require 'impressionist/controllers/mongoid/impressionist_controller.rb' + end ActiveSupport.on_load(:action_controller) do include ImpressionistController::InstanceMethods extend ImpressionistController::ClassMethods diff --git a/vendor/impressionist/lib/impressionist/models/mongoid/impression.rb b/vendor/impressionist/lib/impressionist/models/mongoid/impression.rb index 9a2d958c..5c107857 100644 --- a/vendor/impressionist/lib/impressionist/models/mongoid/impression.rb +++ b/vendor/impressionist/lib/impressionist/models/mongoid/impression.rb @@ -2,8 +2,12 @@ class Impression include Mongoid::Document include Mongoid::Timestamps - field :impressionable_type - field :impressionable_id + attr_accessible :impressionable_type, :impressionable_field, :impressionable_id, :user_id, + :controller_name, :action_name, :view_name, :request_hash, :ip_address, + :session_hash, :message, :referrer + + belongs_to :impressionable, polymorphic: true + field :user_id field :controller_name field :action_name @@ -14,26 +18,15 @@ class Impression field :message field :referrer - belongs_to :impressionable, :polymorphic => true - - after_save :update_impressions_counter_cache - - def self.impressionist_count(options={}) - options.reverse_merge!(:filter => :request_hash, :start_date => nil, :end_date => Time.now) - imps = options[:start_date].blank? ? impressions : impressions.where(:created_at.gte => options[:start_date], :created_at.lte => options[:end_date]) - options[:filter] == :all ? imps.count : imps.distinct(options[:filter]).count - end - - private - - def update_impressions_counter_cache - if self.referrer - impressionable_class = self.impressionable_type.constantize + set_callback(:create, :after) do |doc| + unless impressionable_id.nil? + impressionable_class = doc.impressionable_type.constantize if impressionable_class.impressionist_counter_cache_options - resouce = impressionable_class.find(self.impressionable_id) - resouce.try(:update_impressionist_counter_cache) + resource = impressionable_class.find(doc.impressionable_id) + resource.try(:update_impressionist_counter_cache) end end end + end diff --git a/vendor/impressionist/lib/impressionist/models/mongoid/impressionist/impressionable.rb b/vendor/impressionist/lib/impressionist/models/mongoid/impressionist/impressionable.rb index 6100b886..5f04b03e 100644 --- a/vendor/impressionist/lib/impressionist/models/mongoid/impressionist/impressionable.rb +++ b/vendor/impressionist/lib/impressionist/models/mongoid/impressionist/impressionable.rb @@ -4,9 +4,49 @@ module Impressionist module ClassMethods def is_impressionable(options={}) - has_many :impressions, :as => :impressionable, :dependent => :destroy - @impressionist_cache_options = options[:counter_cache] + has_many :impressions, as: :impressionable, dependent: :destroy + @impressionist_cache_options = options[:counter_cache] + if !@impressionist_cache_options.nil? + opts = impressionist_counter_cache_options + field opts[:column_name], type: Integer + end + end + + def impressionist_counter_cache_options + if @impressionist_cache_options + options = { :column_name => :impressions_count, :unique => false } + options.merge!(@impressionist_cache_options) if @impressionist_cache_options.is_a?(Hash) + options + end + end + + def impressionist_counter_caching? + impressionist_counter_cache_options.present? + end + + def counter_caching? + ::ActiveSupport::Deprecation.warn("#counter_caching? is deprecated; please use #impressionist_counter_caching? instead") + impressionist_counter_caching? end end + + def impressionable? + true + end + + def impressionist_count(options={}) + options.reverse_merge!(:filter=>:request_hash, :start_date=>nil, :end_date=>Time.now) + imps = options[:start_date].blank? ? impressions : impressions.between(created_at: options[:start_date]..options[:end_date]) + options[:filter] == :all ? imps.count : imps.where(options[:filter].ne => nil).count + end + + def update_impressionist_counter_cache + cache_options = self.class.impressionist_counter_cache_options + column_name = cache_options[:column_name].to_sym + count = cache_options[:unique] ? impressionist_count(:filter => :ip_address) : impressionist_count + old_count = send(column_name) || 0 + self.inc(column_name, (count - old_count)) + end + end -end +end \ No newline at end of file diff --git a/vendor/impressionist/test_app/spec/models/counter_caching_spec.rb b/vendor/impressionist/test_app/spec/models/counter_caching_spec.rb index 552bf647..2f9636d4 100644 --- a/vendor/impressionist/test_app/spec/models/counter_caching_spec.rb +++ b/vendor/impressionist/test_app/spec/models/counter_caching_spec.rb @@ -38,6 +38,13 @@ describe Impression do @widget.reload }.should change(@widget, :impressions_count).from(0).to(1) end + + it "should not update the timestamp on the impressable" do + lambda { + @widget.impressions.create(:request_hash => 'abcd1234') + @widget.reload + }.should_not change(@widget, :updated_at) + end end end diff --git a/vendor/plugins/sunspot_mongoid/.document b/vendor/plugins/sunspot_mongoid/.document deleted file mode 100644 index ecf36731..00000000 --- a/vendor/plugins/sunspot_mongoid/.document +++ /dev/null @@ -1,5 +0,0 @@ -README.rdoc -lib/**/*.rb -bin/* -features/**/*.feature -LICENSE diff --git a/vendor/plugins/sunspot_mongoid/LICENSE b/vendor/plugins/sunspot_mongoid/LICENSE deleted file mode 100644 index 883f0922..00000000 --- a/vendor/plugins/sunspot_mongoid/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2009 jugyo - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/sunspot_mongoid/README.md b/vendor/plugins/sunspot_mongoid/README.md deleted file mode 100644 index 7c3c88fe..00000000 --- a/vendor/plugins/sunspot_mongoid/README.md +++ /dev/null @@ -1,53 +0,0 @@ -sunspot_mongoid -==== - -A Sunspot wrapper for Mongoid. - -Install ----- - - gem install sunspot_mongoid - -Examples ----- - - class Post - include Mongoid::Document - field :title - - include Sunspot::Mongoid - searchable do - text :title - end - end - -For Rails3 ----- - -### as gem: - -add a gem to Gemfile as following, - - gem 'sunspot_mongoid' - -### as plugin: - -add gems to Gemfile as following, - - gem 'sunspot' - gem 'sunspot_rails' - -and install sunspot_mongoid as rails plugin, - - rails plugin install git://github.com/jugyo/sunspot_mongoid.git - -Links ----- - -* [sunspot](http://github.com/outoftime/sunspot) -* [sunspot_rails](http://github.com/outoftime/sunspot/tree/master/sunspot_rails/) - -Copyright ----- - -Copyright (c) 2010 jugyo. See LICENSE for details. diff --git a/vendor/plugins/sunspot_mongoid/Rakefile b/vendor/plugins/sunspot_mongoid/Rakefile deleted file mode 100644 index bec1214b..00000000 --- a/vendor/plugins/sunspot_mongoid/Rakefile +++ /dev/null @@ -1,57 +0,0 @@ -require 'rubygems' -require 'rake' - -begin - require 'jeweler' - Jeweler::Tasks.new do |gem| - gem.name = "sunspot_mongoid" - gem.summary = %Q{A Sunspot wrapper for Mongoid.} - gem.description = %Q{A Sunspot wrapper for Mongoid that is like sunspot_rails.} - gem.email = "jugyo.org@gmail.com" - gem.homepage = "http://github.com/jugyo/sunspot_mongoid" - gem.authors = ["jugyo"] - gem.add_runtime_dependency "mongoid", ">= 0" - gem.add_runtime_dependency "sunspot", ">= 1.1.0" - gem.add_runtime_dependency "sunspot_rails", ">= 1.1.0" - gem.add_development_dependency "shoulda", ">= 0" - gem.add_development_dependency "rr", ">= 0" - # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings - end - Jeweler::GemcutterTasks.new -rescue LoadError - puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" -end - -require 'rake/testtask' -Rake::TestTask.new(:test) do |test| - test.libs << 'lib' << 'test' - test.pattern = 'test/**/test_*.rb' - test.verbose = true -end - -begin - require 'rcov/rcovtask' - Rcov::RcovTask.new do |test| - test.libs << 'test' - test.pattern = 'test/**/test_*.rb' - test.verbose = true - end -rescue LoadError - task :rcov do - abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" - end -end - -task :test => :check_dependencies - -task :default => :test - -require 'rake/rdoctask' -Rake::RDocTask.new do |rdoc| - version = File.exist?('VERSION') ? File.read('VERSION') : "" - - rdoc.rdoc_dir = 'rdoc' - rdoc.title = "sunspot_mongoid #{version}" - rdoc.rdoc_files.include('README*') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/sunspot_mongoid/VERSION b/vendor/plugins/sunspot_mongoid/VERSION deleted file mode 100644 index 267577d4..00000000 --- a/vendor/plugins/sunspot_mongoid/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.4.1 diff --git a/vendor/plugins/sunspot_mongoid/examples/example.rb b/vendor/plugins/sunspot_mongoid/examples/example.rb deleted file mode 100644 index 04f02e77..00000000 --- a/vendor/plugins/sunspot_mongoid/examples/example.rb +++ /dev/null @@ -1,36 +0,0 @@ -$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -require 'sunspot_mongoid' - -Mongoid.configure do |config| - config.master = Mongo::Connection.new.db('sunspot-mongoid-test') -end - -# model -class Post - include Mongoid::Document - field :title - - include Sunspot::Mongoid - searchable do - text :title - end -end - -# remove old indexes -Post.destroy_all - -# indexing -Post.create(:title => 'foo') -Post.create(:title => 'foo bar') -Post.create(:title => 'bar baz') - -# commit -Sunspot.commit - -# search -search = Post.search do - keywords 'foo' -end -search.each_hit_with_result do |hit, post| - p post -end diff --git a/vendor/plugins/sunspot_mongoid/init.rb b/vendor/plugins/sunspot_mongoid/init.rb deleted file mode 100644 index 341c6026..00000000 --- a/vendor/plugins/sunspot_mongoid/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'sunspot_mongoid' diff --git a/vendor/plugins/sunspot_mongoid/lib/sunspot/mongoid.rb b/vendor/plugins/sunspot_mongoid/lib/sunspot/mongoid.rb deleted file mode 100644 index a12703df..00000000 --- a/vendor/plugins/sunspot_mongoid/lib/sunspot/mongoid.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'sunspot' -require 'mongoid' -require 'sunspot/rails' - -# == Examples: -# -# class Post -# include Mongoid::Document -# field :title -# -# include Sunspot::Mongoid -# searchable do -# text :title -# end -# end -# -module Sunspot - module Mongoid - def self.included(base) - base.class_eval do - extend Sunspot::Rails::Searchable::ActsAsMethods - Sunspot::Adapters::DataAccessor.register(DataAccessor, base) - Sunspot::Adapters::InstanceAdapter.register(InstanceAdapter, base) - end - end - - class InstanceAdapter < Sunspot::Adapters::InstanceAdapter - def id - @instance.id - end - end - - class DataAccessor < Sunspot::Adapters::DataAccessor - def load(id) - criteria(id).first - end - - def load_all(ids) - criteria(ids) - end - - private - - def criteria(id) - @clazz.criteria.id(id) - end - end - end -end diff --git a/vendor/plugins/sunspot_mongoid/lib/sunspot_mongoid.rb b/vendor/plugins/sunspot_mongoid/lib/sunspot_mongoid.rb deleted file mode 100644 index 454e5da2..00000000 --- a/vendor/plugins/sunspot_mongoid/lib/sunspot_mongoid.rb +++ /dev/null @@ -1 +0,0 @@ -require 'sunspot/mongoid' diff --git a/vendor/plugins/sunspot_mongoid/sunspot_mongoid.gemspec b/vendor/plugins/sunspot_mongoid/sunspot_mongoid.gemspec deleted file mode 100644 index 968884cd..00000000 --- a/vendor/plugins/sunspot_mongoid/sunspot_mongoid.gemspec +++ /dev/null @@ -1,67 +0,0 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{sunspot_mongoid} - s.version = "0.4.1" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["jugyo"] - s.date = %q{2011-03-04} - s.description = %q{A Sunspot wrapper for Mongoid that is like sunspot_rails.} - s.email = %q{jugyo.org@gmail.com} - s.extra_rdoc_files = [ - "LICENSE", - "README.md" - ] - s.files = [ - ".document", - "LICENSE", - "README.md", - "Rakefile", - "VERSION", - "examples/example.rb", - "init.rb", - "lib/sunspot/mongoid.rb", - "lib/sunspot_mongoid.rb", - "sunspot_mongoid.gemspec", - "test/helper.rb", - "test/test_sunspot_mongoid.rb" - ] - s.homepage = %q{http://github.com/jugyo/sunspot_mongoid} - s.require_paths = ["lib"] - s.rubygems_version = %q{1.6.0} - s.summary = %q{A Sunspot wrapper for Mongoid.} - s.test_files = [ - "examples/example.rb", - "test/helper.rb", - "test/test_sunspot_mongoid.rb" - ] - - if s.respond_to? :specification_version then - s.specification_version = 3 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q