From 69901403cdf3b9b10db07fb2e532d2de3fee990d Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 3 Aug 2012 09:30:12 +0800 Subject: [PATCH 01/30] First version of Solr search. --- Gemfile | 5 + Gemfile.lock | 13 + config/initializers/redis_search.rb | 18 - config/sunspot.yml | 4 +- lib/tasks/matt_dev.rake | 17 +- solr/conf/admin-extra.html | 31 + solr/conf/elevate.xml | 36 + solr/conf/mapping-ISOLatin1Accent.txt | 246 +++++ solr/conf/protwords.txt | 21 + solr/conf/schema.xml | 238 +++++ solr/conf/scripts.conf | 24 + solr/conf/solrconfig.xml | 934 ++++++++++++++++++ solr/conf/spellings.txt | 2 + solr/conf/stopwords.txt | 58 ++ solr/conf/synonyms.txt | 31 + .../front_end/bulletins_controller.rb | 8 +- .../announcement/app/models/bulletin.rb | 54 +- .../front_end/news_bulletins_controller.rb | 8 +- .../news/app/models/news_bulletin.rb | 52 +- 19 files changed, 1738 insertions(+), 62 deletions(-) delete mode 100644 config/initializers/redis_search.rb create mode 100644 solr/conf/admin-extra.html create mode 100644 solr/conf/elevate.xml create mode 100644 solr/conf/mapping-ISOLatin1Accent.txt create mode 100644 solr/conf/protwords.txt create mode 100644 solr/conf/schema.xml create mode 100644 solr/conf/scripts.conf create mode 100644 solr/conf/solrconfig.xml create mode 100644 solr/conf/spellings.txt create mode 100644 solr/conf/stopwords.txt create mode 100644 solr/conf/synonyms.txt 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/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..0a9f7104 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/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/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index d970ee1c..8fc53bed 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 @@ -12,8 +12,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController 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 = Bulletin.solr_search do + fulltext params[:search_query] + #with(:frontend_search,true) + 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..12a725cb 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 @@ -65,11 +65,29 @@ class Bulletin 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| t[1]} + end + # text :text do + # a = (title_translations["zh_tw"] + title_translations["en"]) + # a + # end + boolean :frontend_search do + !is_hidden && !is_pending && is_checked + end + + integer :view_count + string :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,:bulletin_category_id,:is_pending], + # :ext_fields => []) # def gen_title_for_search @@ -78,21 +96,21 @@ class Bulletin #alias_method - def s_title - self.title_translations["zh_tw"] - end + # def s_title + # self.title_translations["zh_tw"] + # 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 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 142017b7..48c56f63 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 @@ -12,8 +12,12 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController 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 = NewsBulletin.solr_search do + fulltext params[:search_query] + with(:frontend_search,true) + 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..8105917c 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 @@ -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| t[1]} + end + integer :view_count + + boolean :frontend_search do + !is_hidden && !is_pending && is_checked + 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 From d7ad029d4b45dad73ca3c1fe9dfd6a024b16d868 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 3 Aug 2012 12:45:47 +0800 Subject: [PATCH 02/30] fix approval at news and announcement for abnormal flags that causing search result fault. --- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 4 +- lib/tasks/matt_dev.rake | 2 +- lib/tasks/mid_site_sync.rake | 2 +- .../back_end/approvals_controller.rb | 5 +- .../back_end/bulletins_controller.rb | 72 +++++------------ .../front_end/bulletins_controller.rb | 8 +- .../announcement/app/models/bulletin.rb | 78 ++++--------------- .../front_end/bulletins/index.html.erb | 4 +- .../back_end/news_approvals_controller.rb | 5 +- .../back_end/news_bulletins_controller.rb | 9 +++ .../front_end/news_bulletins_controller.rb | 5 +- .../news/app/models/news_bulletin.rb | 36 ++++----- .../front_end/news_bulletins/index.html.erb | 3 +- 14 files changed, 85 insertions(+), 149 deletions(-) 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/lib/tasks/matt_dev.rake b/lib/tasks/matt_dev.rake index 0a9f7104..ce0cd509 100644 --- a/lib/tasks/matt_dev.rake +++ b/lib/tasks/matt_dev.rake @@ -10,7 +10,7 @@ namespace :matt_dev do task :searching_02 => :environment do a= Bulletin.solr_search do #("Bulletin",'我',:conditions =>{:is_checked=>true,:is_hidden=>false}) - fulltext '我' + fulltext '關島' with(:frontend_search,true) #with(:is_hidden,true) end 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/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 8fc53bed..6f117ed6 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,12 +10,12 @@ 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_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) + with(:frontend_search,true) + #order_by(:average_rating) end search_result = @search.results.collect{|result| result.id} diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 12a725cb..1cda9cb4 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -60,7 +60,7 @@ 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 @@ -70,68 +70,39 @@ class Bulletin title_translations.to_a.collect{|t| t[1]} end text :texts do - text_translations.to_a.collect{|t| t[1]} + 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_hidden && !is_pending && is_checked && !is_rejected ) end integer :view_count string :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,: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 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 - #alias_method - - # def s_title - # self.title_translations["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_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 @@ -232,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 48c56f63..c5165e3a 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,12 +10,13 @@ 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_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) 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 8105917c..8d93dfc4 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -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 @@ -96,12 +96,12 @@ class NewsBulletin title_translations.to_a.collect{|t| t[1]} end text :texts do - text_translations.to_a.collect{|t| t[1]} + 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_hidden && !is_pending && is_checked && !is_rejected ) end @@ -156,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 @@ -229,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 %> From b79de669736f946cbd2c5479712cef8ed32f7954 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 3 Aug 2012 14:42:18 +0800 Subject: [PATCH 03/30] fix variable. --- .../views/panel/news/front_end/news_bulletins/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 0a7d36be..4f8cce62 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,8 +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) unless (@bulletins.count == 30)%> - <%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@bulletins.count) if (@bulletins.count ==30) %> + <%= t("search.result_get",:search_word => params[:search_query],:item_num=>@news_bulletins.count) unless (@news_bulletins.count == 30)%> + <%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@news_bulletins.count) if (@news_bulletins.count ==30) %> <% end %>
From 9a103bbb7e832908657e265df1163d4da50b8f67 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 6 Aug 2012 15:13:21 +0800 Subject: [PATCH 04/30] Fix remote upload file for tinymce --- Gemfile | 1 + app/assets/javascripts/new_admin.js | 2 +- app/views/admin/assets/file_upload.html.erb | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 9fb4c3cd..6e07eafa 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,7 @@ gem 'mysql2' gem 'nokogiri' gem 'radius' gem 'rake' +gem 'remotipart' gem 'resque' # background jobs gem 'resque-scheduler' # job scheduling gem 'resque-restriction' diff --git a/app/assets/javascripts/new_admin.js b/app/assets/javascripts/new_admin.js index 949753a9..0c9f30df 100644 --- a/app/assets/javascripts/new_admin.js +++ b/app/assets/javascripts/new_admin.js @@ -17,4 +17,4 @@ //= require side_bar_history //= require rss //= require ajax_form -//= require inc/ajax_setting +//= require jquery.remotipart diff --git a/app/views/admin/assets/file_upload.html.erb b/app/views/admin/assets/file_upload.html.erb index abdcfbc6..d267b674 100644 --- a/app/views/admin/assets/file_upload.html.erb +++ b/app/views/admin/assets/file_upload.html.erb @@ -3,7 +3,7 @@ <%= flash_messages %> -<%= form_for :asset, :url => admin_assets_path(:uploader => true), :html => {:id => 'ajaxForm', :multipart => true } do |f| %> +<%= form_for :asset, :url => admin_assets_path(:uploader => true), :remote => true do |f| %> @@ -51,7 +51,7 @@
From 80887ace3c83b24fe7518abdd054b8d2a3c4112a Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 6 Aug 2012 15:15:44 +0800 Subject: [PATCH 05/30] Remove console.log --- app/assets/javascripts/tinymce_orbit.js.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/tinymce_orbit.js.erb b/app/assets/javascripts/tinymce_orbit.js.erb index f12bfa3d..aa954973 100644 --- a/app/assets/javascripts/tinymce_orbit.js.erb +++ b/app/assets/javascripts/tinymce_orbit.js.erb @@ -47,7 +47,6 @@ function myFileBrowser(field_name, url, type, win) { var cmsURL = window.location.toString(); cmsURL = cmsURL.split("/"); cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>"; - console.log(cmsURL); // script URL - use an absolute path! if (cmsURL.indexOf("?") < 0) { //add the type as the only query parameter From 1c62c1a79986fcf66a4a1015cc3e827718a7eeda Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 6 Aug 2012 16:12:49 +0800 Subject: [PATCH 06/30] first version of fb_share --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/assets/javascripts/application.js | 3 ++- app/assets/stylesheets/application.css | 2 +- app/helpers/application_helper.rb | 2 ++ config/initializers/social_share_button.rb | 3 +++ config/locales/social_share_button.en.yml | 14 ++++++++++++++ config/locales/social_share_button.zh-tw.yml | 14 ++++++++++++++ .../news/front_end/news_bulletins/show.html.erb | 3 ++- 9 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 config/initializers/social_share_button.rb create mode 100644 config/locales/social_share_button.en.yml create mode 100644 config/locales/social_share_button.zh-tw.yml diff --git a/Gemfile b/Gemfile index 3146d5bc..3eb4c060 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,8 @@ gem 'progress_bar' gem 'sinatra' gem 'sprockets' +gem 'social-share-button' + gem 'tinymce-rails' gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") gem 'rb-readline' if RUBY_PLATFORM.downcase.include?("linux") diff --git a/Gemfile.lock b/Gemfile.lock index 31bdf08a..96f07221 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -250,6 +250,7 @@ GEM rack (~> 1.3, >= 1.3.6) rack-protection (~> 1.2) tilt (~> 1.3, >= 1.3.3) + social-share-button (0.0.6) spork (0.9.0) spork (0.9.0-x86-mingw32) win32-process @@ -343,6 +344,7 @@ DEPENDENCIES shoulda-matchers simplecov sinatra + social-share-button spork sprockets sunspot-rails-tester diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 13d92690..f3c799cf 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -6,4 +6,5 @@ // //= require jquery //= require jquery_ujs -//= require_tree . \ No newline at end of file +//= require_tree . +//= social-share-button \ No newline at end of file diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 9833ffda..c0c227fe 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -3,5 +3,5 @@ *and any sub-directories. You're free to add application-wide styles to this file and they'll appear at *the top of the compiled file, but it's generally better to create a new file per style scope. *= require_self - + *= require social-share-button */ diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0c6229b3..16b0ff09 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -140,6 +140,7 @@ module ApplicationHelper stylesheets << "\n" stylesheets << "\n" end + stylesheets << "\n" stylesheets << "\n" if page.design.reset_css stylesheets << "\n" stylesheets << "\n" if page.design.default_css @@ -161,6 +162,7 @@ module ApplicationHelper end javascripts << "\n" javascripts << "\n" + javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" diff --git a/config/initializers/social_share_button.rb b/config/initializers/social_share_button.rb new file mode 100644 index 00000000..8b933577 --- /dev/null +++ b/config/initializers/social_share_button.rb @@ -0,0 +1,3 @@ +SocialShareButton.configure do |config| + config.allow_sites = %w(twitter facebook google_plus) +end \ No newline at end of file diff --git a/config/locales/social_share_button.en.yml b/config/locales/social_share_button.en.yml new file mode 100644 index 00000000..7e3f1fb0 --- /dev/null +++ b/config/locales/social_share_button.en.yml @@ -0,0 +1,14 @@ +en: + social_share_button: + share_to: Share to %{name} + weibo: Sina Weibo + twitter: Twitter + facebook: Facebook + douban: Douban + qq: Qzone + tqq: Tqq + delicious: Delicious + baidu: Baidu.com + kaixin001: Kaixin001.com + renren: Renren.com + google_plus: Google+ diff --git a/config/locales/social_share_button.zh-tw.yml b/config/locales/social_share_button.zh-tw.yml new file mode 100644 index 00000000..b0321eb5 --- /dev/null +++ b/config/locales/social_share_button.zh-tw.yml @@ -0,0 +1,14 @@ +zh_tw: + social_share_button: + share_to: 分享到%{name} + weibo: 新浪微博 + twitter: Twitter + facebook: Facebook + douban: 豆瓣 + qq: QQ空間 + tqq: 腾讯微博 + delicious: Delicious + baidu: 百度收藏 + kaixin001: 開心網 + renren: 人人網 + google_plus: Google+ diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index edd8a9e1..c6c912c8 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -40,5 +40,6 @@
- <%= render "shared/addthis_toolbox"%> + <%= social_share_button_tag(@news_bulletin.title) %> + <%#= render "shared/addthis_toolbox"%>
From 3f543193f0e0db4e08c778277a3ec3073470db52 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 6 Aug 2012 17:34:00 +0800 Subject: [PATCH 07/30] Remove remotipart (not working with ie9) the upload is working except that the pop-up does not disappear in ie --- Gemfile | 2 +- app/assets/javascripts/ajax_form.js | 6 ++++++ app/assets/javascripts/new_admin.js | 2 +- app/views/admin/assets/file_upload.html.erb | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 6e07eafa..7b12d5c0 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem 'mysql2' gem 'nokogiri' gem 'radius' gem 'rake' -gem 'remotipart' +# gem 'remotipart' gem 'resque' # background jobs gem 'resque-scheduler' # job scheduling gem 'resque-restriction' diff --git a/app/assets/javascripts/ajax_form.js b/app/assets/javascripts/ajax_form.js index d9b5abfe..26218a08 100644 --- a/app/assets/javascripts/ajax_form.js +++ b/app/assets/javascripts/ajax_form.js @@ -2,6 +2,12 @@ $(document).on('click', '#ajax_form_submit', function(){ $('#ajaxForm').ajaxSubmit({ beforeSubmit: function(a,f,o) { o.dataType = 'script'; + if (o.dataType == 'script') { + o.url = o.url.split('?'); // split on GET params + if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js + o.url = o.url.join('?'); // join on GET params + alert(o.url) + } } }); }); \ No newline at end of file diff --git a/app/assets/javascripts/new_admin.js b/app/assets/javascripts/new_admin.js index 0c9f30df..949753a9 100644 --- a/app/assets/javascripts/new_admin.js +++ b/app/assets/javascripts/new_admin.js @@ -17,4 +17,4 @@ //= require side_bar_history //= require rss //= require ajax_form -//= require jquery.remotipart +//= require inc/ajax_setting diff --git a/app/views/admin/assets/file_upload.html.erb b/app/views/admin/assets/file_upload.html.erb index d267b674..abdcfbc6 100644 --- a/app/views/admin/assets/file_upload.html.erb +++ b/app/views/admin/assets/file_upload.html.erb @@ -3,7 +3,7 @@ <%= flash_messages %> -<%= form_for :asset, :url => admin_assets_path(:uploader => true), :remote => true do |f| %> +<%= form_for :asset, :url => admin_assets_path(:uploader => true), :html => {:id => 'ajaxForm', :multipart => true } do |f| %> @@ -51,7 +51,7 @@
From cbf7ccc13ba90240f6bb5af39561dfeafdbb586a Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 7 Aug 2012 19:21:54 +0800 Subject: [PATCH 08/30] 1.Remove category column when category is specified 2.Showing category if not in category browsing 3.Redirect to home and show error if app page is not available for user language 4.Showing no context to display if object has no language for it. 5.Browse new and announcement by unit is now applicable. --- Gemfile.lock | 2 ++ app/controllers/pages_controller.rb | 36 ++++++++++++------- app/models/item.rb | 5 ++- app/models/page.rb | 4 +-- app/models/user/user.rb | 5 --- app/views/layouts/page_layout.html.erb | 13 ++++++- config/locales/en.yml | 4 ++- config/locales/zh_tw.yml | 4 ++- config/mongoid.yml | 2 +- lib/parsers/parser_common.rb | 2 +- lib/tasks/data_migration.rake | 13 +++++++ .../front_end/bulletins_controller.rb | 19 +++++++--- .../announcement/app/models/bulletin.rb | 29 +++++++-------- .../front_end/bulletins/index.html.erb | 12 +++++-- .../front_end/bulletins/show.html.erb | 2 +- .../announcement/config/routes.rb | 1 + .../front_end/news_bulletins_controller.rb | 18 +++++++--- .../news/app/models/news_bulletin.rb | 4 +++ .../front_end/news_bulletins/index.html.erb | 4 +++ .../front_end/news_bulletins/show.html.erb | 2 +- vendor/built_in_modules/news/config/routes.rb | 1 + 21 files changed, 126 insertions(+), 56 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c7dcecaa..04f4c69a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,6 +179,7 @@ GEM chinese_pinyin (>= 0.3.0) redis (>= 2.1.1) redis-namespace (~> 1.0.2) + remotipart (1.0.2) resque (1.20.0) multi_json (~> 1.0) redis-namespace (~> 1.0.2) @@ -320,6 +321,7 @@ DEPENDENCIES redis (>= 2.1.1) redis-namespace (~> 1.0.2) redis-search (= 0.7.1) + remotipart resque resque-restriction resque-scheduler diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 4375ba1a..053660a5 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,9 +1,6 @@ class PagesController < ApplicationController - include ApplicationHelper - before_filter :get_item, :only => [:index_from_link, :show_from_link] - # caches_page :index def index @@ -11,7 +8,7 @@ class PagesController < ApplicationController if @item impressionist(@item) - render_page + render_page else render :text => 'You need a home page' end @@ -19,14 +16,15 @@ class PagesController < ApplicationController def show #begin + @item = Item.first(:conditions => {:path => params[:page_name]}) - if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) + if @item && @item.is_published #&& (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) impressionist(@item) case @item.class.to_s - when 'Page' - render_page + when 'Page' + render_page unless save_from_no_lang_for_page when 'Link' - redirect_to @item[:url] + redirect_to(@item[:url]) unless save_from_no_lang_for_page end else render :file => "#{Rails.root}/public/404.html", :status => :not_found @@ -43,15 +41,17 @@ class PagesController < ApplicationController 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? options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank? + options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank? uri = URI::escape(url + options) - redirect_to uri + #uri = URI::escape("#{url}?" + params.collect{|k,v| "#{k}=#{v}"}.join('&')) + redirect_to(uri)unless save_from_no_lang_for_page end def show_from_link url = "/#{@item.path}?id=#{params[:id]}" options = '' options << "&preview=#{params[:preview]}" unless params[:preview].blank? - redirect_to url + options + redirect_to(url + options) unless save_from_no_lang_for_page end def load_orbit_bar @@ -66,12 +66,22 @@ class PagesController < ApplicationController @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]}) @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item elsif !params[:category_id].blank? - @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) + @item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],category: params[:category_id]).any_in(tag: [nil,'']).first elsif !params[:tag_id].blank? - @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => '', :tag => params[:tag_id]}) + @item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first end - @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => '', :tag => ''}) unless @item + @item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item #TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性 end + protected + def save_from_no_lang_for_page + if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s) + flash[:notice] = t('sys.module_page_lang_not_support') + redirect_to '/' + return true + else + return false + end + end end diff --git a/app/models/item.rb b/app/models/item.rb index f43421af..4cc22674 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -23,7 +23,10 @@ class Item before_destroy :destroy_children after_rearrange :rebuild_path, :if => "parent_id_changed?" - + def enabled_for_lang(lang) + enabled_for.include?(lang) + end + def self.find_by_name(item_name) Item.first(:conditions => { :name => item_name, :is_published => true }) end diff --git a/app/models/page.rb b/app/models/page.rb index 20a51288..cba692d0 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -6,8 +6,8 @@ class Page < Item field :content field :app_frontend_url field :theme_id, :type => BSON::ObjectId, :default => nil - field :category - field :tag + field :category, :default => '' + field :tag, :default => '' field :view_count, :type => Integer, :default => 0 field :page_title, localize: true diff --git a/app/models/user/user.rb b/app/models/user/user.rb index f51d49f0..4cb00bbb 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -31,12 +31,7 @@ class User VALID_LOCALES.each do |loc| locale = loc.to_sym - # debugger - # if(self.cache_dept.nil?) - # self.build_cache_dept key: "dept_cache_user_#{self.id}" - # end dept_hash[locale] = sub_roles.collect{|sr| sr.title}.join(',') - # self.cache_dept[locale] = sub_roles.collect{|sr| sr.title}.join(',') end self.cache_dept = dept_hash self.save! diff --git a/app/views/layouts/page_layout.html.erb b/app/views/layouts/page_layout.html.erb index 0a7240ef..90deba2b 100644 --- a/app/views/layouts/page_layout.html.erb +++ b/app/views/layouts/page_layout.html.erb @@ -12,6 +12,17 @@ <%= page_javascripts(@item).html_safe %> - <%= yield %> + <%= yield %> + <% if !flash.empty? %> + + + <% end -%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 93fbcc10..2ff1163f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -298,7 +298,8 @@ en: sys: not_previewable: "Preview not support" limit_of_upload_file_size: "Upload file must be less than: %{best_size}" - + can_not_display_due_to_no_context: "Can not display due to no context for English" + module_page_lang_not_support: "We are sorry, this page is not available for English" search: not_found: "NOT FOUND" domains: Google Search Domains @@ -306,3 +307,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" + unit_get: "Listed items created by :%{unit_name} Found %{item_num} items" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 79251f92..6276cc4c 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -443,6 +443,7 @@ zh_tw: sitesearch: Google Site Search site_setting_help: 請輸入送交Google搜尋的參數 result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料" + unit_get: "列出由:%{unit_name}發佈的資料,共有%{item_num}筆" activerecord: errors: template: # ~ 2.3.5 backward compatible @@ -524,7 +525,8 @@ zh_tw: sys: not_previewable: "不支援預覽" limit_of_upload_file_size: "上傳檔案大小限制: %{best_size}" - + can_not_display_due_to_no_context: "因為沒有中文版本,所以無法顯示" + module_page_lang_not_support: "很抱歉,本頁沒有開放中文版本" object_disable: change_to_true: "設為停用" change_to_false: "重新啓用" \ No newline at end of file diff --git a/config/mongoid.yml b/config/mongoid.yml index 0d68cb7a..219e1372 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -8,7 +8,7 @@ defaults: &defaults development: <<: *defaults - database: prototype_r4_ldap0229 + database: i18n_var test: <<: *defaults diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index eca375a4..6a9390ea 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -180,7 +180,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/lib/tasks/data_migration.rake b/lib/tasks/data_migration.rake index 54d8bd0f..624cf39c 100644 --- a/lib/tasks/data_migration.rake +++ b/lib/tasks/data_migration.rake @@ -83,4 +83,17 @@ namespace :data_migration do puts("#{'='*10}Finished#{'='*10}") end + task :make_bulletin_save_dept_data => :environment do + Bulletin.all.each{|bt| bt.save!} + end + + task :extend_exsisted_app_module_for_dept_search => :environment do + app = ModuleApp.first({:conditions=>{:title => 'news'}}) + app.app_pages << "index_by_unit" if !app.widgets.include?("index_by_unit") + app.save! + app = ModuleApp.first({:conditions=>{:title => 'Announcement'}}) + app.app_pages << "index_by_unit" if !app.widgets.include?("index_by_unit") + app.save! + end + end \ No newline at end of file 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 685eaa24..6c3a292e 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 @@ -7,7 +7,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController # GET /bulletins # GET /bulletins.xml - + def index_bulletins_by_unit + @page = Page.find(params[:page_id]) + @bulletins=Bulletin.all.available_for_lang(I18n.locale).can_display.where("cache_dept.#{I18n.locale.to_s.downcase}"=>params[:name]).page( params[:page_main]).per(15) + render :index + end + def index @page = Page.find(params[:page_id]) if !params[:search_query].blank? @@ -44,10 +49,14 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController if params[:preview] == "true" preview_content else - @bulletin = Bulletin.all.available_for_lang(I18n.locale).can_display.where(_id: params[:id]).first - unless @bulletin.disable? - impressionist(@bulletin) - get_categorys + @bulletin = Bulletin.all.can_display.where(_id: params[:id]).first + if !@bulletin.disable? + if @bulletin.enabled_for_lang(I18n.locale.to_s) + impressionist(@bulletin) + get_categorys + else + render :text => "
#{t('sys.can_not_display_due_to_no_context')}
".html_safe + end else render :nothing => true, :status => 403 end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index e70acf57..08f0cbc6 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -25,6 +25,8 @@ class Bulletin field :postdate , :type => DateTime field :deadline , :type => DateTime # field :url + field :cache_dept,type: Hash + field :create_user_id field :update_user_id, :class_name => "User" @@ -61,7 +63,8 @@ class Bulletin validates :title, :at_least_one => true before_save :check_deadline,:update_status,:update_avliable_language - + + before_save :fetch_dept after_save :save_bulletin_links after_save :save_bulletin_files @@ -94,26 +97,14 @@ class Bulletin 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 enabled_for_lang(lang) + eval("self.available_for_#{lang}") + end + def publish_month published_at.strftime("%B %Y") end @@ -240,4 +231,8 @@ class Bulletin end end + def fetch_dept + self.cache_dept = (User.current.cache_dept rescue nil) || (User.find(self.create_user_id).cache_dept rescue nil) + end + end \ No newline at end of file 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 1bb363d0..58d3c109 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 @@ -7,10 +7,16 @@
- + <%= content_tag (:th) do %> + <%= t('announcement.bulletin.category') %> + <% end if (!params[:search_query].blank? or params[:category_id].blank?)-%> + <% if !params[:name].blank?%> + <%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %> + <% end %> + <% if @bulletins.blank? and !params[:search_query].blank? %> <%=render :partial => 'shared/search_not_found' %> <% elsif !params[:search_query].blank? %> @@ -18,7 +24,9 @@ <% end %> <% @bulletins.each do |post| %> > - + <%= content_tag(:th) do%> + + <% end if(!params[:search_query].blank? or params[:category_id].blank?) %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index af1ca12c..b6dbb177 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -4,7 +4,7 @@
<%= dislpay_view_count(@bulletin) %> <%= display_date_time(@bulletin.postdate) %> - <%= User.find(@bulletin.create_user_id).cache_dept[I18n.locale.to_s] rescue nil %> + <%= link_to @bulletin.cache_dept[I18n.locale.to_s],panel_announcement_front_end_index_bulletins_by_unit_path(:name=>@bulletin.cache_dept[I18n.locale.to_s]) rescue nil %>
diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index ce6c5ec3..0640a1f0 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -34,6 +34,7 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do + match "index_by_unit" => "bulletins#index_bulletins_by_unit",:as => :index_bulletins_by_unit resources :bulletins # do # match "preview" => "bulletins#preview_content",:as => :get_preview_content # end diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb index 87826f02..2173254d 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 @@ -8,6 +8,12 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController # GET /news_bulletins # GET /news_bulletins.xml + def index_news_bulletins_by_unit + @page = Page.find(params[:page_id]) + @news_bulletins=NewsBulletin.all.available_for_lang(I18n.locale).can_display.where("unit_list_for_anc_id"=>params[:name]).page( params[:page_main]).per(15).page( params[:page_main]).per(10) + render :index + end + def index @page = Page.find(params[:page_id]) if !params[:search_query].blank? @@ -42,10 +48,14 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController preview_content else '' - @news_bulletin = NewsBulletin.all.available_for_lang(I18n.locale).can_display.where(_id: params[:id]).first - unless @news_bulletin.disable? - impressionist(@news_bulletin) - get_categorys + @news_bulletin = NewsBulletin.all.can_display.where(_id: params[:id]).first + if !@news_bulletin.disable? + if @news_bulletin.enabled_for_lang(I18n.locale.to_s) + impressionist(@news_bulletin) + get_categorys + else + render :text => "
#{t('sys.can_not_display_due_to_no_context')}
".html_safe + end else render :nothing => true, :status => 403 end 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..03f82281 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -140,6 +140,10 @@ class NewsBulletin end + def enabled_for_lang(lang) + eval("self.available_for_#{lang}") + end + def de_pending self.is_pending = false end 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 23708c13..8b93b352 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 @@ -4,6 +4,10 @@

