diff --git a/Gemfile b/Gemfile index 6eccd6005..4fa81c9d4 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem 'rake' gem 'resque' # background jobs gem 'resque-scheduler' # job scheduling gem 'resque-restriction' -gem 'rb-readline' +#gem 'rb-readline' gem 'ruby-debug19' gem 'rubyzip' gem 'therubyracer' @@ -37,6 +37,10 @@ gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") gem "impressionist", :require => "impressionist", :path => "vendor/impressionist" +# gem "tire" +gem 'sunspot_rails', "~> 1.3.2" +gem 'sunspot_solr' + # Gems used only for assets and not required # in production environments by default. group :assets do @@ -47,6 +51,7 @@ end group :test, :development do + gem "sunspot-rails-tester" gem 'spork' gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing. gem "rspec", "~> 2.0" diff --git a/Gemfile.lock b/Gemfile.lock index e21da8048..b65254879 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,6 +140,7 @@ GEM color (>= 1.4.0) transaction-simple (~> 1.3) polyglot (0.3.3) + pr_geohash (1.0.0) rack (1.3.6) rack-cache (1.2) rack (>= 0.4) @@ -168,7 +169,6 @@ GEM rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2.2) - rb-readline (0.4.2) rdoc (3.12) json (~> 1.4) redis (2.2.2) @@ -185,6 +185,8 @@ GEM redis (>= 2.0.1) resque (>= 1.8.0) rufus-scheduler + rsolr (1.0.8) + builder (>= 2.1.2) rspec (2.8.0) rspec-core (~> 2.8.0) rspec-expectations (~> 2.8.0) @@ -243,6 +245,15 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) subexec (0.2.1) + sunspot (1.3.3) + pr_geohash (~> 1.0) + rsolr (~> 1.0.7) + sunspot-rails-tester (0.0.4) + sunspot_rails (~> 1.2) + sunspot_rails (1.3.3) + nokogiri + sunspot (= 1.3.3) + sunspot_solr (1.3.3) therubyracer (0.9.9) libv8 (~> 3.3.10) thor (0.14.6) @@ -302,7 +313,6 @@ DEPENDENCIES radius rails (>= 3.1.0, < 3.2.0) rake - rb-readline resque resque-restriction resque-scheduler @@ -316,6 +326,9 @@ DEPENDENCIES sinatra spork sprockets + sunspot-rails-tester + sunspot_rails (~> 1.3.2) + sunspot_solr therubyracer tinymce-rails uglifier diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 8758563e8..7be301564 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -39,7 +39,9 @@ class PagesController < ApplicationController options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank? options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank? options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank? - redirect_to url + options + options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank? + uri = URI::escape(url + options) + redirect_to uri end def show_from_link diff --git a/app/jobs/backup_server.rb b/app/jobs/backup_server.rb index f600d3425..3f0ae6b71 100644 --- a/app/jobs/backup_server.rb +++ b/app/jobs/backup_server.rb @@ -2,11 +2,12 @@ class BackupServer @queue = :high def self.perform() - CronMail.time_check("Going to backup Orbit").deliver + #CronMail.time_check("Going to backup Orbit").deliver dbhost = Mongoid.config.database.connection.primary.join ':' dbname = Mongoid.config.database.name dbdirectory = "#{Rails.root}/tmp/#{dbname}-"+Time.now.strftime("%Y-%m-%d-%H-%M") - %x[mongodump -h dbhost -d dbname -o dbdirectory ] + %x[mongodump -h #{dbhost} -d #{dbname} -o #{dbdirectory} ] + # %x[touch #{Rails.root}/tmp/restart] end end diff --git a/app/models/ad_banner.rb b/app/models/ad_banner.rb index 18c6d4481..dcae4aea9 100644 --- a/app/models/ad_banner.rb +++ b/app/models/ad_banner.rb @@ -21,6 +21,8 @@ attr_writer :transition_sec APP_NAME = 'ad_banners' ObjectAuthTitlesOptions = %W{edit} + + def pp_object title end diff --git a/app/models/i18n_variable.rb b/app/models/i18n_variable.rb index 563ba791e..359a00cef 100644 --- a/app/models/i18n_variable.rb +++ b/app/models/i18n_variable.rb @@ -2,7 +2,7 @@ class I18nVariable include Mongoid::Document include Mongoid::Timestamps - + field :key field :document_class, :type => String field :parent_id, :type => BSON::ObjectId, :index => true diff --git a/app/models/mongoid/base_model.rb b/app/models/mongoid/base_model.rb new file mode 100644 index 000000000..6f6a3937e --- /dev/null +++ b/app/models/mongoid/base_model.rb @@ -0,0 +1,46 @@ +# coding: utf-8 +# 基本 Model,加入一些通用功能 +module Mongoid + module BaseModel + extend ActiveSupport::Concern + + included do + scope :recent, desc(:_id) + scope :exclude_ids, Proc.new { |ids| where(:_id.nin => ids.map(&:to_i)) } + scope :by_week, where(:created_at.gte => 7.days.ago.utc) + end + + module ClassMethods + # like ActiveRecord find_by_id + def find_by_id(id) + if id.is_a?(Integer) or id.is_a?(String) + where(:_id => id.to_i).first + else + nil + end + end + + def find_in_batches(opts = {}) + batch_size = opts[:batch_size] || 1000 + start = opts.delete(:start).to_i || 0 + objects = self.limit(batch_size).skip(start) + t = Time.new + while objects.any? + yield objects + start += batch_size + # Rails.logger.debug("processed #{start} records in #{Time.new - t} seconds") if Rails.logger.debug? + break if objects.size < batch_size + objects = self.limit(batch_size).skip(start) + end + end + + def delay + Sidekiq::Extensions::Proxy.new(DelayedDocument, self) + end + end + + def delay + Sidekiq::Extensions::Proxy.new(DelayedDocument, self) + end + end +end diff --git a/app/models/sunspot/mongoid.rb b/app/models/sunspot/mongoid.rb new file mode 100644 index 000000000..0f207c5a7 --- /dev/null +++ b/app/models/sunspot/mongoid.rb @@ -0,0 +1,46 @@ +# coding: utf-8 +# this is from : https://github.com/jugyo/sunspot_mongoid +# this file is special for mongoid_auto_increment_id +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) + @clazz.where(:_id => id).first + end + + def load_all(ids) + @clazz.where(:_id.in => ids.collect { |id| id.to_i }) + end + end + end +end diff --git a/config/sunspot.yml b/config/sunspot.yml new file mode 100644 index 000000000..79867b7a6 --- /dev/null +++ b/config/sunspot.yml @@ -0,0 +1,17 @@ +production: + solr: + hostname: localhost + port: 8983 + log_level: WARNING + +development: + solr: + hostname: localhost + port: 8983 + log_level: INFO + +test: + solr: + hostname: localhost + port: 8983 + log_level: WARNING \ No newline at end of file diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 000000000..0e889caea Binary files /dev/null and b/dump.rdb differ diff --git a/lib/orbit_basis.rb b/lib/orbit_basis.rb new file mode 100644 index 000000000..3e0ec976a --- /dev/null +++ b/lib/orbit_basis.rb @@ -0,0 +1,28 @@ +module OrbitBasis + module BaseModel + extend ActiveSupport::Concern + + # included do + # scope :recent, desc(:_id) + # scope :exclude_ids, Proc.new { |ids| where(:_id.nin => ids.map(&:to_i)) } + # scope :by_week, where(:created_at.gte => 7.days.ago.utc) + # end + + module ClassMethods + + def find_in_batches(opts = {}) + batch_size = opts[:batch_size] || 1000 + start = opts.delete(:start).to_i || 0 + objects = self.limit(batch_size).skip(start) + t = Time.new + while objects.any? + yield objects + start += batch_size + # Rails.logger.debug("processed #{start} records in #{Time.new - t} seconds") if Rails.logger.debug? + break if objects.size < batch_size + objects = self.limit(batch_size).skip(start) + end + end + end + end +end diff --git a/lib/orbit_search_lib.rb b/lib/orbit_search_lib.rb new file mode 100644 index 000000000..e98ecb536 --- /dev/null +++ b/lib/orbit_search_lib.rb @@ -0,0 +1,46 @@ +# coding: utf-8 +# this is from : https://github.com/jugyo/sunspot_mongoid +# this file is special for mongoid_auto_increment_id +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 OrbitSearchLib + module ObjectSearchable + 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) + @clazz.where(:_id => id).first + end + + def load_all(ids) + @clazz.where(:_id.in => ids.collect { |id| id.to_i }) + end + end + end +end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index f1387a93e..308620238 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -171,7 +171,7 @@ module ParserCommon if (content["main"] == "true" && !page.module_app.nil?) ret << "
" else part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil diff --git a/log/sunspot-solr-development.log.1 b/log/sunspot-solr-development.log.1 new file mode 100644 index 000000000..049dd80c3 --- /dev/null +++ b/log/sunspot-solr-development.log.1 @@ -0,0 +1,222 @@ +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: JNDI not configured for solr (NoInitialContextEx) +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: using system property solr.solr.home: /Users/kaito/Documents/MyWorkspeace/NCCU/solr +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader +INFO: Solr home set to '/Users/kaito/Documents/MyWorkspeace/NCCU/solr/' +Jun 18, 2012 4:30:20 PM org.apache.solr.servlet.SolrDispatchFilter init +INFO: SolrDispatchFilter.init() +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: JNDI not configured for solr (NoInitialContextEx) +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: using system property solr.solr.home: /Users/kaito/Documents/MyWorkspeace/NCCU/solr +Jun 18, 2012 4:30:20 PM org.apache.solr.core.CoreContainer$Initializer initialize +INFO: looking for solr.xml: /Users/kaito/Documents/MyWorkspeace/NCCU/solr/solr.xml +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrResourceLoader +INFO: Solr home set to '/Users/kaito/Documents/MyWorkspeace/NCCU/solr/' +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrConfig initLibs +INFO: Adding specified lib dirs to ClassLoader +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrConfig +INFO: Loaded SolrConfig: solrconfig.xml +Jun 18, 2012 4:30:20 PM org.apache.solr.core.SolrCore +INFO: Opening new SolrCore at /Users/kaito/Documents/MyWorkspeace/NCCU/solr/, dataDir=/Users/kaito/Documents/MyWorkspeace/NCCU/solr/data/development/ +Jun 18, 2012 4:30:20 PM org.apache.solr.schema.IndexSchema readSchema +INFO: Reading Solr Schema +Jun 18, 2012 4:30:21 PM org.apache.solr.schema.IndexSchema readSchema +INFO: Schema name=sunspot +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created string: org.apache.solr.schema.StrField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created tdouble: org.apache.solr.schema.TrieDoubleField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created rand: org.apache.solr.schema.RandomSortField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created null: org.apache.solr.analysis.StandardTokenizerFactory +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created null: org.apache.solr.analysis.StandardFilterFactory +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created null: org.apache.solr.analysis.LowerCaseFilterFactory +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created text: org.apache.solr.schema.TextField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created boolean: org.apache.solr.schema.BoolField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created date: org.apache.solr.schema.DateField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created sdouble: org.apache.solr.schema.SortableDoubleField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created sfloat: org.apache.solr.schema.SortableFloatField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created sint: org.apache.solr.schema.SortableIntField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created slong: org.apache.solr.schema.SortableLongField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created tint: org.apache.solr.schema.TrieIntField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created tfloat: org.apache.solr.schema.TrieFloatField +Jun 18, 2012 4:30:21 PM org.apache.solr.util.plugin.AbstractPluginLoader load +INFO: created tdate: org.apache.solr.schema.TrieDateField +Jun 18, 2012 4:30:21 PM org.apache.solr.schema.IndexSchema readSchema +INFO: default search field is text +Jun 18, 2012 4:30:21 PM org.apache.solr.schema.IndexSchema readSchema +INFO: query parser default operator is AND +Jun 18, 2012 4:30:21 PM org.apache.solr.schema.IndexSchema readSchema +INFO: unique key field: id +Jun 18, 2012 4:30:21 PM org.apache.solr.core.JmxMonitoredMap +INFO: No JMX servers found, not exposing Solr information with JMX. +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore initListeners +INFO: Added SolrEventListener: org.apache.solr.core.QuerySenderListener{queries=[]} +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore initListeners +INFO: Added SolrEventListener: org.apache.solr.core.QuerySenderListener{queries=[{q=solr rocks,start=0,rows=10}, {q=static firstSearcher warming query from solrconfig.xml}]} +Jun 18, 2012 4:30:21 PM org.apache.solr.request.XSLTResponseWriter init +INFO: xsltCacheLifetimeSeconds=5 +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created standard: solr.SearchHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created dismax: solr.SearchHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created partitioned: solr.SearchHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /spell: solr.SearchHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created tvrh: org.apache.solr.handler.component.SearchHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: adding lazy requestHandler: org.apache.solr.handler.extraction.ExtractingRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /update/extract: org.apache.solr.handler.extraction.ExtractingRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /terms: org.apache.solr.handler.component.SearchHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: adding lazy requestHandler: solr.SearchHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /elevate: solr.SearchHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /update: solr.XmlUpdateRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /update/javabin: solr.BinaryUpdateRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /analysis/document: solr.DocumentAnalysisRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /analysis/field: solr.FieldAnalysisRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: adding lazy requestHandler: solr.CSVRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /update/csv: solr.CSVRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /admin/: org.apache.solr.handler.admin.AdminHandlers +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /admin/ping: PingRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /debug/dump: solr.DumpRequestHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig +INFO: created /mlt: solr.MoreLikeThisHandler +Jun 18, 2012 4:30:21 PM org.apache.solr.search.SolrIndexSearcher +INFO: Opening Searcher@3b5b123b main +Jun 18, 2012 4:30:21 PM org.apache.solr.update.DirectUpdateHandler2$CommitTracker +INFO: AutoCommit: disabled +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SpellCheckComponent inform +INFO: Initializing spell checkers +Jun 18, 2012 4:30:21 PM org.apache.solr.spelling.AbstractLuceneSpellChecker init +INFO: Using WhitespaceAnalzyer for dictionary: default +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SpellCheckComponent inform +WARNING: No queryConverter defined, using default converter +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.QueryElevationComponent inform +INFO: Loading QueryElevation from: /Users/kaito/Documents/MyWorkspeace/NCCU/solr/conf/elevate.xml +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.SpellCheckComponent@6a40afb9 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.QueryComponent@7dc21ece +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.FacetComponent@5374a6e2 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.MoreLikeThisComponent@f786a3c +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.HighlightComponent@2a869113 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.StatsComponent@689e8c34 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.TermVectorComponent@3cd0d12e +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding debug component:org.apache.solr.handler.component.DebugComponent@106df95 +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SearchHandler inform +INFO: Adding component:org.apache.solr.handler.component.TermsComponent@31554233 +Jun 18, 2012 4:30:21 PM org.apache.solr.core.QuerySenderListener newSearcher +INFO: QuerySenderListener sending requests to Searcher@3b5b123b main +Jun 18, 2012 4:30:21 PM org.apache.solr.core.CoreContainer register +INFO: registering core: +Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrDispatchFilter init +INFO: user.dir=/Users/kaito/.rvm/gems/ruby-1.9.2-p290@orbit/gems/sunspot_solr-1.3.3/solr +Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrDispatchFilter init +INFO: SolrDispatchFilter.init() done +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore execute +INFO: [] webapp=null path=null params={start=0&event=firstSearcher&q=solr+rocks&rows=10} hits=0 status=0 QTime=43 +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore execute +INFO: [] webapp=null path=null params={event=firstSearcher&q=static+firstSearcher+warming+query+from+solrconfig.xml} hits=0 status=0 QTime=1 +Jun 18, 2012 4:30:21 PM org.apache.solr.core.QuerySenderListener newSearcher +INFO: QuerySenderListener done. +Jun 18, 2012 4:30:21 PM org.apache.solr.handler.component.SpellCheckComponent$SpellCheckerListener newSearcher +INFO: Loading spell index for spellchecker: default +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrCore registerSearcher +INFO: [] Registered new searcher Searcher@3b5b123b main +Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrServlet init +INFO: SolrServlet.init() +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: JNDI not configured for solr (NoInitialContextEx) +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: using system property solr.solr.home: /Users/kaito/Documents/MyWorkspeace/NCCU/solr +Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrServlet init +INFO: SolrServlet.init() done +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: JNDI not configured for solr (NoInitialContextEx) +Jun 18, 2012 4:30:21 PM org.apache.solr.core.SolrResourceLoader locateSolrHome +INFO: using system property solr.solr.home: /Users/kaito/Documents/MyWorkspeace/NCCU/solr +Jun 18, 2012 4:30:21 PM org.apache.solr.servlet.SolrUpdateServlet init +INFO: SolrUpdateServlet.init() done diff --git a/log/sunspot-solr-development.log.lck b/log/sunspot-solr-development.log.lck new file mode 100644 index 000000000..e69de29bb diff --git a/public/static/nccu_calendar.xml b/public/static/nccu_calendar.xml index f72c72680..e903ac458 100644 --- a/public/static/nccu_calendar.xml +++ b/public/static/nccu_calendar.xml @@ -4,246 +4,6 @@ 本月最新活動 zh-tw - - 「系際盃拔河賽」活動 - - - - - 101/05/14-101/05/16 12:00-14:00 - - - LEXUS百萬挑戰賽校園巡迴說明會 - - - - - 101/05/15 12:00-12:45 - - - 職場講座「數位文本實務課程」 - - - - - 101/04/24-101/05/15 12:20-13:50 - - - 「系際盃拔河賽」活動 - - - - - 101/05/14-101/05/16 12:00-14:00 - - - 85週年校慶運動會 - - - - - 101/05/17-101/05/18 08:00-17:00 - - - 85週年校慶運動會 - - - - - 101/05/17-101/05/18 08:00-17:00 - - - 2012年福祿貝爾恩物親子戲遊成長團體(上午) - - - - - 101/04/07-101/06/02 09:00-11:00 - - - 2012年福祿貝爾恩物親子戲遊成長團體(下午) - - - - - 101/04/07-101/06/09 14:00-16:00 - - - 商學院羽球賽 - - - - - 101/05/20 08:00-17:00 - - - 期末舞展/彩排 - - - - - 政治大學熱舞社17th成果發表 《i》6:30入場 - - - 期末舞展/彩排 - - - - - 政治大學熱舞社17th成果發表 《i》6:30入場 - - - ★特優TA教學觀摩(不動產投資與市場分析) - - - - - 101/05/24 12:10-13:00 - - - 文化講座「破戒:關於『色•戒』的實與虛」 - - - - - 101/05/24 12:20-14:00 - - - 團隊導向學習(TBL)及Campus Pasck研習工作坊 - - - - - 101/05/25 12:00-14:00 - - - 青春活力校園展演(歌仔戲):《馴夫記》 - - - - - 101/05/25 19:00-21:00 - - - 國際交流足球聯賽 - - - - - 101/05/26 08:00-17:00 - - - 政大盃桌球賽 - - - - - 101/05/26 08:00-17:00 - - - 2012年福祿貝爾恩物親子戲遊成長團體(上午) - - - - - 101/04/07-101/06/02 09:00-11:00 - - - 五院盃羽球賽 - - - - - 101/05/26 09:00-17:00 - - - TOEIC英語測驗校園考 - - - - - 101/05/26 09:30-12:00 - - - 2012年福祿貝爾恩物親子戲遊成長團體(下午) - - - - - 101/04/07-101/06/09 14:00-16:00 - - - 期末公演 - - - - - 2012/5/26 13:00入場 13:30開始 - - - 傳播學院媒體參訪(二)壹電視 - - - - - 101/05/30 14:00-16:30 - - - 國樂講座—國樂演奏會【故鄉情】 - - - - - 101/05/30 19:30-21:00 - - - 2012年福祿貝爾恩物親子戲遊成長團體(上午) - - - - - 101/04/07-101/06/02 09:00-11:00 - - - 100學年畢業典禮 - - - - - 101/06/02 09:00-17:00 - - - 100學年度文學院研究所畢業生撥穗典禮 - - - - - 101/06/02 10:00-11:30 - - - 100學年度文學院大學部畢業生撥穗典禮 - - - - - 101/06/02 12:00-13:30 - - - 2012年福祿貝爾恩物親子戲遊成長團體(下午) - - - - - 101/04/07-101/06/09 14:00-16:00 - - - 往內在旅行,尋覓你的人格風景 - - - - - 101/06/03 09:00-16:30 - 政大講座論壇:東亞模式的民法典?(蘇永欽講座教授) @@ -252,6 +12,38 @@ 101/06/04 10:10-11:50 + + 文化講座【父親與民國】-白先勇 + + + + + 101/06/06 14:00-16:00 + + + 鄭丁旺講座教授榮退專題演講-我國會計發展的回顧與前瞻 + + + + + 101/06/07 10:00-12:30 + + + 弦樂社 + + + + + 政大弦樂社期末成果發表音樂會 + + + 期末舞展 + + + + + 政大國標社期末舞展 歡迎大家來共襄盛舉 + 國際學院運動會 @@ -300,5 +92,45 @@ 101/06/10 08:00-17:00 + + 教職員羽球賽 + + + + + 101/06/16 08:00-12:00 + + + 「樂活飲食•健康之鑰」系列活動--餐飲實務操作與食品安全 + + + + + 101/06/22 14:00-16:00 + + + 學生議會預備會議 + + + + + 第13屆學生議會第1會期預備會議,將選舉新任學生議會議長、副議長,歡迎政大同學列席旁聽!! + + + 山水講堂:政大教學日 + + + + + 101/06/26 08:20-16:40 + + + 「樂活飲食•健康之鑰」系列活動--廚房消毒與病媒防治 + + + + + 101/06/29 14:00-16:00 + diff --git a/solr/conf/admin-extra.html b/solr/conf/admin-extra.html new file mode 100644 index 000000000..aa739da86 --- /dev/null +++ b/solr/conf/admin-extra.html @@ -0,0 +1,31 @@ + + + diff --git a/solr/conf/elevate.xml b/solr/conf/elevate.xml new file mode 100644 index 000000000..7630ebe20 --- /dev/null +++ b/solr/conf/elevate.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + diff --git a/solr/conf/mapping-ISOLatin1Accent.txt b/solr/conf/mapping-ISOLatin1Accent.txt new file mode 100644 index 000000000..ede774258 --- /dev/null +++ b/solr/conf/mapping-ISOLatin1Accent.txt @@ -0,0 +1,246 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Syntax: +# "source" => "target" +# "source".length() > 0 (source cannot be empty.) +# "target".length() >= 0 (target can be empty.) + +# example: +# "À" => "A" +# "\u00C0" => "A" +# "\u00C0" => "\u0041" +# "ß" => "ss" +# "\t" => " " +# "\n" => "" + +# À => A +"\u00C0" => "A" + +# Á => A +"\u00C1" => "A" + +#  => A +"\u00C2" => "A" + +# à => A +"\u00C3" => "A" + +# Ä => A +"\u00C4" => "A" + +# Å => A +"\u00C5" => "A" + +# Æ => AE +"\u00C6" => "AE" + +# Ç => C +"\u00C7" => "C" + +# È => E +"\u00C8" => "E" + +# É => E +"\u00C9" => "E" + +# Ê => E +"\u00CA" => "E" + +# Ë => E +"\u00CB" => "E" + +# Ì => I +"\u00CC" => "I" + +# Í => I +"\u00CD" => "I" + +# Î => I +"\u00CE" => "I" + +# Ï => I +"\u00CF" => "I" + +# IJ => IJ +"\u0132" => "IJ" + +# Ð => D +"\u00D0" => "D" + +# Ñ => N +"\u00D1" => "N" + +# Ò => O +"\u00D2" => "O" + +# Ó => O +"\u00D3" => "O" + +# Ô => O +"\u00D4" => "O" + +# Õ => O +"\u00D5" => "O" + +# Ö => O +"\u00D6" => "O" + +# Ø => O +"\u00D8" => "O" + +# Œ => OE +"\u0152" => "OE" + +# Þ +"\u00DE" => "TH" + +# Ù => U +"\u00D9" => "U" + +# Ú => U +"\u00DA" => "U" + +# Û => U +"\u00DB" => "U" + +# Ü => U +"\u00DC" => "U" + +# Ý => Y +"\u00DD" => "Y" + +# Ÿ => Y +"\u0178" => "Y" + +# à => a +"\u00E0" => "a" + +# á => a +"\u00E1" => "a" + +# â => a +"\u00E2" => "a" + +# ã => a +"\u00E3" => "a" + +# ä => a +"\u00E4" => "a" + +# å => a +"\u00E5" => "a" + +# æ => ae +"\u00E6" => "ae" + +# ç => c +"\u00E7" => "c" + +# è => e +"\u00E8" => "e" + +# é => e +"\u00E9" => "e" + +# ê => e +"\u00EA" => "e" + +# ë => e +"\u00EB" => "e" + +# ì => i +"\u00EC" => "i" + +# í => i +"\u00ED" => "i" + +# î => i +"\u00EE" => "i" + +# ï => i +"\u00EF" => "i" + +# ij => ij +"\u0133" => "ij" + +# ð => d +"\u00F0" => "d" + +# ñ => n +"\u00F1" => "n" + +# ò => o +"\u00F2" => "o" + +# ó => o +"\u00F3" => "o" + +# ô => o +"\u00F4" => "o" + +# õ => o +"\u00F5" => "o" + +# ö => o +"\u00F6" => "o" + +# ø => o +"\u00F8" => "o" + +# œ => oe +"\u0153" => "oe" + +# ß => ss +"\u00DF" => "ss" + +# þ => th +"\u00FE" => "th" + +# ù => u +"\u00F9" => "u" + +# ú => u +"\u00FA" => "u" + +# û => u +"\u00FB" => "u" + +# ü => u +"\u00FC" => "u" + +# ý => y +"\u00FD" => "y" + +# ÿ => y +"\u00FF" => "y" + +# ff => ff +"\uFB00" => "ff" + +# fi => fi +"\uFB01" => "fi" + +# fl => fl +"\uFB02" => "fl" + +# ffi => ffi +"\uFB03" => "ffi" + +# ffl => ffl +"\uFB04" => "ffl" + +# ſt => ft +"\uFB05" => "ft" + +# st => st +"\uFB06" => "st" diff --git a/solr/conf/protwords.txt b/solr/conf/protwords.txt new file mode 100644 index 000000000..1dfc0abec --- /dev/null +++ b/solr/conf/protwords.txt @@ -0,0 +1,21 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. +dontstems +zwhacky + diff --git a/solr/conf/schema.xml b/solr/conf/schema.xml new file mode 100644 index 000000000..01b9c8c8d --- /dev/null +++ b/solr/conf/schema.xml @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + text + + + + diff --git a/solr/conf/scripts.conf b/solr/conf/scripts.conf new file mode 100644 index 000000000..f58b262ae --- /dev/null +++ b/solr/conf/scripts.conf @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +user= +solr_hostname=localhost +solr_port=8983 +rsyncd_port=18983 +data_dir= +webapp_name=solr +master_host= +master_data_dir= +master_status_dir= diff --git a/solr/conf/solrconfig.xml b/solr/conf/solrconfig.xml new file mode 100644 index 000000000..809e9a568 --- /dev/null +++ b/solr/conf/solrconfig.xml @@ -0,0 +1,938 @@ + + + + + + ${solr.abortOnConfigurationError:true} + + + + + + + + + + + + + ${solr.data.dir:./solr/data} + + + + false + 10 + + + + 32 + + 10000 + 1000 + 10000 + + + + + + + + native + + + + + + false + 32 + 10 + + + + + + false + + true + + + + + + 1 + + 0 + + + + false + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + true + + + + + 20 + + 200 + + + + + + + + + + + + solr rocks + 0 + 10 + + + static firstSearcher warming query from solrconfig.xml + + + + + false + + 2 + + + + + + + + + + + + + + + + + + explicit + + + + + + + + + + + dismax + explicit + 0.01 + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + + text^0.2 features^1.1 name^1.5 manu^1.4 manu_exact^1.9 + + + popularity^0.5 recip(price,1,1000,1000)^0.3 + + + id,name,price,score + + + 2<-1 5<-2 6<90% + + 100 + *:* + + text features name + + 0 + + name + regex + + + + + + + dismax + explicit + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 + 2<-1 5<-2 6<90% + + incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2 + + + + inStock:true + + + + cat + manu_exact + price:[* TO 500] + price:[500 TO *] + + + + + + + + + + textSpell + + default + name + ./spellchecker + + + + + + + + + false + + false + + 1 + + + spellcheck + + + + + + + true + + + tvComponent + + + + + + + + default + + org.carrot2.clustering.lingo.LingoClusteringAlgorithm + + 20 + + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + + + + true + default + true + + name + id + + features + + true + + + + false + + + clusteringComponent + + + + + + + text + true + ignored_ + + true + links + ignored_ + + + + + + + true + + + termsComponent + + + + + + string + elevate.xml + + + + + explicit + + + elevator + + + + + + + + + + + + + + + + + + standard + solrpingquery + all + + + + + + explicit + + true + + + + + + + + 100 + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + ]]> + ]]> + + + + + + + + + 5 + + + + + + solr + + + + + 1 + 2 + + + diff --git a/solr/conf/spellings.txt b/solr/conf/spellings.txt new file mode 100644 index 000000000..d7ede6f56 --- /dev/null +++ b/solr/conf/spellings.txt @@ -0,0 +1,2 @@ +pizza +history \ No newline at end of file diff --git a/solr/conf/stopwords.txt b/solr/conf/stopwords.txt new file mode 100644 index 000000000..b5824da32 --- /dev/null +++ b/solr/conf/stopwords.txt @@ -0,0 +1,58 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +#Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +s +such +t +that +the +their +then +there +these +they +this +to +was +will +with + diff --git a/solr/conf/synonyms.txt b/solr/conf/synonyms.txt new file mode 100644 index 000000000..b0e31cb7e --- /dev/null +++ b/solr/conf/synonyms.txt @@ -0,0 +1,31 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaa => aaaa +bbb => bbbb1 bbbb2 +ccc => cccc1,cccc2 +a\=>a => b\=>b +a\,a => b\,b +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 589da3208..0dae6a5f3 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -5,6 +5,9 @@ class Bulletin include Mongoid::Timestamps include Mongoid::MultiParameterAttributes include Impressionist::Impressionable + include NccuSearch + + scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false) is_impressionable :counter_cache => { :column_name => :view_count } @@ -54,7 +57,11 @@ class Bulletin after_save :save_bulletin_links after_save :save_bulletin_files - + + +def publish_month + published_at.strftime("%B %Y") +end def self.search( search = nil, category_id = nil ) if category_id.to_s.size > 0 and search.to_s.size > 0 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 b4f5fc828..a8479ee98 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 @@ -9,20 +9,29 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController # GET /news_bulletins.xml def index - date_now = Time.now - if !params[:category_id].blank? - @news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) - elsif !params[:tag_id].blank? - tmp = NewsTag.find(params[:tag_id]) rescue nil - tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp - @news_bulletins = tmp.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) rescue nil - else - @news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) - end + if !params[:search_query].blank? + @news_bulletins = NewsBulletin.solr_search do + fulltext params[:search_query] do + fields(:text,:title=>2.0) + end + end.each_hit_with_result + else + date_now = Time.now + if !params[:category_id].blank? + @news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) + elsif !params[:tag_id].blank? + tmp = NewsTag.find(params[:tag_id]) rescue nil + tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp + @news_bulletins = tmp.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) rescue nil + else + @news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) + end + end get_categorys @current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil + end def show 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 dad3c7811..d31188576 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 @@ -46,6 +46,9 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController get_categorys end + # def news_bulletins_search_block + # end + def home_banner if !params[:category_id].blank? @news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).widget_datas.limit(9) 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 f9d2ca0e8..9e8d0a2ba 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -5,6 +5,16 @@ class NewsBulletin include Mongoid::Timestamps include Mongoid::MultiParameterAttributes include Impressionist::Impressionable + # include OrbitBasis::BaseModel + # include OrbitSearchLib::ObjectSearchable + # include NccuSearch + # include Redis::Objects + include Mongoid::BaseModel + + include Sunspot::Mongoid + + + # scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false) is_impressionable :counter_cache => { :column_name => :view_count } @@ -54,7 +64,61 @@ class NewsBulletin after_save :save_news_bulletin_links after_save :save_news_bulletin_files - +# include OrbitBasis::ClassMethods + + + searchable do + text :title do + titles = "" + titles << (self.title.zh_tw.nil? ? '':self.title.zh_tw) + titles << (self.title.en.nil? ? '':self.title.en) + #(titles << self.title.en )unless self.title.nil? + doc = Nokogiri::HTML(titles) + doc.text + #VALID_LOCALES + end + + text :text do + texts = "" + texts << (self.text.zh_tw.nil? ? '':self.text.zh_tw) + texts << (self.text.en.nil? ? '':self.text.en) + #texts << self.text.en )unless self.text.en.nil? + doc = Nokogiri::HTML(texts) + doc.text + #VALID_LOCALES + end + # text :sub_titles do + # self.subtitle.zh_tw + # #VALID_LOCALES + # end + # text :text do + # self.text.zh_tw + # #VALID_LOCALES + # end + # text :content, :publish_month + # text :comments do + # comments.map(&:content) + # end + # time :published_at + # string :publish_month + end + # mapping do + # indexes :title, :analyzer => 'cjk', :boost => 10 + # indexes :sub_titles, :analyzer => 'cjk', :boost => 5 + # indexes :text, :analyzer => 'cjk' + # 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 => titles, + # :sub_titles => sub_titles, + # :text => texts + # }.to_json + # end def self.search( search = nil, category_id = nil ) if category_id.to_s.size > 0 and search.to_s.size > 0 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 new file mode 100644 index 000000000..f3512afc0 --- /dev/null +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb @@ -0,0 +1,6 @@ +<%= form_tag panel_news_front_end_news_bulletins_path, method: :get do %> +

