diff --git a/app/assets/stylesheets/basic/orbit_bar.css.erb b/app/assets/stylesheets/basic/orbit_bar.css.erb index 082e63d..290f61f 100644 --- a/app/assets/stylesheets/basic/orbit_bar.css.erb +++ b/app/assets/stylesheets/basic/orbit_bar.css.erb @@ -169,11 +169,21 @@ } #search_footer{ - height: 10px; + min-height: 10px; padding: 5px 25px 5px 10px; + border-top: 1px solid #DDD; border-bottom: 1px solid #CCC; color: #666; - /*background: #DDD;*/ + background: #EEE; +} + +#search_footer .pagination{ + margin: 0; +} + +#search_footer .pagination ul li a{ + padding: 4px 10px; + color: #0053CF; } #search_results{ @@ -181,7 +191,10 @@ overflow-y: auto; overflow-x: hidden; } - +#search_results img{ + margin: 20px auto; + display: block; +} #search_results::-webkit-scrollbar { width: 8px; background: #CCC; diff --git a/app/controllers/site_search_controller.rb b/app/controllers/site_search_controller.rb index 307d21d..7d21359 100644 --- a/app/controllers/site_search_controller.rb +++ b/app/controllers/site_search_controller.rb @@ -8,6 +8,7 @@ class SiteSearchController < ApplicationController ] key_string = params[:keywords] + key_string = key_string.strip.nil? ? key_string : key_string.strip keywords = key_string.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/) regex = Regexp.union(keywords.map{|word| Regexp.new(".*"+word+".*", "i")}) @@ -45,7 +46,8 @@ class SiteSearchController < ApplicationController tmp[:content] = "" tmp[:matches] = 0 mod[:fields].each do |f| - value = eval("r.#{f}").gsub(/<\/?[^>]*>/, "").gsub(/ /i,"") rescue "" + value = ActionView::Base.full_sanitizer.sanitize(eval("r.#{f}")) rescue "" + value = value.nil? ? "" : value if f=="title" or f=="name" tmp[:title] = value @@ -62,11 +64,11 @@ class SiteSearchController < ApplicationController result.each do |res| res[:matches] = 0 - res[:matches] += res[:title].match(/(#{key_string})/i) ? 100 : 0 rescue 0 - res[:matches] += res[:content].match(/(#{key_string})/i) ? 100 : 0 rescue 0 + res[:matches] += res[:title].match(/(#{key_string})/i) ? 500 : 0 rescue 0 + res[:matches] += res[:content].match(/(#{key_string})/i) ? 300 : 0 rescue 0 keywords.each do |k| - res[:matches] += res[:title].scan(/(#{k})/i).size + res[:content].scan(/(#{k})/i).size + res[:matches] += (res[:title].scan(/(#{k})/i).size)*100 + res[:content].scan(/(#{k})/i).size res[:title].gsub!(/(#{k})/i, '\1') rescue "" res[:content].gsub!(/(#{k})/i, '\1') rescue "" end @@ -76,7 +78,7 @@ class SiteSearchController < ApplicationController next end - res[:content] = truncate(res[:content], length: 150) + res[:content] = truncate(res[:content], length: 120) end result = result.sort_by { |k| k[:matches] }.reverse rescue [] diff --git a/app/models/page.rb b/app/models/page.rb index 1b6ef08..f36f608 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -3,14 +3,14 @@ class Page < Item include Impressionist::Impressionable include ParserFrontEnd - is_impressionable :counter_cache => { :column_name => :view_count } + is_impressionable field :content, localize: true field :app_frontend_url # field :theme_id, :type => BSON::ObjectId, :default => nil field :category,type: Array, :default => [] field :tag, type: Array,:default => [] - field :view_count, :type => Integer, :default => 0 + # field :view_count, :type => Integer, :default => 0 field :page_title, localize: true field :frontend_style @@ -65,6 +65,10 @@ class Page < Item end end + def view_count + self.impression_count + end + protected def create_parts @@ -97,15 +101,15 @@ class Page < Item end def delete_empty_frontend_field - if self.frontend_field + if self.frontend_field self.frontend_field.reject! { |ff| (ff[0].blank? || ff[1].blank?) } - # self.frontend_field.each do | ff | - # if ff[0].blank? || ff[1].blank? + # self.frontend_field.each do | ff | + # if ff[0].blank? || ff[1].blank? # self.frontend_field.delete("") if self.frontend_field # self.frontend_field.delete(ff) - # end - # end - end + # end + # end + end end def generate_html diff --git a/app/views/layouts/_search.erb b/app/views/layouts/_search.erb index d4c7ba9..c6381fc 100644 --- a/app/views/layouts/_search.erb +++ b/app/views/layouts/_search.erb @@ -3,18 +3,28 @@
- - +