diff --git a/Gemfile b/Gemfile index 9fb4c3cd..3146d5bc 100644 --- a/Gemfile +++ b/Gemfile @@ -32,6 +32,11 @@ gem 'resque-restriction' #gem 'rb-readline' gem 'ruby-debug19' gem 'rubyzip' + +gem 'sunspot_mongo' +gem 'sunspot_solr' +gem 'progress_bar' + gem 'sinatra' gem 'sprockets' gem 'tinymce-rails' diff --git a/Gemfile.lock b/Gemfile.lock index c7dcecaa..31bdf08a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,7 +97,9 @@ GEM factory_girl (~> 2.6.0) railties (>= 3.0.0) fastercsv (1.5.4) + fattr (2.2.1) haml (3.1.4) + highline (1.6.13) hike (1.2.1) hoe (2.16.1) rake (~> 0.8) @@ -136,12 +138,17 @@ GEM net-ldap (0.3.1) nokogiri (1.5.2) nokogiri (1.5.2-x86-mingw32) + options (2.3.0) + fattr orm_adapter (0.0.6) pdf-writer (1.1.8) color (>= 1.4.0) transaction-simple (~> 1.3) polyglot (0.3.3) pr_geohash (1.0.0) + progress_bar (0.4.0) + highline (~> 1.6.1) + options (~> 2.3.0) rack (1.3.6) rack-cache (1.2) rack (>= 0.4) @@ -256,9 +263,12 @@ GEM rsolr (~> 1.0.7) sunspot-rails-tester (0.0.4) sunspot_rails (~> 1.2) + sunspot_mongo (1.0.1) + sunspot_rails sunspot_rails (1.3.3) nokogiri sunspot (= 1.3.3) + sunspot_solr (1.3.3) thor (0.14.6) tilt (1.3.3) tinymce-rails (3.4.8) @@ -314,6 +324,7 @@ DEPENDENCIES mysql2 net-ldap (~> 0.3.1) nokogiri + progress_bar radius rails (>= 3.1.0, < 3.2.0) rake @@ -335,6 +346,8 @@ DEPENDENCIES spork sprockets sunspot-rails-tester + sunspot_mongo + sunspot_solr tinymce-rails uglifier watchr diff --git a/config/initializers/redis_search.rb b/config/initializers/redis_search.rb deleted file mode 100644 index 76971b97..00000000 --- a/config/initializers/redis_search.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "redis" -require "redis-namespace" -require "redis-search" -# don't forget change namespace -redis = Redis.new(:host => "127.0.0.1",:port => "6379") -# We suggest you use a special db in Redis, when you need to clear all data, you can use flushdb command to clear them. -redis.select(3) -# Give a special namespace as prefix for Redis key, when your have more than one project used redis-search, this config will make them work fine. -redis = Redis::Namespace.new("orbit_nccu:redis_search2", :redis => redis) -Redis::Search.configure do |config| - config.redis = redis - config.complete_max_length = 100 - #config.pinyin_match = true - # use rmmseg, true to disable it, it can save memroy - config.disable_rmmseg = false -end -# Bulletin.new -# NewsBulletin.new \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 93fbcc10..7a85ddff 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -306,3 +306,4 @@ en: sitesearch: Google Site Search site_setting_help: Please Enter the search argument for Google search. result_get: "Searched about ' %{search_word} ' Found %{item_num} items" + too_many: "Search about ' %{search_word} 'resulted more than %{exceed_num} items maybe try to search with more specific terms?" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 79251f92..d1a15773 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -442,7 +442,9 @@ zh_tw: site_search: "全站搜尋" sitesearch: Google Site Search site_setting_help: 請輸入送交Google搜尋的參數 - result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料" + result_get: "搜尋有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料" + too_many: "搜尋有關 ' %{search_word} ' 尋找到超過 %{exceed_num} 筆資料,請嘗試加入更多關鍵字縮小搜尋範圍,以作更精確的搜尋" + activerecord: errors: template: # ~ 2.3.5 backward compatible diff --git a/config/sunspot.yml b/config/sunspot.yml index 79867b7a..7bbd32c0 100644 --- a/config/sunspot.yml +++ b/config/sunspot.yml @@ -7,11 +7,11 @@ production: development: solr: hostname: localhost - port: 8983 + port: 8982 log_level: INFO test: solr: hostname: localhost - port: 8983 + port: 8981 log_level: WARNING \ No newline at end of file diff --git a/lib/tasks/matt_dev.rake b/lib/tasks/matt_dev.rake index c82606c2..ce0cd509 100644 --- a/lib/tasks/matt_dev.rake +++ b/lib/tasks/matt_dev.rake @@ -6,9 +6,22 @@ namespace :matt_dev do p a a= Redis::Search.query("NewsBulletin",'社科院',:conditions =>{:is_checked=>true,:is_hidden=>false}) p a - # p Pinyin.t('台灣不是中國的一部分') end - + + task :searching_02 => :environment do + a= Bulletin.solr_search do #("Bulletin",'我',:conditions =>{:is_checked=>true,:is_hidden=>false}) + fulltext '關島' + with(:frontend_search,true) + #with(:is_hidden,true) + end + p a.results + a= NewsBulletin.solr_search do #("NewsBulletin",'社科院',:conditions =>{:is_checked=>true,:is_hidden=>false}) + fulltext '社科院' + with(:frontend_search,true) + #with(:is_hidden,true) + end + p a.results + end task :testing_new_tag_cal do ranges = [[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5],[1,2,3,4,5,6],[1,2,3,4,5,6,7],[1,2,3,4,5,6,7,8],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10,11],[1,2,3,4,5,6,7,8,9,10,11,12],[-1,-2,-3,-4,5,6,7,8,9,10,11,12]] diff --git a/lib/tasks/mid_site_sync.rake b/lib/tasks/mid_site_sync.rake index 707a609b..e009f861 100644 --- a/lib/tasks/mid_site_sync.rake +++ b/lib/tasks/mid_site_sync.rake @@ -9,7 +9,7 @@ namespace :mid_site do admin_role = nil sub_role = nil test_account_ldap_id ='139716' - MiddleSiteConnection.establish + #MiddleSiteConnection.establish task :sync => :environment do info_profile = Info.first(conditions: {:key => 'profile'}) diff --git a/solr/conf/admin-extra.html b/solr/conf/admin-extra.html new file mode 100644 index 00000000..aa739da8 --- /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 00000000..7630ebe2 --- /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 00000000..ede77425 --- /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 00000000..1dfc0abe --- /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 00000000..17a751ad --- /dev/null +++ b/solr/conf/schema.xml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + text + + + + diff --git a/solr/conf/scripts.conf b/solr/conf/scripts.conf new file mode 100644 index 00000000..f58b262a --- /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 00000000..65c19607 --- /dev/null +++ b/solr/conf/solrconfig.xml @@ -0,0 +1,934 @@ + + + + + + ${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 00000000..d7ede6f5 --- /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 00000000..b5824da3 --- /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 00000000..b0e31cb7 --- /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/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index f787ff28..5dfbb750 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -10,11 +10,8 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle def approve notice = "" @bulletin = Bulletin.find params[:bulletin_id] - - @bulletin.is_checked = params[:bulletin][:is_checked] - @bulletin.not_checked_reason = params[:bulletin][:not_checked_reason] + @bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason]) @bulletin.de_pending - if @bulletin.save notice = t('bulletin.approve_bulletin_success') else diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 466ba140..33090e50 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -14,8 +14,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def index # @bulletins = Bulletin.all # @bulletins = Bulletin.desc("postdate desc") - get_categorys('BulletinCategory',params[:bulletin_category_id]) - get_tags + get_categorys('BulletinCategory',params[:bulletin_category_id]) + get_tags @filter = params[:filter] new_filter = params[:new_filter] @@ -34,12 +34,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @filter = {new_filter[:type] => [new_filter[:id].to_s]} end - # @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id] - - # @bulletins = Bulletin.search(params[:search], params[:category_id]) - # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) - - # @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10) @bulletin_categories = get_categories_for_index("BulletinCategory") @bulletin_category_ids = @bulletin_categories.collect{|t| t.id.to_s} + [nil] @@ -62,16 +56,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # GET /bulletins/1.xml def show @bulletin = Bulletin.find(params[:id]) - get_tags - # get_categorys - - # @bulletin_categorys = BulletinCategory.where("_id" => params[:id]) - - # if params[:id] - # @bulletins = Bulletin.where("bulletin_category_id" => params[:id]) - # else - # @bulletins = Bulletin.desc("postdate desc") - # end + get_tags respond_to do |format| format.html # show.html.erb @@ -84,13 +69,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def new @bulletin = Bulletin.new(:postdate => DateTime.now) - @link_url = panel_announcement_back_end_bulletins_path - - # @bulletin.bulletin_files.build - # @bulletin.bulletin_files.new - - get_tags - respond_to do |format| + @link_url = panel_announcement_back_end_bulletins_path + get_tags + respond_to do |format| format.html # new.html.erb format.xml { render :xml => @bulletin } end @@ -141,6 +122,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin.create_user_id = current_user.id @bulletin.update_user_id = current_user.id + if(is_manager? || is_admin?) + @bulletin.de_pending + end respond_to do |format| if @bulletin.save @@ -158,13 +142,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController end - def link_quick_add - # debugger - + def link_quick_add @bulletin_link = BulletinLink.new - @link_url = panel_announcement_back_end_bulletins_path - - @bulletin_link.bulletin_id = params[:bulletin_id] + @link_url = panel_announcement_back_end_bulletins_path + @bulletin_link.bulletin_id = params[:bulletin_id] respond_to do |format| format.js @@ -173,29 +154,17 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController end def link_quick_edit - # debugger @bulletin_link = BulletinLink.find(params[:bulletin_id]) - - @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link) - - # @bulletin = Bulletin.find(params[:bulletin_id]) - - # @link_url = panel_announcement_back_end_bulletin_path(@bulletin) - + @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link) respond_to do |format| format.js end - end - def file_quick_add - # debugger - + def file_quick_add @bulletin_file = BulletinFile.new @file_url = panel_announcement_back_end_bulletins_path - @bulletin_file.bulletin_id = params[:bulletin_id] - respond_to do |format| format.js end @@ -203,11 +172,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController end def file_quick_edit - # debugger @bulletin_file = BulletinFile.find(params[:bulletin_id]) - @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file) - respond_to do |format| format.js end @@ -215,6 +181,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # PUT /bulletins/1 # PUT /bulletins/1.xml + def update if params[:bulletin_link] @@ -248,7 +215,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController else @bulletin = Bulletin.find(params[:id]) - # @bulletin.image.clear if params[:bulletin][:image_del] == '1' # if params[:bulletin][:image_del] == '1' @@ -262,6 +228,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController respond_to do |format| if @bulletin.update_attributes(params[:bulletin]) + if(is_manager? || is_admin?) + @bulletin.is_checked = true + @bulletin.is_rejected = false + @bulletin.de_pending! + end # if (params[:bulletin][:is_checked] == "false") # @bulletin.is_rejected = true # @bulletin.save! @@ -276,8 +247,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController format.js { render 'toggle_enable' } format.xml { head :ok } else - get_tags - + get_tags format.html { render :action => "edit" } format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 93911aeb..9bcfb4fe 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -10,10 +10,14 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController def index if !params[:search_query].blank? - search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending => false} - search_cond.merge!({:bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank? - search = Redis::Search.query("Bulletin", params[:search_query], :conditions =>search_cond,:limit=>Bulletin.all.count) - search_result = search.collect{|t| t["id"]} + # search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending => false} + # search_cond.merge!({:bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank? + @search = Bulletin.solr_search do + fulltext params[:search_query] + with(:frontend_search,true) + #order_by(:average_rating) + end + search_result = @search.results.collect{|result| result.id} @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(15) else diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index e70acf57..1cda9cb4 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -4,7 +4,7 @@ class Bulletin include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - include Redis::Search + include Sunspot::Mongo include Impressionist::Impressionable BelongsToCategory = :bulletin_category @@ -60,60 +60,49 @@ class Bulletin validates :title, :at_least_one => true - before_save :check_deadline,:update_status,:update_avliable_language + before_save :check_deadline,:update_avliable_language after_save :save_bulletin_links after_save :save_bulletin_files - redis_search_index(:title_field => :s_title, - :alias_field =>:s_title_en , - :score_field => :view_count, - :condition_fields => [:is_checked,:is_hidden,:bulletin_category_id,:is_pending], - :ext_fields => []) - + searchable do + text :titles do + title_translations.to_a.collect{|t| t[1]} + end + text :texts do + text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text} + end + # text :text do + # a = (title_translations["zh_tw"] + title_translations["en"]) + # a + # end + boolean :frontend_search do + ( !is_hidden && !is_pending && is_checked && !is_rejected ) + end - # def gen_title_for_search - # # [s_title,s_title_en,s_text_en,s_text_zh_tw].join(' ') - # end + integer :view_count + string :bulletin_category_id + end - #alias_method - - def s_title - self.title_translations["zh_tw"] + def proc_check(check,not_pass_info = "") + self.is_checked = true + if check =="true" + self.is_rejected = false + elsif check == "false" + self.is_rejected = true + self.not_checked_reason = not_pass_info + end end - def s_title_was - self.title_was["zh_tw"] - end - - def s_title_en - self.title_translations["en"] - end - - def s_title_en_was - self.title_was["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 - - # scope :currently_available, lambda { |category, limit| - # # limit ||= 5 - # # { - # # debugger - # # a=1 - # :where => {:bulletin_category_id => bulletin_category_id, :disable => false}#, - # # :limit => limit - # # } - # } def de_pending self.is_pending = false end + def de_pending! + de_pending + self.save! + end + def publish_month published_at.strftime("%B %Y") end @@ -214,21 +203,6 @@ class Bulletin end end - - def update_status - if !self.is_pending - if !self.is_checked - # self.is_pending = false - self.is_rejected = true - #self.is_checked = false - elsif self.is_checked - # self.is_pending = false - self.is_rejected = false - #self.is_checked = true - end - end - return true - end def update_avliable_language VALID_LOCALES.each do |locale| diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb index 8e512aa6..611c59ba 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb @@ -18,8 +18,10 @@ <% if @bulletins.blank? and !params[:search_query].blank? %> <%=render :partial => 'shared/search_not_found' %> <% elsif !params[:search_query].blank? %> - <%= t("search.result_get",:search_word => params[:search_query],:item_num=>@bulletins.count) %> + <%= t("search.result_get",:search_word => params[:search_query],:item_num=>@bulletins.count) unless (@bulletins.count == 30) %> + <%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@bulletins.count) if (@bulletins.count ==30) %> <% end %> + <% @bulletins.each do |post| %> <%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %> diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb index 0c946ca3..2cd1b684 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb @@ -10,11 +10,8 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController def approve notice = "" @news_bulletin = NewsBulletin.find params[:news_bulletin_id] - - @news_bulletin.is_checked = params[:news_bulletin][:is_checked] - @news_bulletin.not_checked_reason = params[:news_bulletin][:not_checked_reason] + @news_bulletin.proc_check(params[:news_bulletin][:is_checked],params[:news_bulletin][:not_checked_reason]) @news_bulletin.de_pending - if @news_bulletin.save notice = t('news_bulletin.approve_bulletin_success') else diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb index 8ada0a01..fa08cac1 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb @@ -148,6 +148,10 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController @news_bulletin.create_user_id = current_user.id @news_bulletin.update_user_id = current_user.id + if(is_manager? || is_admin?) + @news_bulletin.de_pending + end + respond_to do |format| if @news_bulletin.save expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner') @@ -267,6 +271,11 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController respond_to do |format| if @news_bulletin.update_attributes(params[:news_bulletin]) + if(is_manager? || is_admin?) + @news_bulletin.is_checked = true + @news_bulletin.is_rejected = false + @news_bulletin.de_pending! + end expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner') # format.html { redirect_to(panel_news_back_end_news_bulletin_url(@news_bulletin), :notice => t('news_bulletin.update_news_bulletin_success')) } format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('news_bulletin.update_success')) } 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 ed15065b..caa2ceeb 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,10 +10,15 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController def index if !params[:search_query].blank? - search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending=>false,:is_pending=>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,:limit=>NewsBulletin.all.count) - search_result = search.collect{|t| t["id"]} + # search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending=>false,:is_pending=>false} + # search_cond.merge!({:news_bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank? + + @search = NewsBulletin.solr_search do + fulltext params[:search_query] + with(:frontend_search,true) + #order_by(:average_rating) + end + search_result = @search.results.collect{|result| result.id} @news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(10) else date_now = Time.now 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 3fdabd56..8d93dfc4 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -4,7 +4,7 @@ class NewsBulletin include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - include Redis::Search + include Sunspot::Mongo include Impressionist::Impressionable BelongsToCategory = :news_bulletin_category @@ -61,7 +61,7 @@ class NewsBulletin validates :title, :at_least_one => true - before_save :update_status,:update_avliable_language + before_save :update_avliable_language after_save :save_news_bulletin_links after_save :save_news_bulletin_files @@ -91,31 +91,47 @@ class NewsBulletin "news_bulletin" 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,:is_pending], - :ext_fields =>[]) + searchable do + text :titles do + title_translations.to_a.collect{|t| t[1]} + end + text :texts do + text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text} + end + integer :view_count + + boolean :frontend_search do + ( !is_hidden && !is_pending && is_checked && !is_rejected ) + end + + + string :news_bulletin_category_id + 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,:is_pending], + # :ext_fields =>[]) # def gen_title_for_search # # [s_title,s_title_en,s_text_en,s_text_zh_tw].join(' ') # end - def s_title - self.title_translations["zh_tw"] - end + # def s_title + # self. + # end - def s_title_was - self.title_was["zh_tw"] - end + # def s_title_was + # self.title_was["zh_tw"] + # end - def s_title_en - self.title_translations["en"] - end + # def s_title_en + # self.title_translations["en"] + # end - def s_title_en_was - self.title_was["en"] - end + # def s_title_en_was + # self.title_was["en"] + # end # def s_text_en # Nokogiri::HTML(self.text.en).text @@ -140,10 +156,25 @@ class NewsBulletin end + def proc_check(check,not_pass_info = "") + self.is_checked = true + if check =="true" + self.is_rejected = false + elsif check == "false" + self.is_rejected = true + self.not_checked_reason = not_pass_info + end + end + def de_pending self.is_pending = false end + def de_pending! + de_pending + self.save! + end + def is_expired? Date.today > self.deadline ? true : false rescue false #some dates might sat as nil so rescue false @@ -213,19 +244,4 @@ class NewsBulletin end end - def update_status - if !self.is_pending - if !self.is_checked - # self.is_pending = false - self.is_rejected = true - #self.is_checked = false - elsif self.is_checked - # self.is_pending = false - self.is_rejected = false - #self.is_checked = true - end - end - return true - end - end \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/index.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/index.html.erb index b7b1f57a..0a7d36be 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/index.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/index.html.erb @@ -10,7 +10,8 @@ <% if @news_bulletins.blank? and !params[:search_query].blank? %> <%=render :partial => 'shared/search_not_found' %> <% elsif !params[:search_query].blank? %> - <%= t("search.result_get",:search_word => params[:search_query],:item_num=>@news_bulletins.count) %> + <%= t("search.result_get",:search_word => params[:search_query],:item_num=>@news_bulletins.count) unless (@bulletins.count == 30)%> + <%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@bulletins.count) if (@bulletins.count ==30) %> <% end %>