<%= @page.title %>

+<% if !params[:name].blank?%> + <%= t("search.unit_get",:unit_name => UnitListForAnc.find(params[:name]).title,:item_num=>@news_bulletins.count) %> +<% end %> + <% if @news_bulletins.blank? and !params[:search_query].blank? %> <%=render :partial => 'shared/search_not_found' %> <% elsif !params[:search_query].blank? %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index edd8a9e1..239667df 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -6,7 +6,7 @@ <%= display_date(@news_bulletin.postdate) %> <% unit = @news_bulletin.unit_list_for_anc.title rescue nil %> <%= " | " if unit %> - <%= unit %> + <%= link_to unit, panel_news_front_end_index_news_bulletins_by_unit_path(:name=>@news_bulletin.unit_list_for_anc_id)%>
diff --git a/vendor/built_in_modules/news/config/routes.rb b/vendor/built_in_modules/news/config/routes.rb index e78f2874..701136e5 100644 --- a/vendor/built_in_modules/news/config/routes.rb +++ b/vendor/built_in_modules/news/config/routes.rb @@ -34,6 +34,7 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do + match "index_by_unit" => "news_bulletins#index_news_bulletins_by_unit",:as => :index_news_bulletins_by_unit resources :news_bulletins # do # match "preview" => "news_bulletins#preview_content",:as => :get_preview_content # end From 3cb182ff8ed5c5e2f7909942d2cc166a782f1734 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 03:10:26 +0800 Subject: [PATCH 09/30] Add meta to head for fb share --- app/helpers/application_helper.rb | 15 +++++++++++++-- .../front_end/bulletins/show.html.erb | 5 ++--- .../news/front_end/news_bulletins/show.html.erb | 5 +---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 16b0ff09..8fb55315 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -140,7 +140,7 @@ module ApplicationHelper stylesheets << "\n" stylesheets << "\n" end - stylesheets << "\n" + stylesheets << "\n" stylesheets << "\n" if page.design.reset_css stylesheets << "\n" stylesheets << "\n" if page.design.default_css @@ -162,7 +162,7 @@ module ApplicationHelper end javascripts << "\n" javascripts << "\n" - javascripts << "\n" + javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" @@ -214,4 +214,15 @@ module ApplicationHelper object.strftime("%Y-%m-%d") end + def share_links(object) + js = '' + js << "\n" rescue '' + js << "\n" rescue '' + js << "\n" rescue '' + content_tag :div, :class => 'fb' do + concat social_share_button_tag + concat javascript_tag "$('head').append('#{j js}');" + end + end + end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index af1ca12c..2671d2e1 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -36,6 +36,5 @@
<% end %> -
- <%= render "shared/addthis_toolbox"%> -
+ +<%= share_links(@news_bulletin) %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index c6c912c8..38a62828 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -39,7 +39,4 @@ <% end %> -
- <%= social_share_button_tag(@news_bulletin.title) %> - <%#= render "shared/addthis_toolbox"%> -
+<%= share_links(@news_bulletin) %> From fc560f420515c1c94a93857ada7f2fac00cecf35 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 05:40:50 +0800 Subject: [PATCH 10/30] Try fb from override and generated page --- .../lib/social-share-button.coffee | 34 +++++++++++++++++++ app/controllers/application_controller.rb | 7 ++++ app/helpers/application_helper.rb | 7 ++-- app/views/shared/render_share.html.erb | 11 ++++++ .../override_and_new_class_methods.rb | 21 ++++++++++++ config/routes.rb | 2 ++ 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/lib/social-share-button.coffee create mode 100644 app/views/shared/render_share.html.erb diff --git a/app/assets/javascripts/lib/social-share-button.coffee b/app/assets/javascripts/lib/social-share-button.coffee new file mode 100644 index 00000000..8e97d0ef --- /dev/null +++ b/app/assets/javascripts/lib/social-share-button.coffee @@ -0,0 +1,34 @@ +window.SocialShareButton = + openUrl : (url) -> + window.open(url) + false + + share : (el) -> + site = $(el).data('site') + title = encodeURIComponent($(el).parent().data('title')) + img = encodeURIComponent($(el).parent().data("img")) + fb_url = encodeURIComponent($(el).parent().data("fb_url")) + url = encodeURIComponent(location.href) + fb_full_url = encodeURIComponent("#{fb_url}?orig_url=#{location.href}") + switch site + when "weibo" + SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8") + when "twitter" + SocialShareButton.openUrl("https://twitter.com/home?status=#{title}: #{url}") + when "douban" + SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}") + when "facebook" + SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_full_url}") + when "qq" + SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}") + when "tqq" + SocialShareButton.openUrl("http://share.v.t.qq.com/index.php?c=share&a=index&url=#{url}&title=#{title}&pic=#{img}") + when "baidu" + SocialShareButton.openUrl("http://apps.hi.baidu.com/share/?url=#{url}&title=#{title}&content=") + when "kaixin001" + SocialShareButton.openUrl("http://www.kaixin001.com/rest/records.php?url=#{url}&content=#{title}&style=11&pic=#{img}") + when "renren" + SocialShareButton.openUrl("http://widget.renren.com/dialog/share?resourceUrl=#{url}&title=#{title}&description=") + when "google_plus" + SocialShareButton.openUrl("https://plus.google.com/share?url=#{url}&t=#{title}") + false \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5fd9de5c..bf9da2f7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -106,6 +106,13 @@ class ApplicationController < ActionController::Base render :text => '404 Not Found' end end + + def render_share + object_class = params[:model].classify.constantize + @object = object_class.find(params[:id]) + @orig_url = params[:orig_url] + render 'shared/render_share', :layout => false + end protected diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8fb55315..be2ab270 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -162,7 +162,8 @@ module ApplicationHelper end javascripts << "\n" javascripts << "\n" - javascripts << "\n" + # javascripts << "\n" + javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" @@ -220,8 +221,8 @@ module ApplicationHelper js << "\n" rescue '' js << "\n" rescue '' content_tag :div, :class => 'fb' do - concat social_share_button_tag - concat javascript_tag "$('head').append('#{j js}');" + concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") + # concat javascript_tag "$('head').append('#{j js}');" end end diff --git a/app/views/shared/render_share.html.erb b/app/views/shared/render_share.html.erb new file mode 100644 index 00000000..110d30f5 --- /dev/null +++ b/app/views/shared/render_share.html.erb @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/config/initializers/override_and_new_class_methods.rb b/config/initializers/override_and_new_class_methods.rb index 8170d674..07515804 100644 --- a/config/initializers/override_and_new_class_methods.rb +++ b/config/initializers/override_and_new_class_methods.rb @@ -3,3 +3,24 @@ Integer.class_eval do !self.zero? end end + +module SocialShareButton + module Helper + def social_share_button_tag(title = "", opts = {}) + rel = opts[:rel] + html = [] + html << "" + raw html.join("\n") + end + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b281dd33..91a28d60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -140,6 +140,8 @@ Orbit::Application.routes.draw do match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request| !request.query_string.include?("inner=true") } + + match '/share/:model/:id' => 'application#render_share' # routes for gridfs files match "/gridfs/*path" => "gridfs#serve" From f7e6703d5f8e19977ab09c4bc362092b161adea8 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 06:50:28 +0800 Subject: [PATCH 11/30] Change the way the orig_url is passed to fb --- app/assets/javascripts/lib/social-share-button.coffee | 2 +- app/controllers/application_controller.rb | 2 +- app/views/shared/render_share.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/lib/social-share-button.coffee b/app/assets/javascripts/lib/social-share-button.coffee index 8e97d0ef..8a72a2ac 100644 --- a/app/assets/javascripts/lib/social-share-button.coffee +++ b/app/assets/javascripts/lib/social-share-button.coffee @@ -9,7 +9,7 @@ window.SocialShareButton = img = encodeURIComponent($(el).parent().data("img")) fb_url = encodeURIComponent($(el).parent().data("fb_url")) url = encodeURIComponent(location.href) - fb_full_url = encodeURIComponent("#{fb_url}?orig_url=#{location.href}") + fb_full_url = encodeURIComponent("#{fb_url}?orig_host=#{location.host}&orig_path=#{location.pathname}") switch site when "weibo" SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8") diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bf9da2f7..7601f91a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -110,7 +110,7 @@ class ApplicationController < ActionController::Base def render_share object_class = params[:model].classify.constantize @object = object_class.find(params[:id]) - @orig_url = params[:orig_url] + @orig_url = "http://#{params[:orig_host]}/#{params[:orig_path]}" render 'shared/render_share', :layout => false end diff --git a/app/views/shared/render_share.html.erb b/app/views/shared/render_share.html.erb index 110d30f5..33cc4b00 100644 --- a/app/views/shared/render_share.html.erb +++ b/app/views/shared/render_share.html.erb @@ -2,7 +2,7 @@ - + From db16fdc7b5e12a5ad6373777849c9cf5b8afc0f2 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 07:46:10 +0800 Subject: [PATCH 12/30] Change for getting url from key --- app/assets/javascripts/lib/social-share-button.coffee | 3 +-- app/controllers/application_controller.rb | 4 +++- app/helpers/application_helper.rb | 4 ++-- .../panel/announcement/front_end/bulletins/show.html.erb | 2 +- .../views/panel/news/front_end/news_bulletins/show.html.erb | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/lib/social-share-button.coffee b/app/assets/javascripts/lib/social-share-button.coffee index 8a72a2ac..cec9fcbc 100644 --- a/app/assets/javascripts/lib/social-share-button.coffee +++ b/app/assets/javascripts/lib/social-share-button.coffee @@ -9,7 +9,6 @@ window.SocialShareButton = img = encodeURIComponent($(el).parent().data("img")) fb_url = encodeURIComponent($(el).parent().data("fb_url")) url = encodeURIComponent(location.href) - fb_full_url = encodeURIComponent("#{fb_url}?orig_host=#{location.host}&orig_path=#{location.pathname}") switch site when "weibo" SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8") @@ -18,7 +17,7 @@ window.SocialShareButton = when "douban" SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}") when "facebook" - SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_full_url}") + SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_url}") when "qq" SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}") when "tqq" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7601f91a..88c14bfa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -110,7 +110,9 @@ class ApplicationController < ActionController::Base def render_share object_class = params[:model].classify.constantize @object = object_class.find(params[:id]) - @orig_url = "http://#{params[:orig_host]}/#{params[:orig_path]}" + module_app = ModuleApp.first(:conditions => {:key => params[:key]}) + @item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + @orig_url = "http://#{request.host}/#{@item.path}?id=#{@object.id}" render 'shared/render_share', :layout => false end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index be2ab270..e9211c76 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -215,13 +215,13 @@ module ApplicationHelper object.strftime("%Y-%m-%d") end - def share_links(object) + def share_links(object, key) js = '' js << "\n" rescue '' js << "\n" rescue '' js << "\n" rescue '' content_tag :div, :class => 'fb' do - concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") + concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") # concat javascript_tag "$('head').append('#{j js}');" end end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index 2671d2e1..c8cc6bea 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -37,4 +37,4 @@ <% end %> -<%= share_links(@news_bulletin) %> +<%= share_links(@bulletin, 'announcement') %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index 38a62828..a1d4097b 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -39,4 +39,4 @@ <% end %> -<%= share_links(@news_bulletin) %> +<%= share_links(@news_bulletin, 'news') %> From e9de0e24b4c1558ecb759329016e8c50ff23cef4 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 10:12:21 +0800 Subject: [PATCH 13/30] Fix fb share, redirect with js when the page is not requested by fb but by user --- app/controllers/application_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/views/shared/render_share.html.erb | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 88c14bfa..109d4742 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -112,7 +112,7 @@ class ApplicationController < ActionController::Base @object = object_class.find(params[:id]) module_app = ModuleApp.first(:conditions => {:key => params[:key]}) @item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first - @orig_url = "http://#{request.host}/#{@item.path}?id=#{@object.id}" + @orig_url = "http://#{request.host_with_port}/#{@item.path}?id=#{@object.id}" render 'shared/render_share', :layout => false end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e9211c76..63526229 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -163,7 +163,7 @@ module ApplicationHelper javascripts << "\n" javascripts << "\n" # javascripts << "\n" - javascripts << "\n" + javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" diff --git a/app/views/shared/render_share.html.erb b/app/views/shared/render_share.html.erb index 33cc4b00..f8d3c930 100644 --- a/app/views/shared/render_share.html.erb +++ b/app/views/shared/render_share.html.erb @@ -3,8 +3,12 @@ - - + + From cd4c9306da53942f14c557f180a2e95a477dc536 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 10:24:44 +0800 Subject: [PATCH 14/30] Revert useless changes --- .../panel/announcement/back_end/bulletins_controller.rb | 6 +++--- .../back_end/bulletins/_list_bulletin_file.html.erb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 3979ca78..2f38dd08 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 @@ -128,11 +128,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin_file = BulletinFile.new(params[:bulletin_file]) - # respond_to do |format| + respond_to do |format| if @bulletin_file.save - render 'create_bulletin_file',:layout=>false + format.js { render 'create_bulletin_file' } end - # end + end else diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb index ce9ce90c..4fca4715 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb @@ -3,7 +3,7 @@ - + <% end %> 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 23708c13..e3ed67ee 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 @@ -19,12 +19,12 @@ <% @news_bulletins.each do |post| %> - + - + <% end %> From 1cdc0e24bdcef9779c2375046d6da7adcc86a5c7 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 3 Aug 2012 09:30:12 +0800 Subject: [PATCH 21/30] First version of Solr search. --- Gemfile | 5 + Gemfile.lock | 13 + config/initializers/redis_search.rb | 18 - config/sunspot.yml | 4 +- lib/tasks/matt_dev.rake | 17 +- solr/conf/admin-extra.html | 31 + solr/conf/elevate.xml | 36 + solr/conf/mapping-ISOLatin1Accent.txt | 246 +++++ solr/conf/protwords.txt | 21 + solr/conf/schema.xml | 238 +++++ solr/conf/scripts.conf | 24 + solr/conf/solrconfig.xml | 934 ++++++++++++++++++ solr/conf/spellings.txt | 2 + solr/conf/stopwords.txt | 58 ++ solr/conf/synonyms.txt | 31 + .../front_end/bulletins_controller.rb | 8 +- .../announcement/app/models/bulletin.rb | 54 +- .../front_end/news_bulletins_controller.rb | 8 +- .../news/app/models/news_bulletin.rb | 52 +- 19 files changed, 1738 insertions(+), 62 deletions(-) delete mode 100644 config/initializers/redis_search.rb create mode 100644 solr/conf/admin-extra.html create mode 100644 solr/conf/elevate.xml create mode 100644 solr/conf/mapping-ISOLatin1Accent.txt create mode 100644 solr/conf/protwords.txt create mode 100644 solr/conf/schema.xml create mode 100644 solr/conf/scripts.conf create mode 100644 solr/conf/solrconfig.xml create mode 100644 solr/conf/spellings.txt create mode 100644 solr/conf/stopwords.txt create mode 100644 solr/conf/synonyms.txt diff --git a/Gemfile b/Gemfile index 7b12d5c0..138fa838 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,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/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..0a9f7104 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/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/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 685eaa24..d46cbc9f 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 @@ -13,8 +13,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController 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 = Bulletin.solr_search do + fulltext params[:search_query] + #with(:frontend_search,true) + 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..12a725cb 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 @@ -65,11 +65,29 @@ class Bulletin 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| t[1]} + end + # text :text do + # a = (title_translations["zh_tw"] + title_translations["en"]) + # a + # end + boolean :frontend_search do + !is_hidden && !is_pending && is_checked + end + + integer :view_count + string :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,:bulletin_category_id,:is_pending], + # :ext_fields => []) # def gen_title_for_search @@ -78,21 +96,21 @@ class Bulletin #alias_method - def s_title - self.title_translations["zh_tw"] - end + # def s_title + # self.title_translations["zh_tw"] + # 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 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 87826f02..bacb0a31 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 @@ -13,8 +13,12 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController 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 = NewsBulletin.solr_search do + fulltext params[:search_query] + with(:frontend_search,true) + 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..8105917c 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 @@ -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| t[1]} + end + integer :view_count + + boolean :frontend_search do + !is_hidden && !is_pending && is_checked + 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 From 06919e76edf2363ab1dc3a12d6269f6896749ad2 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 3 Aug 2012 12:45:47 +0800 Subject: [PATCH 22/30] fix approval at news and announcement for abnormal flags that causing search result fault. --- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 4 +- lib/tasks/matt_dev.rake | 2 +- lib/tasks/mid_site_sync.rake | 2 +- .../back_end/approvals_controller.rb | 5 +- .../back_end/bulletins_controller.rb | 72 +++++------------ .../front_end/bulletins_controller.rb | 8 +- .../announcement/app/models/bulletin.rb | 78 ++++--------------- .../front_end/bulletins/index.html.erb | 4 +- .../back_end/news_approvals_controller.rb | 5 +- .../back_end/news_bulletins_controller.rb | 9 +++ .../front_end/news_bulletins_controller.rb | 5 +- .../news/app/models/news_bulletin.rb | 36 ++++----- .../front_end/news_bulletins/index.html.erb | 1 - 14 files changed, 83 insertions(+), 149 deletions(-) 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/lib/tasks/matt_dev.rake b/lib/tasks/matt_dev.rake index 0a9f7104..ce0cd509 100644 --- a/lib/tasks/matt_dev.rake +++ b/lib/tasks/matt_dev.rake @@ -10,7 +10,7 @@ namespace :matt_dev do task :searching_02 => :environment do a= Bulletin.solr_search do #("Bulletin",'我',:conditions =>{:is_checked=>true,:is_hidden=>false}) - fulltext '我' + fulltext '關島' with(:frontend_search,true) #with(:is_hidden,true) end 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/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 2f38dd08..60784f05 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 d46cbc9f..ac524859 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 @@ -11,12 +11,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController def index @page = Page.find(params[:page_id]) 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_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) + with(:frontend_search,true) + #order_by(:average_rating) end search_result = @search.results.collect{|result| result.id} diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 12a725cb..1cda9cb4 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -60,7 +60,7 @@ 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 @@ -70,68 +70,39 @@ class Bulletin title_translations.to_a.collect{|t| t[1]} end text :texts do - text_translations.to_a.collect{|t| t[1]} + 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_hidden && !is_pending && is_checked && !is_rejected ) end integer :view_count string :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,: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 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 - #alias_method - - # def s_title - # self.title_translations["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_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 @@ -232,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 45554af0..421a347a 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 @@ -14,8 +14,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| %> > 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 bacb0a31..1d3bb407 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 @@ -11,12 +11,13 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController def index @page = Page.find(params[:page_id]) 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_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) 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 8105917c..8d93dfc4 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -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 @@ -96,12 +96,12 @@ class NewsBulletin title_translations.to_a.collect{|t| t[1]} end text :texts do - text_translations.to_a.collect{|t| t[1]} + 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_hidden && !is_pending && is_checked && !is_rejected ) end @@ -156,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 @@ -229,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 e3ed67ee..c1788d13 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 @@ -9,7 +9,6 @@ <% elsif !params[:search_query].blank? %> <%= t("search.result_get",:search_word => params[:search_query],:item_num=>@news_bulletins.count) %> <% end %> -
<%= t('announcement.bulletin.category') %><%= t('announcement.bulletin.title') %> <%= t('announcement.bulletin.postdate') %>
<%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %><%= (post.bulletin_category.title rescue nil ) %><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> <%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> <%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.title_translations['en'], list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description_translations['en']} ) : list_bulletin_file.title_translations['zh_tw'] %> - + <%= fields_for "bulletin[bulletin_files_attributes][]", list_bulletin_file, :index => list_bulletin_file_counter do |f| %> <%= f.hidden_field :id %> <%= hidden_field_tag :tr, (dom_id list_bulletin_file) %> From ecc5c39840285f20a74c2d39bd3f22c75f4a341a Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 6 Aug 2012 15:13:21 +0800 Subject: [PATCH 15/30] Fix remote upload file for tinymce --- Gemfile | 1 + app/assets/javascripts/new_admin.js | 2 +- app/views/admin/assets/file_upload.html.erb | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 9fb4c3cd..6e07eafa 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,7 @@ gem 'mysql2' gem 'nokogiri' gem 'radius' gem 'rake' +gem 'remotipart' gem 'resque' # background jobs gem 'resque-scheduler' # job scheduling gem 'resque-restriction' diff --git a/app/assets/javascripts/new_admin.js b/app/assets/javascripts/new_admin.js index 949753a9..0c9f30df 100644 --- a/app/assets/javascripts/new_admin.js +++ b/app/assets/javascripts/new_admin.js @@ -17,4 +17,4 @@ //= require side_bar_history //= require rss //= require ajax_form -//= require inc/ajax_setting +//= require jquery.remotipart diff --git a/app/views/admin/assets/file_upload.html.erb b/app/views/admin/assets/file_upload.html.erb index 06141117..2881d5f9 100644 --- a/app/views/admin/assets/file_upload.html.erb +++ b/app/views/admin/assets/file_upload.html.erb @@ -53,9 +53,9 @@
<% end %> - \ No newline at end of file + From 86a3d4a4b1cbed6390f8a9ff0d0a6ffb0bc89e23 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 6 Aug 2012 15:15:44 +0800 Subject: [PATCH 16/30] Remove console.log --- app/assets/javascripts/tinymce_orbit.js.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/tinymce_orbit.js.erb b/app/assets/javascripts/tinymce_orbit.js.erb index 86882530..aa954973 100644 --- a/app/assets/javascripts/tinymce_orbit.js.erb +++ b/app/assets/javascripts/tinymce_orbit.js.erb @@ -47,7 +47,6 @@ function myFileBrowser(field_name, url, type, win) { var cmsURL = window.location.toString(); cmsURL = cmsURL.split("/"); cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>"; - // console.log(cmsURL); // script URL - use an absolute path! if (cmsURL.indexOf("?") < 0) { //add the type as the only query parameter From 292105bdf197ba26a5aba977c75d65e988569670 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 6 Aug 2012 17:34:00 +0800 Subject: [PATCH 17/30] Remove remotipart (not working with ie9) the upload is working except that the pop-up does not disappear in ie --- Gemfile | 2 +- app/assets/javascripts/new_admin.js | 2 +- app/views/admin/assets/file_upload.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 6e07eafa..7b12d5c0 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem 'mysql2' gem 'nokogiri' gem 'radius' gem 'rake' -gem 'remotipart' +# gem 'remotipart' gem 'resque' # background jobs gem 'resque-scheduler' # job scheduling gem 'resque-restriction' diff --git a/app/assets/javascripts/new_admin.js b/app/assets/javascripts/new_admin.js index 0c9f30df..949753a9 100644 --- a/app/assets/javascripts/new_admin.js +++ b/app/assets/javascripts/new_admin.js @@ -17,4 +17,4 @@ //= require side_bar_history //= require rss //= require ajax_form -//= require jquery.remotipart +//= require inc/ajax_setting diff --git a/app/views/admin/assets/file_upload.html.erb b/app/views/admin/assets/file_upload.html.erb index 2881d5f9..8ea1416f 100644 --- a/app/views/admin/assets/file_upload.html.erb +++ b/app/views/admin/assets/file_upload.html.erb @@ -53,7 +53,7 @@
From c8dcc9734d1326be085cb6bc0a77ce96a49a5cf0 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 6 Aug 2012 18:41:29 +0800 Subject: [PATCH 18/30] Change width for site map frontend, add link for more in announcement widget --- app/views/admin/sites/sitemap_frontend.html.erb | 2 +- .../widget/bulletins/bulletins_and_web_links.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/sites/sitemap_frontend.html.erb b/app/views/admin/sites/sitemap_frontend.html.erb index cd8372d3..bf126c90 100644 --- a/app/views/admin/sites/sitemap_frontend.html.erb +++ b/app/views/admin/sites/sitemap_frontend.html.erb @@ -16,7 +16,7 @@ $(document).ready(function(){ $('.site-map').masonry({ itemSelector: '.map-block', - columnWidth: 260, + columnWidth: 220, isAnimated: true }); }); diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb index 50ae0674..9b600a67 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb @@ -5,7 +5,7 @@
-

<%= t("announcement.bulletins") %>

+

<%= link_to t("announcement.bulletins"), panel_announcement_front_end_bulletins_path, :class => 'more' %>

From 9982fd880ff4ba8a2e9fa96bd806e3150a0c97b0 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 7 Aug 2012 11:26:17 +0800 Subject: [PATCH 19/30] Update the path when name is changed in item.rb --- app/models/item.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/item.rb b/app/models/item.rb index f43421af..c20eadde 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -21,7 +21,7 @@ class Item validates_associated :parent, :children before_destroy :destroy_children - after_rearrange :rebuild_path, :if => "parent_id_changed?" + after_rearrange :rebuild_path, :if => "parent_id_changed? || name_changed?" def self.find_by_name(item_name) From c6c8187bda601321835baa5988f307b0733c2f99 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 7 Aug 2012 18:11:39 +0800 Subject: [PATCH 20/30] Changes for design: menu, frontend news and announcement --- app/views/layouts/page_layout.html.erb | 2 +- .../panel/announcement/front_end/bulletins/index.html.erb | 2 +- .../views/panel/news/front_end/news_bulletins/index.html.erb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/page_layout.html.erb b/app/views/layouts/page_layout.html.erb index 0a7240ef..75dbd290 100644 --- a/app/views/layouts/page_layout.html.erb +++ b/app/views/layouts/page_layout.html.erb @@ -1,5 +1,5 @@ - + <%= page_title(@item).html_safe %> 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 1bb363d0..45554af0 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 @@ -22,7 +22,7 @@
<%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> <%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> <%= display_date_time(post.postdate) %><%= display_date_time(post.postdate) %>
<%= image_tag post.image rescue nil %><%= image_tag post.image rescue nil %> <%= link_to post.title, panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %> <%= post.subtitle.html_safe rescue '' %> <%= display_date(post.postdate) %><%= display_date(post.postdate) %>
<%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %>
From 85a556a4a24b75a34182ea3d029562e9d2c6880a Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 6 Aug 2012 16:12:49 +0800 Subject: [PATCH 23/30] first version of fb_share --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/assets/javascripts/application.js | 3 ++- app/assets/stylesheets/application.css | 2 +- app/helpers/application_helper.rb | 2 ++ config/initializers/social_share_button.rb | 3 +++ config/locales/social_share_button.en.yml | 14 ++++++++++++++ config/locales/social_share_button.zh-tw.yml | 14 ++++++++++++++ .../news/front_end/news_bulletins/show.html.erb | 3 ++- 9 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 config/initializers/social_share_button.rb create mode 100644 config/locales/social_share_button.en.yml create mode 100644 config/locales/social_share_button.zh-tw.yml diff --git a/Gemfile b/Gemfile index 138fa838..a12f66dc 100644 --- a/Gemfile +++ b/Gemfile @@ -40,6 +40,8 @@ gem 'progress_bar' gem 'sinatra' gem 'sprockets' +gem 'social-share-button' + gem 'tinymce-rails' gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") gem 'rb-readline' if RUBY_PLATFORM.downcase.include?("linux") diff --git a/Gemfile.lock b/Gemfile.lock index 31bdf08a..96f07221 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -250,6 +250,7 @@ GEM rack (~> 1.3, >= 1.3.6) rack-protection (~> 1.2) tilt (~> 1.3, >= 1.3.3) + social-share-button (0.0.6) spork (0.9.0) spork (0.9.0-x86-mingw32) win32-process @@ -343,6 +344,7 @@ DEPENDENCIES shoulda-matchers simplecov sinatra + social-share-button spork sprockets sunspot-rails-tester diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 13d92690..f3c799cf 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -6,4 +6,5 @@ // //= require jquery //= require jquery_ujs -//= require_tree . \ No newline at end of file +//= require_tree . +//= social-share-button \ No newline at end of file diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 9833ffda..c0c227fe 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -3,5 +3,5 @@ *and any sub-directories. You're free to add application-wide styles to this file and they'll appear at *the top of the compiled file, but it's generally better to create a new file per style scope. *= require_self - + *= require social-share-button */ diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0c6229b3..16b0ff09 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -140,6 +140,7 @@ module ApplicationHelper stylesheets << "\n" stylesheets << "\n" end + stylesheets << "\n" stylesheets << "\n" if page.design.reset_css stylesheets << "\n" stylesheets << "\n" if page.design.default_css @@ -161,6 +162,7 @@ module ApplicationHelper end javascripts << "\n" javascripts << "\n" + javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" diff --git a/config/initializers/social_share_button.rb b/config/initializers/social_share_button.rb new file mode 100644 index 00000000..8b933577 --- /dev/null +++ b/config/initializers/social_share_button.rb @@ -0,0 +1,3 @@ +SocialShareButton.configure do |config| + config.allow_sites = %w(twitter facebook google_plus) +end \ No newline at end of file diff --git a/config/locales/social_share_button.en.yml b/config/locales/social_share_button.en.yml new file mode 100644 index 00000000..7e3f1fb0 --- /dev/null +++ b/config/locales/social_share_button.en.yml @@ -0,0 +1,14 @@ +en: + social_share_button: + share_to: Share to %{name} + weibo: Sina Weibo + twitter: Twitter + facebook: Facebook + douban: Douban + qq: Qzone + tqq: Tqq + delicious: Delicious + baidu: Baidu.com + kaixin001: Kaixin001.com + renren: Renren.com + google_plus: Google+ diff --git a/config/locales/social_share_button.zh-tw.yml b/config/locales/social_share_button.zh-tw.yml new file mode 100644 index 00000000..b0321eb5 --- /dev/null +++ b/config/locales/social_share_button.zh-tw.yml @@ -0,0 +1,14 @@ +zh_tw: + social_share_button: + share_to: 分享到%{name} + weibo: 新浪微博 + twitter: Twitter + facebook: Facebook + douban: 豆瓣 + qq: QQ空間 + tqq: 腾讯微博 + delicious: Delicious + baidu: 百度收藏 + kaixin001: 開心網 + renren: 人人網 + google_plus: Google+ diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index edd8a9e1..c6c912c8 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -40,5 +40,6 @@
- <%= render "shared/addthis_toolbox"%> + <%= social_share_button_tag(@news_bulletin.title) %> + <%#= render "shared/addthis_toolbox"%>
From acf4446523e3c1e952ed83c27fa1d36b7d659881 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 03:10:26 +0800 Subject: [PATCH 24/30] Add meta to head for fb share --- app/helpers/application_helper.rb | 15 +++++++++++++-- .../front_end/bulletins/show.html.erb | 5 ++--- .../news/front_end/news_bulletins/show.html.erb | 5 +---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 16b0ff09..8fb55315 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -140,7 +140,7 @@ module ApplicationHelper stylesheets << "\n" stylesheets << "\n" end - stylesheets << "\n" + stylesheets << "\n" stylesheets << "\n" if page.design.reset_css stylesheets << "\n" stylesheets << "\n" if page.design.default_css @@ -162,7 +162,7 @@ module ApplicationHelper end javascripts << "\n" javascripts << "\n" - javascripts << "\n" + javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" @@ -214,4 +214,15 @@ module ApplicationHelper object.strftime("%Y-%m-%d") end + def share_links(object) + js = '' + js << "\n" rescue '' + js << "\n" rescue '' + js << "\n" rescue '' + content_tag :div, :class => 'fb' do + concat social_share_button_tag + concat javascript_tag "$('head').append('#{j js}');" + end + end + end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index af1ca12c..2671d2e1 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -36,6 +36,5 @@ <% end %> -
- <%= render "shared/addthis_toolbox"%> -
+ +<%= share_links(@news_bulletin) %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index c6c912c8..38a62828 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -39,7 +39,4 @@ <% end %> -
- <%= social_share_button_tag(@news_bulletin.title) %> - <%#= render "shared/addthis_toolbox"%> -
+<%= share_links(@news_bulletin) %> From 4bed925e0f4eb3b8c0be739f331b426026573611 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 05:40:50 +0800 Subject: [PATCH 25/30] Try fb from override and generated page --- .../lib/social-share-button.coffee | 34 +++++++++++++++++++ app/controllers/application_controller.rb | 7 ++++ app/helpers/application_helper.rb | 7 ++-- app/views/shared/render_share.html.erb | 11 ++++++ .../override_and_new_class_methods.rb | 21 ++++++++++++ config/routes.rb | 2 ++ 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/lib/social-share-button.coffee create mode 100644 app/views/shared/render_share.html.erb diff --git a/app/assets/javascripts/lib/social-share-button.coffee b/app/assets/javascripts/lib/social-share-button.coffee new file mode 100644 index 00000000..8e97d0ef --- /dev/null +++ b/app/assets/javascripts/lib/social-share-button.coffee @@ -0,0 +1,34 @@ +window.SocialShareButton = + openUrl : (url) -> + window.open(url) + false + + share : (el) -> + site = $(el).data('site') + title = encodeURIComponent($(el).parent().data('title')) + img = encodeURIComponent($(el).parent().data("img")) + fb_url = encodeURIComponent($(el).parent().data("fb_url")) + url = encodeURIComponent(location.href) + fb_full_url = encodeURIComponent("#{fb_url}?orig_url=#{location.href}") + switch site + when "weibo" + SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8") + when "twitter" + SocialShareButton.openUrl("https://twitter.com/home?status=#{title}: #{url}") + when "douban" + SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}") + when "facebook" + SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_full_url}") + when "qq" + SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}") + when "tqq" + SocialShareButton.openUrl("http://share.v.t.qq.com/index.php?c=share&a=index&url=#{url}&title=#{title}&pic=#{img}") + when "baidu" + SocialShareButton.openUrl("http://apps.hi.baidu.com/share/?url=#{url}&title=#{title}&content=") + when "kaixin001" + SocialShareButton.openUrl("http://www.kaixin001.com/rest/records.php?url=#{url}&content=#{title}&style=11&pic=#{img}") + when "renren" + SocialShareButton.openUrl("http://widget.renren.com/dialog/share?resourceUrl=#{url}&title=#{title}&description=") + when "google_plus" + SocialShareButton.openUrl("https://plus.google.com/share?url=#{url}&t=#{title}") + false \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5fd9de5c..bf9da2f7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -106,6 +106,13 @@ class ApplicationController < ActionController::Base render :text => '404 Not Found' end end + + def render_share + object_class = params[:model].classify.constantize + @object = object_class.find(params[:id]) + @orig_url = params[:orig_url] + render 'shared/render_share', :layout => false + end protected diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8fb55315..be2ab270 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -162,7 +162,8 @@ module ApplicationHelper end javascripts << "\n" javascripts << "\n" - javascripts << "\n" + # javascripts << "\n" + javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" @@ -220,8 +221,8 @@ module ApplicationHelper js << "\n" rescue '' js << "\n" rescue '' content_tag :div, :class => 'fb' do - concat social_share_button_tag - concat javascript_tag "$('head').append('#{j js}');" + concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") + # concat javascript_tag "$('head').append('#{j js}');" end end diff --git a/app/views/shared/render_share.html.erb b/app/views/shared/render_share.html.erb new file mode 100644 index 00000000..110d30f5 --- /dev/null +++ b/app/views/shared/render_share.html.erb @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/config/initializers/override_and_new_class_methods.rb b/config/initializers/override_and_new_class_methods.rb index 8170d674..07515804 100644 --- a/config/initializers/override_and_new_class_methods.rb +++ b/config/initializers/override_and_new_class_methods.rb @@ -3,3 +3,24 @@ Integer.class_eval do !self.zero? end end + +module SocialShareButton + module Helper + def social_share_button_tag(title = "", opts = {}) + rel = opts[:rel] + html = [] + html << "" + raw html.join("\n") + end + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b281dd33..91a28d60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -140,6 +140,8 @@ Orbit::Application.routes.draw do match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request| !request.query_string.include?("inner=true") } + + match '/share/:model/:id' => 'application#render_share' # routes for gridfs files match "/gridfs/*path" => "gridfs#serve" From 6cfdf0f25a24eaf200eb4b0c99d34563614a1444 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 06:50:28 +0800 Subject: [PATCH 26/30] Change the way the orig_url is passed to fb --- app/assets/javascripts/lib/social-share-button.coffee | 2 +- app/controllers/application_controller.rb | 2 +- app/views/shared/render_share.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/lib/social-share-button.coffee b/app/assets/javascripts/lib/social-share-button.coffee index 8e97d0ef..8a72a2ac 100644 --- a/app/assets/javascripts/lib/social-share-button.coffee +++ b/app/assets/javascripts/lib/social-share-button.coffee @@ -9,7 +9,7 @@ window.SocialShareButton = img = encodeURIComponent($(el).parent().data("img")) fb_url = encodeURIComponent($(el).parent().data("fb_url")) url = encodeURIComponent(location.href) - fb_full_url = encodeURIComponent("#{fb_url}?orig_url=#{location.href}") + fb_full_url = encodeURIComponent("#{fb_url}?orig_host=#{location.host}&orig_path=#{location.pathname}") switch site when "weibo" SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8") diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bf9da2f7..7601f91a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -110,7 +110,7 @@ class ApplicationController < ActionController::Base def render_share object_class = params[:model].classify.constantize @object = object_class.find(params[:id]) - @orig_url = params[:orig_url] + @orig_url = "http://#{params[:orig_host]}/#{params[:orig_path]}" render 'shared/render_share', :layout => false end diff --git a/app/views/shared/render_share.html.erb b/app/views/shared/render_share.html.erb index 110d30f5..33cc4b00 100644 --- a/app/views/shared/render_share.html.erb +++ b/app/views/shared/render_share.html.erb @@ -2,7 +2,7 @@ - + From a03d1ad10b5c5048f286afebaf109fc6da1b9d8b Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 07:46:10 +0800 Subject: [PATCH 27/30] Change for getting url from key --- app/assets/javascripts/lib/social-share-button.coffee | 3 +-- app/controllers/application_controller.rb | 4 +++- app/helpers/application_helper.rb | 4 ++-- .../panel/announcement/front_end/bulletins/show.html.erb | 2 +- .../views/panel/news/front_end/news_bulletins/show.html.erb | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/lib/social-share-button.coffee b/app/assets/javascripts/lib/social-share-button.coffee index 8a72a2ac..cec9fcbc 100644 --- a/app/assets/javascripts/lib/social-share-button.coffee +++ b/app/assets/javascripts/lib/social-share-button.coffee @@ -9,7 +9,6 @@ window.SocialShareButton = img = encodeURIComponent($(el).parent().data("img")) fb_url = encodeURIComponent($(el).parent().data("fb_url")) url = encodeURIComponent(location.href) - fb_full_url = encodeURIComponent("#{fb_url}?orig_host=#{location.host}&orig_path=#{location.pathname}") switch site when "weibo" SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8") @@ -18,7 +17,7 @@ window.SocialShareButton = when "douban" SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}") when "facebook" - SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_full_url}") + SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_url}") when "qq" SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}") when "tqq" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7601f91a..88c14bfa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -110,7 +110,9 @@ class ApplicationController < ActionController::Base def render_share object_class = params[:model].classify.constantize @object = object_class.find(params[:id]) - @orig_url = "http://#{params[:orig_host]}/#{params[:orig_path]}" + module_app = ModuleApp.first(:conditions => {:key => params[:key]}) + @item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + @orig_url = "http://#{request.host}/#{@item.path}?id=#{@object.id}" render 'shared/render_share', :layout => false end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index be2ab270..e9211c76 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -215,13 +215,13 @@ module ApplicationHelper object.strftime("%Y-%m-%d") end - def share_links(object) + def share_links(object, key) js = '' js << "\n" rescue '' js << "\n" rescue '' js << "\n" rescue '' content_tag :div, :class => 'fb' do - concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") + concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") # concat javascript_tag "$('head').append('#{j js}');" end end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index 2671d2e1..c8cc6bea 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -37,4 +37,4 @@ <% end %> -<%= share_links(@news_bulletin) %> +<%= share_links(@bulletin, 'announcement') %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index 38a62828..a1d4097b 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -39,4 +39,4 @@ <% end %> -<%= share_links(@news_bulletin) %> +<%= share_links(@news_bulletin, 'news') %> From 05e61b63bbba6279814ed5117d61d180bf1fe409 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 8 Aug 2012 10:12:21 +0800 Subject: [PATCH 28/30] Fix fb share, redirect with js when the page is not requested by fb but by user --- app/controllers/application_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/views/shared/render_share.html.erb | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 88c14bfa..109d4742 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -112,7 +112,7 @@ class ApplicationController < ActionController::Base @object = object_class.find(params[:id]) module_app = ModuleApp.first(:conditions => {:key => params[:key]}) @item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first - @orig_url = "http://#{request.host}/#{@item.path}?id=#{@object.id}" + @orig_url = "http://#{request.host_with_port}/#{@item.path}?id=#{@object.id}" render 'shared/render_share', :layout => false end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e9211c76..63526229 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -163,7 +163,7 @@ module ApplicationHelper javascripts << "\n" javascripts << "\n" # javascripts << "\n" - javascripts << "\n" + javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" diff --git a/app/views/shared/render_share.html.erb b/app/views/shared/render_share.html.erb index 33cc4b00..f8d3c930 100644 --- a/app/views/shared/render_share.html.erb +++ b/app/views/shared/render_share.html.erb @@ -3,8 +3,12 @@ - - + + From fbb53cca360d57da39d7e9948019c194df99bbc8 Mon Sep 17 00:00:00 2001 From: OrbitServer Date: Wed, 8 Aug 2012 11:51:20 +0800 Subject: [PATCH 29/30] Ray's changes for sitemap backend --- app/assets/stylesheets/bootstrap.css.erb | 860 +++++++++++++++++++---- app/assets/stylesheets/style.css.erb | 96 ++- 2 files changed, 780 insertions(+), 176 deletions(-) diff --git a/app/assets/stylesheets/bootstrap.css.erb b/app/assets/stylesheets/bootstrap.css.erb index 62a0afe8..eb17ef12 100644 --- a/app/assets/stylesheets/bootstrap.css.erb +++ b/app/assets/stylesheets/bootstrap.css.erb @@ -1116,381 +1116,959 @@ table .span12 { width: 924px; margin-left: 0; } -[class^="icon-"] { +/* Font Awesome + the iconic font designed for use with Twitter Bootstrap + ------------------------------------------------------- + The full suite of pictographic icons, examples, and documentation + can be found at: http://fortawesome.github.com/Font-Awesome/ + + License + ------------------------------------------------------- + The Font Awesome webfont, CSS, and LESS files are licensed under CC BY 3.0: + http://creativecommons.org/licenses/by/3.0/ A mention of + 'Font Awesome - http://fortawesome.github.com/Font-Awesome' in human-readable + source code is considered acceptable attribution (most common on the web). + If human readable source code is not available to the end user, a mention in + an 'About' or 'Credits' screen is considered acceptable (most common in desktop + or mobile software). + + Contact + ------------------------------------------------------- + Email: dave@davegandy.com + Twitter: http://twitter.com/fortaweso_me + Work: http://lemonwi.se co-founder + + */ +@font-face { + font-family: "FontAwesome"; + src: url(<%= asset_path 'fontawesome-webfont.eot' %>); + src: url(<%= asset_path 'fontawesome-webfont.eot?#iefix' %>) format('eot'), url('../fonts/fontawesome-webfont.woff') format('woff'), url('../fonts/fontawesome-webfont.ttf') format('truetype'), url('../fonts/fontawesome-webfont.svg#FontAwesome') format('svg'); + font-weight: normal; + font-style: normal; +} + +/* Font Awesome styles + ------------------------------------------------------- */ +[class^="icon-"]:before, [class*=" icon-"]:before { + font-family: FontAwesome; + font-weight: normal; + font-style: normal; display: inline-block; - width: 14px; - height: 14px; - vertical-align: text-top; - background-image: url(<%= asset_path 'glyphicons-halflings.png' %>); - background-position: 14px 14px; - background-repeat: no-repeat; - *margin-right: .3em; + text-decoration: inherit; } -[class^="icon-"]:last-child { - *margin-left: 0; +a [class^="icon-"], a [class*=" icon-"] { + display: inline-block; + text-decoration: inherit; } -.icon-white { - background-image: url(<%= asset_path 'glyphicons-halflings-white.png' %>); +/* makes the font 33% larger relative to the icon container */ +.icon-large:before { + vertical-align: top; + font-size: 1.3333333333333333em; +} +.btn [class^="icon-"], .btn [class*=" icon-"] { + /* keeps button heights with and without icons the same */ + + line-height: .9em; +} +li [class^="icon-"], li [class*=" icon-"] { + display: inline-block; + width: 1.25em; + text-align: center; +} +li .icon-large[class^="icon-"], li .icon-large[class*=" icon-"] { + /* 1.5 increased font size for icon-large * 1.25 width */ + + width: 1.875em; +} +li[class^="icon-"], li[class*=" icon-"] { + margin-left: 0; + list-style-type: none; +} +li[class^="icon-"]:before, li[class*=" icon-"]:before { + text-indent: -2em; + text-align: center; +} +li[class^="icon-"].icon-large:before, li[class*=" icon-"].icon-large:before { + text-indent: -1.3333333333333333em; +} +/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen + readers do not read off random characters that represent icons */ +.icon-glass:before { content: "\f000"; } +.icon-music:before { content: "\f001"; } +.icon-search:before { content: "\f002"; } +.icon-envelope:before { content: "\f003"; } +.icon-heart:before { content: "\f004"; } +.icon-star:before { content: "\f005"; } +.icon-star-empty:before { content: "\f006"; } +.icon-user:before { content: "\f007"; } +.icon-film:before { content: "\f008"; } +.icon-th-large:before { content: "\f009"; } +.icon-th:before { content: "\f00a"; } +.icon-th-list:before { content: "\f00b"; } +.icon-ok:before { content: "\f00c"; } +.icon-remove:before { content: "\f00d"; } +.icon-zoom-in:before { content: "\f00e"; } + +.icon-zoom-out:before { content: "\f010"; } +.icon-off:before { content: "\f011"; } +.icon-signal:before { content: "\f012"; } +.icon-cog:before { content: "\f013"; } +.icon-trash:before { content: "\f014"; } +.icon-home:before { content: "\f015"; } +.icon-file:before { content: "\f016"; } +.icon-time:before { content: "\f017"; } +.icon-road:before { content: "\f018"; } +.icon-download-alt:before { content: "\f019"; } +.icon-download:before { content: "\f01a"; } +.icon-upload:before { content: "\f01b"; } +.icon-inbox:before { content: "\f01c"; } +.icon-play-circle:before { content: "\f01d"; } +.icon-repeat:before { content: "\f01e"; } + +/* \f020 doesn't work in Safari. all shifted one down */ +.icon-refresh:before { content: "\f021"; } +.icon-list-alt:before { content: "\f022"; } +.icon-lock:before { content: "\f023"; } +.icon-flag:before { content: "\f024"; } +.icon-headphones:before { content: "\f025"; } +.icon-volume-off:before { content: "\f026"; } +.icon-volume-down:before { content: "\f027"; } +.icon-volume-up:before { content: "\f028"; } +.icon-qrcode:before { content: "\f029"; } +.icon-barcode:before { content: "\f02a"; } +.icon-tag:before { content: "\f02b"; } +.icon-tags:before { content: "\f02c"; } +.icon-book:before { content: "\f02d"; } +.icon-bookmark:before { content: "\f02e"; } +.icon-print:before { content: "\f02f"; } + +.icon-camera:before { content: "\f030"; } +.icon-font:before { content: "\f031"; } +.icon-bold:before { content: "\f032"; } +.icon-italic:before { content: "\f033"; } +.icon-text-height:before { content: "\f034"; } +.icon-text-width:before { content: "\f035"; } +.icon-align-left:before { content: "\f036"; } +.icon-align-center:before { content: "\f037"; } +.icon-align-right:before { content: "\f038"; } +.icon-align-justify:before { content: "\f039"; } +.icon-list:before { content: "\f03a"; } +.icon-indent-left:before { content: "\f03b"; } +.icon-indent-right:before { content: "\f03c"; } +.icon-facetime-video:before { content: "\f03d"; } +.icon-picture:before { content: "\f03e"; } + +.icon-pencil:before { content: "\f040"; } +.icon-map-marker:before { content: "\f041"; } +.icon-adjust:before { content: "\f042"; } +.icon-tint:before { content: "\f043"; } +.icon-edit:before { content: "\f044"; } +.icon-share:before { content: "\f045"; } +.icon-check:before { content: "\f046"; } +.icon-move:before { content: "\f047"; } +.icon-step-backward:before { content: "\f048"; } +.icon-fast-backward:before { content: "\f049"; } +.icon-backward:before { content: "\f04a"; } +.icon-play:before { content: "\f04b"; } +.icon-pause:before { content: "\f04c"; } +.icon-stop:before { content: "\f04d"; } +.icon-forward:before { content: "\f04e"; } + +.icon-fast-forward:before { content: "\f050"; } +.icon-step-forward:before { content: "\f051"; } +.icon-eject:before { content: "\f052"; } +.icon-chevron-left:before { content: "\f053"; } +.icon-chevron-right:before { content: "\f054"; } +.icon-plus-sign:before { content: "\f055"; } +.icon-minus-sign:before { content: "\f056"; } +.icon-remove-sign:before { content: "\f057"; } +.icon-ok-sign:before { content: "\f058"; } +.icon-question-sign:before { content: "\f059"; } +.icon-info-sign:before { content: "\f05a"; } +.icon-screenshot:before { content: "\f05b"; } +.icon-remove-circle:before { content: "\f05c"; } +.icon-ok-circle:before { content: "\f05d"; } +.icon-ban-circle:before { content: "\f05e"; } + +.icon-arrow-left:before { content: "\f060"; } +.icon-arrow-right:before { content: "\f061"; } +.icon-arrow-up:before { content: "\f062"; } +.icon-arrow-down:before { content: "\f063"; } +.icon-share-alt:before { content: "\f064"; } +.icon-resize-full:before { content: "\f065"; } +.icon-resize-small:before { content: "\f066"; } +.icon-plus:before { content: "\f067"; } +.icon-minus:before { content: "\f068"; } +.icon-asterisk:before { content: "\f069"; } +.icon-exclamation-sign:before { content: "\f06a"; } +.icon-gift:before { content: "\f06b"; } +.icon-leaf:before { content: "\f06c"; } +.icon-fire:before { content: "\f06d"; } +.icon-eye-open:before { content: "\f06e"; } + +.icon-eye-close:before { content: "\f070"; } +.icon-warning-sign:before { content: "\f071"; } +.icon-plane:before { content: "\f072"; } +.icon-calendar:before { content: "\f073"; } +.icon-random:before { content: "\f074"; } +.icon-comment:before { content: "\f075"; } +.icon-magnet:before { content: "\f076"; } +.icon-chevron-up:before { content: "\f077"; } +.icon-chevron-down:before { content: "\f078"; } +.icon-retweet:before { content: "\f079"; } +.icon-shopping-cart:before { content: "\f07a"; } +.icon-folder-close:before { content: "\f07b"; } +.icon-folder-open:before { content: "\f07c"; } +.icon-resize-vertical:before { content: "\f07d"; } +.icon-resize-horizontal:before { content: "\f07e"; } + +.icon-bar-chart:before { content: "\f080"; } +.icon-twitter-sign:before { content: "\f081"; } +.icon-facebook-sign:before { content: "\f082"; } +.icon-camera-retro:before { content: "\f083"; } +.icon-key:before { content: "\f084"; } +.icon-cogs:before { content: "\f085"; } +.icon-comments:before { content: "\f086"; } +.icon-thumbs-up:before { content: "\f087"; } +.icon-thumbs-down:before { content: "\f088"; } +.icon-star-half:before { content: "\f089"; } +.icon-heart-empty:before { content: "\f08a"; } +.icon-signout:before { content: "\f08b"; } +.icon-linkedin-sign:before { content: "\f08c"; } +.icon-pushpin:before { content: "\f08d"; } +.icon-external-link:before { content: "\f08e"; } + +.icon-signin:before { content: "\f090"; } +.icon-trophy:before { content: "\f091"; } +.icon-github-sign:before { content: "\f092"; } +.icon-upload-alt:before { content: "\f093"; } +.icon-lemon:before { content: "\f094"; } +.icon-phone:before { content: "\f095"; } +.icon-check-empty:before { content: "\f096"; } +.icon-bookmark-empty:before { content: "\f097"; } +.icon-phone-sign:before { content: "\f098"; } +.icon-twitter:before { content: "\f099"; } +.icon-facebook:before { content: "\f09a"; } +.icon-github:before { content: "\f09b"; } +.icon-unlock:before { content: "\f09c"; } +.icon-credit-card:before { content: "\f09d"; } +.icon-rss:before { content: "\f09e"; } + +.icon-hdd:before { content: "\f0a0"; } +.icon-bullhorn:before { content: "\f0a1"; } +.icon-bell:before { content: "\f0a2"; } +.icon-certificate:before { content: "\f0a3"; } +.icon-hand-right:before { content: "\f0a4"; } +.icon-hand-left:before { content: "\f0a5"; } +.icon-hand-up:before { content: "\f0a6"; } +.icon-hand-down:before { content: "\f0a7"; } +.icon-circle-arrow-left:before { content: "\f0a8"; } +.icon-circle-arrow-right:before { content: "\f0a9"; } +.icon-circle-arrow-up:before { content: "\f0aa"; } +.icon-circle-arrow-down:before { content: "\f0ab"; } +.icon-globe:before { content: "\f0ac"; } +.icon-wrench:before { content: "\f0ad"; } +.icon-tasks:before { content: "\f0ae"; } + +.icon-filter:before { content: "\f0b0"; } +.icon-briefcase:before { content: "\f0b1"; } +.icon-fullscreen:before { content: "\f0b2"; } + +.icon-group:before { content: "\f0c0"; } +.icon-link:before { content: "\f0c1"; } +.icon-cloud:before { content: "\f0c2"; } +.icon-beaker:before { content: "\f0c3"; } +.icon-cut:before { content: "\f0c4"; } +.icon-copy:before { content: "\f0c5"; } +.icon-paper-clip:before { content: "\f0c6"; } +.icon-save:before { content: "\f0c7"; } +.icon-sign-blank:before { content: "\f0c8"; } +.icon-reorder:before { content: "\f0c9"; } +.icon-list-ul:before { content: "\f0ca"; } +.icon-list-ol:before { content: "\f0cb"; } +.icon-strikethrough:before { content: "\f0cc"; } +.icon-underline:before { content: "\f0cd"; } +.icon-table:before { content: "\f0ce"; } + +.icon-magic:before { content: "\f0d0"; } +.icon-truck:before { content: "\f0d1"; } +.icon-pinterest:before { content: "\f0d2"; } +.icon-pinterest-sign:before { content: "\f0d3"; } +.icon-google-plus-sign:before { content: "\f0d4"; } +.icon-google-plus:before { content: "\f0d5"; } +.icon-money:before { content: "\f0d6"; } +.icon-caret-down:before { content: "\f0d7"; } +.icon-caret-up:before { content: "\f0d8"; } +.icon-caret-left:before { content: "\f0d9"; } +.icon-caret-right:before { content: "\f0da"; } +.icon-columns:before { content: "\f0db"; } +.icon-sort:before { content: "\f0dc"; } +.icon-sort-down:before { content: "\f0dd"; } +.icon-sort-up:before { content: "\f0de"; } + +.icon-envelope-alt:before { content: "\f0e0"; } +.icon-linkedin:before { content: "\f0e1"; } +.icon-undo:before { content: "\f0e2"; } +.icon-legal:before { content: "\f0e3"; } +.icon-dashboard:before { content: "\f0e4"; } +.icon-comment-alt:before { content: "\f0e5"; } +.icon-comments-alt:before { content: "\f0e6"; } +.icon-bolt:before { content: "\f0e7"; } +.icon-sitemap:before { content: "\f0e8"; } +.icon-umbrella:before { content: "\f0e9"; } +.icon-paste:before { content: "\f0ea"; } +.icon-user-md:before { content: "\f200"; } + + + + + + + +[class^="icon-"], +[class*=" icon-"] { + font-family: FontAwesome; + font-style: normal; + font-weight: normal; +} +.btn.dropdown-toggle [class^="icon-"], +.btn.dropdown-toggle [class*=" icon-"] { + /* keeps button heights with and without icons the same */ + + line-height: 1.4em; +} +.icon-large { + font-size: 1.3333em; } .icon-glass { - background-position: 0 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-music { - background-position: -24px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-search { - background-position: -48px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-envelope { - background-position: -72px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-heart { - background-position: -96px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-star { - background-position: -120px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-star-empty { - background-position: -144px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-user { - background-position: -168px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-film { - background-position: -192px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-th-large { - background-position: -216px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-th { - background-position: -240px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-th-list { - background-position: -264px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-ok { - background-position: -288px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-remove { - background-position: -312px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-zoom-in { - background-position: -336px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-zoom-out { - background-position: -360px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-off { - background-position: -384px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-signal { - background-position: -408px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-cog { - background-position: -432px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-trash { - background-position: -456px 0; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-home { - background-position: 0 -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-file { - background-position: -24px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-time { - background-position: -48px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-road { - background-position: -72px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-download-alt { - background-position: -96px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-download { - background-position: -120px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-upload { - background-position: -144px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-inbox { - background-position: -168px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-play-circle { - background-position: -192px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-repeat { - background-position: -216px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-refresh { - background-position: -240px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-list-alt { - background-position: -264px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-lock { - background-position: -287px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-flag { - background-position: -312px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-headphones { - background-position: -336px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-volume-off { - background-position: -360px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-volume-down { - background-position: -384px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-volume-up { - background-position: -408px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-qrcode { - background-position: -432px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-barcode { - background-position: -456px -24px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-tag { - background-position: 0 -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-tags { - background-position: -25px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-book { - background-position: -48px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-bookmark { - background-position: -72px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-print { - background-position: -96px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-camera { - background-position: -120px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-font { - background-position: -144px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-bold { - background-position: -167px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-italic { - background-position: -192px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-text-height { - background-position: -216px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-text-width { - background-position: -240px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-align-left { - background-position: -264px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-align-center { - background-position: -288px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-align-right { - background-position: -312px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-align-justify { - background-position: -336px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-list { - background-position: -360px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-indent-left { - background-position: -384px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-indent-right { - background-position: -408px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-facetime-video { - background-position: -432px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-picture { - background-position: -456px -48px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-pencil { - background-position: 0 -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-map-marker { - background-position: -24px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-adjust { - background-position: -48px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-tint { - background-position: -72px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-edit { - background-position: -96px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-share { - background-position: -120px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-check { - background-position: -144px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-move { - background-position: -168px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-step-backward { - background-position: -192px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-fast-backward { - background-position: -216px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-backward { - background-position: -240px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-play { - background-position: -264px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-pause { - background-position: -288px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-stop { - background-position: -312px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-forward { - background-position: -336px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-fast-forward { - background-position: -360px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-step-forward { - background-position: -384px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-eject { - background-position: -408px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-chevron-left { - background-position: -432px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-chevron-right { - background-position: -456px -72px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-plus-sign { - background-position: 0 -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-minus-sign { - background-position: -24px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-remove-sign { - background-position: -48px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-ok-sign { - background-position: -72px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-question-sign { - background-position: -96px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-info-sign { - background-position: -120px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-screenshot { - background-position: -144px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-remove-circle { - background-position: -168px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-ok-circle { - background-position: -192px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-ban-circle { - background-position: -216px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-arrow-left { - background-position: -240px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-arrow-right { - background-position: -264px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-arrow-up { - background-position: -289px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-arrow-down { - background-position: -312px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-share-alt { - background-position: -336px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-resize-full { - background-position: -360px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-resize-small { - background-position: -384px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-plus { - background-position: -408px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-minus { - background-position: -433px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-asterisk { - background-position: -456px -96px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-exclamation-sign { - background-position: 0 -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-gift { - background-position: -24px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-leaf { - background-position: -48px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-fire { - background-position: -72px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-eye-open { - background-position: -96px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-eye-close { - background-position: -120px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-warning-sign { - background-position: -144px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-plane { - background-position: -168px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-calendar { - background-position: -192px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-random { - background-position: -216px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-comment { - background-position: -240px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-magnet { - background-position: -264px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-chevron-up { - background-position: -288px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-chevron-down { - background-position: -313px -119px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-retweet { - background-position: -336px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-shopping-cart { - background-position: -360px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-folder-close { - background-position: -384px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-folder-open { - background-position: -408px -120px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-resize-vertical { - background-position: -432px -119px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-resize-horizontal { - background-position: -456px -118px; + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-bar-chart { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-twitter-sign { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-facebook-sign { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-camera-retro { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-key { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-cogs { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-comments { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-thumbs-up { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-thumbs-down { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-star-half { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-heart-empty { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-signout { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-linkedin-sign { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-pushpin { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-external-link { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-signin { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-trophy { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-github-sign { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-upload-alt { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-lemon { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-phone { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-check-empty { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-bookmark-empty { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-phone-sign { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-twitter { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-facebook { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-github { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-unlock { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-credit-card { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-rss { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-hdd { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-bullhorn { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-bell { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-certificate { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-hand-right { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-hand-left { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-hand-up { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-hand-down { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-circle-arrow-left { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-circle-arrow-right { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-circle-arrow-up { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-circle-arrow-down { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-globe { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-wrench { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-tasks { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-filter { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-briefcase { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-fullscreen { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-group { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-link { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-cloud { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-beaker { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-cut { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-copy { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-paper-clip { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-save { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-sign-blank { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-reorder { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-list-ul { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-list-ol { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-strikethrough { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-underline { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-table { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-magic { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-truck { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-pinterest { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-pinterest-sign { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-google-plus-sign { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-google-plus { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-money { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-caret-down { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-caret-up { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-caret-left { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-caret-right { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-columns { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-sort { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-sort-down { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-sort-up { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-envelope-alt { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-linkedin { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-undo { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-legal { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-dashboard { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-comment-alt { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-comments-alt { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-bolt { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-sitemap { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-umbrella { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-paste { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); +} +.icon-user-md { + *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .dropdown { position: relative; @@ -2665,15 +3243,6 @@ button.btn.small, input[type="submit"].btn.small { .pagination li { display: inline; } - -/*.pagination .page{ - float: left; - padding: 0 14px; - line-height: 34px; - text-decoration: none; - border: 1px solid #ddd; - border-left-width: 0; -}*/ .pagination a { float: left; padding: 0 14px; @@ -3100,6 +3669,15 @@ a.thumbnail:hover { .label-info { background-color: #3a87ad; } +.label-teacher { + background-color: #0071A9; +} +.label-student { + background-color: #AF0045; +} +.label-staff { + background-color: #219C6B; +} @-webkit-keyframes progress-bar-stripes { from { background-position: 0 0; diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index f45faf9c..0ab84c3f 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -31,8 +31,7 @@ padding-bottom: 1px; -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset; -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset; - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset; - + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset; background-image: -moz-linear-gradient(top, #5282A6, #133757); background-image: -ms-linear-gradient(top, #5282A6, #133757); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5282A6), to(#133757)); @@ -40,15 +39,6 @@ background-image: -o-linear-gradient(top, #5282A6, #133757); background-image: linear-gradient(top, #5282A6, #133757); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5282A6', endColorstr='#133757', GradientType=0); - /* - background-image: -moz-linear-gradient(top, #545b60, #191a1c); - background-image: -ms-linear-gradient(top, #545b60, #191a1c); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#545b60), to(#191a1c)); - background-image: -webkit-linear-gradient(top, #545b60, #191a1c); - background-image: -o-linear-gradient(top, #545b60, #191a1c); - background-image: linear-gradient(top, #545b60, #191a1c); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#545b60', endColorstr='#191a1c', GradientType=0); - */ } #orbit-bar .navbar-search { left: 28px; @@ -62,25 +52,20 @@ } #orbit-bar .search-query { padding: 7px 9px 5px; - height: 10px; + height: 11px; margin-top: 3px; border: 1px solid #333333; font-size: 11px; - /*background-color: rgba(255, 255, 255, 0.8); - color: #333; - text-shadow: 0px 1px 0px #FFF;*/ + line-height: 21px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3) inset, 0 1px 0 rgba(255, 255, 255, 0.15); } #orbit-bar .search-query:focus { - /*background-color: rgba(255, 255, 255, 0.9); - text-shadow: 0px 1px 0px #FFF;*/ background-position: 5px 2px; } #orbit-bar .container { width:100%; } #orbit-bar .orbit-logo .brand { - /* background: url(<%= asset_path 'orbit-bar.png' %>) no-repeat -162px -5px; */ background: url(<%= asset_path 'nccu_logo.png' %>) no-repeat 6px 0px; text-indent:-9999px; padding: 5px 20px 4px; @@ -118,8 +103,7 @@ background-position: -10px -10px; } #orbit-bar .nav > li > a.orbit-bar-desktop { - background-position: -73px -42px; - width: 48px; + background-position: -73px -42px;width: 48px; } #orbit-bar .nav > li > a.orbit-bar-member { background-position: -4px -37px; @@ -190,7 +174,7 @@ margin: 0; } #orbit-bar .bar-login .dropdown-menu .log .span2 { - width: 183px; + width: 182px; } #orbit-bar .bar-login .dropdown-menu .log .forgot { margin-bottom: 20px; @@ -286,18 +270,9 @@ background-color: #FFF; margin-left:160px; padding-top: 32px; - /*padding-bottom: 18px;*/ - position: relative; padding-bottom: 45px; - /*min-height: 100%;*/ + position: relative; } -/*#main-wrap > .form-actions { - background-color: #FFF; - text-align: center; - padding: 17px 20px 0; - margin: 0; - border-top: none; -}*/ #main-wrap .subnav { height: auto; min-height: 36px; @@ -378,11 +353,10 @@ #post-body .editor { } #post-body-content { - /*margin-right: 320px;*/ padding: 8px 0 8px 6px; } .filter .accordion-heading > a:hover { - text-decoration: none; + text-decoration: none; } .filter .accordion-group { border-bottom: none; @@ -581,6 +555,22 @@ /*background-color: #AF0045; border-left: 2px solid #AF0045;*/ } +.gender { + position: absolute; + border-radius: 0 0 5px 0; + border-width: 10px; + margin: 0; + border-style: solid; + z-index: 10; + bottom: 0; + right: 0; +} +.gender.male { + border-color: transparent #41B1D5 #41B1D5 transparent; +} +.gender.female { + border-color: transparent #DB186E #DB186E transparent; +} .user-info .roles-nav { margin: 0; position: relative; @@ -642,6 +632,20 @@ min-width: 220px; display: inline-block; float: left; + position: relative; +} +.user-info-basic .gender { + border-radius: 0; + top: 0; + left: 0; + right: auto; + bottom: auto; +} +.user-info-basic .gender.male { + border-color: #41B1D5 transparent transparent #41B1D5; +} +.user-info-basic .gender.female { + border-color: #DB186E transparent transparent #DB186E; } .user-info-roles { padding: 20px; @@ -655,7 +659,7 @@ margin-right: 10px; } .user-avatar .reflective { - background-image: url(img/reflective.png); + background-image: url(<%= asset_path 'reflective.png' %>); background-repeat: no-repeat; background-position: 0; height: 80px; @@ -663,7 +667,7 @@ position: absolute; } .user .user-avatar .reflective { - background-image: url(img/reflective.png); + background-image: url(<%= asset_path 'reflective.png' %>); background-repeat: no-repeat; background-position: 0 -20px; height: 80px; @@ -855,6 +859,7 @@ .site-map .map-block ul { margin: 0px; list-style: none; + width: 220px \9; } .site-map .map-block li { font-size: 12px; @@ -929,6 +934,27 @@ margin-top: 2px; } +.modal.alert-error { + color: #B94A48; + background-color: #F2DEDE; + border-color: #EED3D7; +} +.news_paragraph p { + line-height: 20px; +} +.nav-tabs>li>.edit, .nav-tabs>li>.edit:hover { + background-color: #333; + color: #FFF; + padding-right: 12px; +} +.nav-tabs li .icons-pencil { + float: right; + margin-top: 8px; +} +.nav-tabs li a { + padding-right: 32px; +} + /*icons*/ .the-icons i:after { From e8317e0a4b184cb0ec1b9073cc3275739d233044 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 7 Aug 2012 19:21:54 +0800 Subject: [PATCH 30/30] 1.Remove category column when category is specified 2.Showing category if not in category browsing 3.Redirect to home and show error if app page is not available for user language 4.Showing no context to display if object has no language for it. 5.Browse new and announcement by unit is now applicable. --- Gemfile.lock | 2 ++ app/controllers/pages_controller.rb | 36 ++++++++++++------- app/models/item.rb | 5 ++- app/models/page.rb | 4 +-- app/models/user/user.rb | 5 --- app/views/layouts/page_layout.html.erb | 13 ++++++- config/locales/en.yml | 4 ++- config/locales/zh_tw.yml | 5 ++- config/mongoid.yml | 2 +- lib/parsers/parser_common.rb | 2 +- lib/tasks/data_migration.rake | 13 +++++++ .../front_end/bulletins_controller.rb | 19 +++++++--- .../announcement/app/models/bulletin.rb | 18 ++++++++-- .../front_end/bulletins/index.html.erb | 12 +++++-- .../front_end/bulletins/show.html.erb | 2 +- .../announcement/config/routes.rb | 1 + .../front_end/news_bulletins_controller.rb | 18 +++++++--- .../news/app/models/news_bulletin.rb | 4 +++ .../front_end/news_bulletins/index.html.erb | 4 +++ .../front_end/news_bulletins/show.html.erb | 2 +- vendor/built_in_modules/news/config/routes.rb | 1 + 21 files changed, 130 insertions(+), 42 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 96f07221..463946c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -186,6 +186,7 @@ GEM chinese_pinyin (>= 0.3.0) redis (>= 2.1.1) redis-namespace (~> 1.0.2) + remotipart (1.0.2) resque (1.20.0) multi_json (~> 1.0) redis-namespace (~> 1.0.2) @@ -332,6 +333,7 @@ DEPENDENCIES redis (>= 2.1.1) redis-namespace (~> 1.0.2) redis-search (= 0.7.1) + remotipart resque resque-restriction resque-scheduler diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 4375ba1a..053660a5 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,9 +1,6 @@ class PagesController < ApplicationController - include ApplicationHelper - before_filter :get_item, :only => [:index_from_link, :show_from_link] - # caches_page :index def index @@ -11,7 +8,7 @@ class PagesController < ApplicationController if @item impressionist(@item) - render_page + render_page else render :text => 'You need a home page' end @@ -19,14 +16,15 @@ class PagesController < ApplicationController def show #begin + @item = Item.first(:conditions => {:path => params[:page_name]}) - if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) + if @item && @item.is_published #&& (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) impressionist(@item) case @item.class.to_s - when 'Page' - render_page + when 'Page' + render_page unless save_from_no_lang_for_page when 'Link' - redirect_to @item[:url] + redirect_to(@item[:url]) unless save_from_no_lang_for_page end else render :file => "#{Rails.root}/public/404.html", :status => :not_found @@ -43,15 +41,17 @@ class PagesController < ApplicationController 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? options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank? + options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank? uri = URI::escape(url + options) - redirect_to uri + #uri = URI::escape("#{url}?" + params.collect{|k,v| "#{k}=#{v}"}.join('&')) + redirect_to(uri)unless save_from_no_lang_for_page end def show_from_link url = "/#{@item.path}?id=#{params[:id]}" options = '' options << "&preview=#{params[:preview]}" unless params[:preview].blank? - redirect_to url + options + redirect_to(url + options) unless save_from_no_lang_for_page end def load_orbit_bar @@ -66,12 +66,22 @@ class PagesController < ApplicationController @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]}) @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item elsif !params[:category_id].blank? - @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) + @item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],category: params[:category_id]).any_in(tag: [nil,'']).first elsif !params[:tag_id].blank? - @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => '', :tag => params[:tag_id]}) + @item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first end - @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => '', :tag => ''}) unless @item + @item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item #TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性 end + protected + def save_from_no_lang_for_page + if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s) + flash[:notice] = t('sys.module_page_lang_not_support') + redirect_to '/' + return true + else + return false + end + end end diff --git a/app/models/item.rb b/app/models/item.rb index c20eadde..ae086c7d 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -23,7 +23,10 @@ class Item before_destroy :destroy_children after_rearrange :rebuild_path, :if => "parent_id_changed? || name_changed?" - + def enabled_for_lang(lang) + enabled_for.include?(lang) + end + def self.find_by_name(item_name) Item.first(:conditions => { :name => item_name, :is_published => true }) end diff --git a/app/models/page.rb b/app/models/page.rb index 20a51288..cba692d0 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -6,8 +6,8 @@ class Page < Item field :content field :app_frontend_url field :theme_id, :type => BSON::ObjectId, :default => nil - field :category - field :tag + field :category, :default => '' + field :tag, :default => '' field :view_count, :type => Integer, :default => 0 field :page_title, localize: true diff --git a/app/models/user/user.rb b/app/models/user/user.rb index f51d49f0..4cb00bbb 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -31,12 +31,7 @@ class User VALID_LOCALES.each do |loc| locale = loc.to_sym - # debugger - # if(self.cache_dept.nil?) - # self.build_cache_dept key: "dept_cache_user_#{self.id}" - # end dept_hash[locale] = sub_roles.collect{|sr| sr.title}.join(',') - # self.cache_dept[locale] = sub_roles.collect{|sr| sr.title}.join(',') end self.cache_dept = dept_hash self.save! diff --git a/app/views/layouts/page_layout.html.erb b/app/views/layouts/page_layout.html.erb index 75dbd290..ae73e59d 100644 --- a/app/views/layouts/page_layout.html.erb +++ b/app/views/layouts/page_layout.html.erb @@ -12,6 +12,17 @@ <%= page_javascripts(@item).html_safe %> - <%= yield %> + <%= yield %> + <% if !flash.empty? %> + + + <% end -%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 7a85ddff..a3e295ff 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -298,7 +298,8 @@ en: sys: not_previewable: "Preview not support" limit_of_upload_file_size: "Upload file must be less than: %{best_size}" - + can_not_display_due_to_no_context: "Can not display due to no context for English" + module_page_lang_not_support: "We are sorry, this page is not available for English" search: not_found: "NOT FOUND" domains: Google Search Domains @@ -307,3 +308,4 @@ en: 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?" + unit_get: "Listed items created by :%{unit_name} Found %{item_num} items" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index d1a15773..28bc5e1d 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -445,6 +445,8 @@ zh_tw: result_get: "搜尋有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料" too_many: "搜尋有關 ' %{search_word} ' 尋找到超過 %{exceed_num} 筆資料,請嘗試加入更多關鍵字縮小搜尋範圍,以作更精確的搜尋" + result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料" + unit_get: "列出由:%{unit_name}發佈的資料,共有%{item_num}筆" activerecord: errors: template: # ~ 2.3.5 backward compatible @@ -526,7 +528,8 @@ zh_tw: sys: not_previewable: "不支援預覽" limit_of_upload_file_size: "上傳檔案大小限制: %{best_size}" - + can_not_display_due_to_no_context: "因為沒有中文版本,所以無法顯示" + module_page_lang_not_support: "很抱歉,本頁沒有開放中文版本" object_disable: change_to_true: "設為停用" change_to_false: "重新啓用" \ No newline at end of file diff --git a/config/mongoid.yml b/config/mongoid.yml index 0d68cb7a..219e1372 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -8,7 +8,7 @@ defaults: &defaults development: <<: *defaults - database: prototype_r4_ldap0229 + database: i18n_var test: <<: *defaults diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index eca375a4..6a9390ea 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -180,7 +180,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/lib/tasks/data_migration.rake b/lib/tasks/data_migration.rake index 54d8bd0f..624cf39c 100644 --- a/lib/tasks/data_migration.rake +++ b/lib/tasks/data_migration.rake @@ -83,4 +83,17 @@ namespace :data_migration do puts("#{'='*10}Finished#{'='*10}") end + task :make_bulletin_save_dept_data => :environment do + Bulletin.all.each{|bt| bt.save!} + end + + task :extend_exsisted_app_module_for_dept_search => :environment do + app = ModuleApp.first({:conditions=>{:title => 'news'}}) + app.app_pages << "index_by_unit" if !app.widgets.include?("index_by_unit") + app.save! + app = ModuleApp.first({:conditions=>{:title => 'Announcement'}}) + app.app_pages << "index_by_unit" if !app.widgets.include?("index_by_unit") + app.save! + end + end \ No newline at end of file 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 ac524859..0adc848b 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 @@ -7,7 +7,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController # GET /bulletins # GET /bulletins.xml - + def index_bulletins_by_unit + @page = Page.find(params[:page_id]) + @bulletins=Bulletin.all.available_for_lang(I18n.locale).can_display.where("cache_dept.#{I18n.locale.to_s.downcase}"=>params[:name]).page( params[:page_main]).per(15) + render :index + end + def index @page = Page.find(params[:page_id]) if !params[:search_query].blank? @@ -48,10 +53,14 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController if params[:preview] == "true" preview_content else - @bulletin = Bulletin.all.available_for_lang(I18n.locale).can_display.where(_id: params[:id]).first - unless @bulletin.disable? - impressionist(@bulletin) - get_categorys + @bulletin = Bulletin.all.can_display.where(_id: params[:id]).first + if !@bulletin.disable? + if @bulletin.enabled_for_lang(I18n.locale.to_s) + impressionist(@bulletin) + get_categorys + else + render :text => "
#{t('sys.can_not_display_due_to_no_context')}
".html_safe + end else render :nothing => true, :status => 403 end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 1cda9cb4..f4cf9ae3 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -25,6 +25,8 @@ class Bulletin field :postdate , :type => DateTime field :deadline , :type => DateTime # field :url + field :cache_dept,type: Hash + field :create_user_id field :update_user_id, :class_name => "User" @@ -59,9 +61,10 @@ class Bulletin accepts_nested_attributes_for :bulletin_links, :allow_destroy => true validates :title, :at_least_one => true - - before_save :check_deadline,:update_avliable_language - + + before_save :check_deadline,:update_status,:update_avliable_language + + before_save :fetch_dept after_save :save_bulletin_links after_save :save_bulletin_files @@ -103,6 +106,11 @@ class Bulletin self.save! end + + def enabled_for_lang(lang) + eval("self.available_for_#{lang}") + end + def publish_month published_at.strftime("%B %Y") end @@ -214,4 +222,8 @@ class Bulletin end end + def fetch_dept + self.cache_dept = (User.current.cache_dept rescue nil) || (User.find(self.create_user_id).cache_dept rescue nil) + end + end \ No newline at end of file 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 421a347a..9ba18b9c 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 @@ -7,10 +7,16 @@
- + <%= content_tag (:th) do %> + <%= t('announcement.bulletin.category') %> + <% end if (!params[:search_query].blank? or params[:category_id].blank?)-%> + <% if !params[:name].blank?%> + <%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %> + <% end %> + <% if @bulletins.blank? and !params[:search_query].blank? %> <%=render :partial => 'shared/search_not_found' %> <% elsif !params[:search_query].blank? %> @@ -20,7 +26,9 @@ <% @bulletins.each do |post| %> > - + <%= content_tag(:th) do%> + + <% end if(!params[:search_query].blank? or params[:category_id].blank?) %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index c8cc6bea..a26f9200 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -4,7 +4,7 @@
<%= dislpay_view_count(@bulletin) %> <%= display_date_time(@bulletin.postdate) %> - <%= User.find(@bulletin.create_user_id).cache_dept[I18n.locale.to_s] rescue nil %> + <%= link_to @bulletin.cache_dept[I18n.locale.to_s],panel_announcement_front_end_index_bulletins_by_unit_path(:name=>@bulletin.cache_dept[I18n.locale.to_s]) rescue nil %>
diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index ce6c5ec3..0640a1f0 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -34,6 +34,7 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do + match "index_by_unit" => "bulletins#index_bulletins_by_unit",:as => :index_bulletins_by_unit resources :bulletins # do # match "preview" => "bulletins#preview_content",:as => :get_preview_content # end diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb index 1d3bb407..e2cdf289 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 @@ -8,6 +8,12 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController # GET /news_bulletins # GET /news_bulletins.xml + def index_news_bulletins_by_unit + @page = Page.find(params[:page_id]) + @news_bulletins=NewsBulletin.all.available_for_lang(I18n.locale).can_display.where("unit_list_for_anc_id"=>params[:name]).page( params[:page_main]).per(15).page( params[:page_main]).per(10) + render :index + end + def index @page = Page.find(params[:page_id]) if !params[:search_query].blank? @@ -47,10 +53,14 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController preview_content else '' - @news_bulletin = NewsBulletin.all.available_for_lang(I18n.locale).can_display.where(_id: params[:id]).first - unless @news_bulletin.disable? - impressionist(@news_bulletin) - get_categorys + @news_bulletin = NewsBulletin.all.can_display.where(_id: params[:id]).first + if !@news_bulletin.disable? + if @news_bulletin.enabled_for_lang(I18n.locale.to_s) + impressionist(@news_bulletin) + get_categorys + else + render :text => "
#{t('sys.can_not_display_due_to_no_context')}
".html_safe + end else render :nothing => true, :status => 403 end 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 8d93dfc4..578714c6 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -166,6 +166,10 @@ class NewsBulletin end end + def enabled_for_lang(lang) + eval("self.available_for_#{lang}") + end + def de_pending self.is_pending = false end 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 c1788d13..3324928c 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 @@ -4,6 +4,10 @@

<%= @page.title %>

+<% if !params[:name].blank?%> + <%= t("search.unit_get",:unit_name => UnitListForAnc.find(params[:name]).title,:item_num=>@news_bulletins.count) %> +<% end %> + <% if @news_bulletins.blank? and !params[:search_query].blank? %> <%=render :partial => 'shared/search_not_found' %> <% elsif !params[:search_query].blank? %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index a1d4097b..7366127a 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -6,7 +6,7 @@ <%= display_date(@news_bulletin.postdate) %> <% unit = @news_bulletin.unit_list_for_anc.title rescue nil %> <%= " | " if unit %> - <%= unit %> + <%= link_to unit, panel_news_front_end_index_news_bulletins_by_unit_path(:name=>@news_bulletin.unit_list_for_anc_id)%>
diff --git a/vendor/built_in_modules/news/config/routes.rb b/vendor/built_in_modules/news/config/routes.rb index e78f2874..701136e5 100644 --- a/vendor/built_in_modules/news/config/routes.rb +++ b/vendor/built_in_modules/news/config/routes.rb @@ -34,6 +34,7 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do + match "index_by_unit" => "news_bulletins#index_news_bulletins_by_unit",:as => :index_news_bulletins_by_unit resources :news_bulletins # do # match "preview" => "news_bulletins#preview_content",:as => :get_preview_content # end
<%= t('announcement.bulletin.category') %><%= t('announcement.bulletin.title') %> <%= t('announcement.bulletin.postdate') %>
<%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %><%= (post.bulletin_category.title rescue nil ) %><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> <%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>