+ <%= 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/news/config/routes.rb b/vendor/built_in_modules/news/config/routes.rb index 244b1d034..e78f28748 100644 --- a/vendor/built_in_modules/news/config/routes.rb +++ b/vendor/built_in_modules/news/config/routes.rb @@ -45,6 +45,7 @@ Rails.application.routes.draw do match "reload_news_bulletins" => "news_bulletins#reload_news_bulletins" match "reload_web_links" => "news_bulletins#reload_web_links" match "news_bulletins_side_bar" => "news_bulletins#news_bulletins_side_bar" + match "news_bulletins_search_block" => "news_bulletins#news_bulletins_search_block" end end end diff --git a/vendor/built_in_modules/page_content/app/controllers/panel/page_content/back_end/page_contexts_controller.rb b/vendor/built_in_modules/page_content/app/controllers/panel/page_content/back_end/page_contexts_controller.rb index 809bfbb33..0f334e77b 100644 --- a/vendor/built_in_modules/page_content/app/controllers/panel/page_content/back_end/page_contexts_controller.rb +++ b/vendor/built_in_modules/page_content/app/controllers/panel/page_content/back_end/page_contexts_controller.rb @@ -5,8 +5,7 @@ class Panel::PageContent::BackEnd::PageContextsController < OrbitBackendControll #before_filter :is_admin? def index - - @page_contexts = params[:sort] ? get_sorted_and_filtered("page_contexts", {:archived => false}) : PageContext.where(:archived => false).page(params[:page]).per(10) + @page_contexts = (params.has_key?:sort)? get_sorted_and_filtered("page_contexts", {:archived => false}) : PageContext.where(:archived => false).page(params[:page]).per(10) respond_to do |format| format.html # index.html.erb diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb index 7e056432b..e11122f31 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb @@ -19,5 +19,5 @@ <%end -%> <%= display_date_time(page_context.updated_at) %> - <%= User.find(page_context.create_user_id).name %> + <%= User.find(page_context.create_user_id).name rescue ''%> \ No newline at end of file diff --git a/vendor/plugins/sunspot_mongoid/.document b/vendor/plugins/sunspot_mongoid/.document new file mode 100644 index 000000000..ecf367319 --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/.document @@ -0,0 +1,5 @@ +README.rdoc +lib/**/*.rb +bin/* +features/**/*.feature +LICENSE diff --git a/vendor/plugins/sunspot_mongoid/LICENSE b/vendor/plugins/sunspot_mongoid/LICENSE new file mode 100644 index 000000000..883f09226 --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/LICENSE @@ -0,0 +1,20 @@ +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 new file mode 100644 index 000000000..7c3c88fef --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/README.md @@ -0,0 +1,53 @@ +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 new file mode 100644 index 000000000..bec1214b7 --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/Rakefile @@ -0,0 +1,57 @@ +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 new file mode 100644 index 000000000..267577d47 --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/VERSION @@ -0,0 +1 @@ +0.4.1 diff --git a/vendor/plugins/sunspot_mongoid/examples/example.rb b/vendor/plugins/sunspot_mongoid/examples/example.rb new file mode 100644 index 000000000..04f02e776 --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/examples/example.rb @@ -0,0 +1,36 @@ +$:.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 new file mode 100644 index 000000000..341c6026a --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/init.rb @@ -0,0 +1 @@ +require 'sunspot_mongoid' diff --git a/vendor/plugins/sunspot_mongoid/lib/sunspot/mongoid.rb b/vendor/plugins/sunspot_mongoid/lib/sunspot/mongoid.rb new file mode 100644 index 000000000..a12703dfa --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/lib/sunspot/mongoid.rb @@ -0,0 +1,49 @@ +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 new file mode 100644 index 000000000..454e5da2a --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/lib/sunspot_mongoid.rb @@ -0,0 +1 @@ +require 'sunspot/mongoid' diff --git a/vendor/plugins/sunspot_mongoid/sunspot_mongoid.gemspec b/vendor/plugins/sunspot_mongoid/sunspot_mongoid.gemspec new file mode 100644 index 000000000..968884cde --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/sunspot_mongoid.gemspec @@ -0,0 +1,67 @@ +# 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, [">= 0"]) + s.add_runtime_dependency(%q, [">= 1.1.0"]) + s.add_runtime_dependency(%q, [">= 1.1.0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 1.1.0"]) + s.add_dependency(%q, [">= 1.1.0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + end + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 1.1.0"]) + s.add_dependency(%q, [">= 1.1.0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + end +end + diff --git a/vendor/plugins/sunspot_mongoid/test/helper.rb b/vendor/plugins/sunspot_mongoid/test/helper.rb new file mode 100644 index 000000000..e5c3b13b9 --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/test/helper.rb @@ -0,0 +1,12 @@ +require 'rubygems' +require 'test/unit' +require 'shoulda' +require 'rr' + +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +$LOAD_PATH.unshift(File.dirname(__FILE__)) +require 'sunspot_mongoid' + +class Test::Unit::TestCase + include RR::Adapters::TestUnit +end diff --git a/vendor/plugins/sunspot_mongoid/test/test_sunspot_mongoid.rb b/vendor/plugins/sunspot_mongoid/test/test_sunspot_mongoid.rb new file mode 100644 index 000000000..141b6f3b6 --- /dev/null +++ b/vendor/plugins/sunspot_mongoid/test/test_sunspot_mongoid.rb @@ -0,0 +1,51 @@ +require 'helper' + +# +# NOTE: I think tests are too few... +# +class TestSunspotMongoid < Test::Unit::TestCase + class Foo + include Mongoid::Document + field :title + + include Sunspot::Mongoid + searchable do + text :title + end + end + + class Bar + include Mongoid::Document + field :title + + include Sunspot::Mongoid + searchable(:auto_index => false, :auto_remove => false) do + text :title + end + end + + context 'default' do + should 'sunspot_options is specified' do + assert Foo.sunspot_options == {:include => []} + assert Bar.sunspot_options == {:auto_index=>false, :auto_remove=>false, :include=>[]} + end + + should 'be called Sunspot.setup when call Foo.searchable' do + mock(Sunspot).setup(Foo) + Foo.searchable + end + + should 'get as text_fields from Sunspot::Setup' do + text_field = Sunspot::Setup.for(Foo).all_text_fields.first + assert text_field.type == Sunspot::Type::TextType.instance + assert text_field.name == :title + end + + should 'search' do + options = {} + mock.proxy(Foo).solr_execute_search(options) + mock(Sunspot).new_search(Foo) { mock(Object.new).execute } + Foo.search(options) + end + end +end