diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index 276d03b..59eedf0 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -130,15 +130,34 @@ module AnnouncementsHelper end fans end - def filter_by_keywords(sorted,keywords) - if !keywords.to_s.empty? + def filter_by_keywords(sorted,keywords,stime,etime) + kflag = keywords.blank? + sflag = stime.blank? + eflag = etime.blank? + stime = stime.to_s.split('/') + stime = Time.zone.local(*stime) rescue nil + etime = etime.to_s.split('/') + etime = Time.zone.local(*etime) rescue nil + if !kflag || !sflag || !eflag sorted.select{|anns| - if anns["source-site"].present? - title = Nokogiri::HTML(anns["title"].to_s).text + if kflag + flag = true else - title = Nokogiri::HTML(anns.title.to_s).text + if anns["source-site"].present? + title = Nokogiri::HTML(anns["title"].to_s).text + else + title = Nokogiri::HTML(anns.title.to_s).text + end + flag = title.include?(keywords.to_s) end - title.include?(keywords.to_s) + if sflag && !eflag + flag = flag && (anns.postdate<=etime) + elsif !sflag && eflag + flag = flag && (anns.postdate>=stime) + elsif !sflag && !eflag + flag = flag && (anns.postdate>=stime) && (anns.postdate<=etime) + end + flag } else sorted @@ -201,9 +220,9 @@ module AnnouncementsHelper else all_sorted = feeds_anns.select{|v| v['is_top']}.sort{|v1,v2| v2["postdate"]<=>v1["postdate"]} + feeds_anns.select{|v| v['is_top'] != true}.sort{|v1,v2| v2["postdate"]<=>v1["postdate"]} end - all_filter = filter_by_keywords(all_sorted,params[:keywords]) + all_filter = filter_by_keywords(all_sorted,params[:keywords],params[:stime].params[:etime]) else - all_filter = filter_by_keywords(announcements,params[:keywords]) + all_filter = filter_by_keywords(announcements,params[:keywords],params[:stime],params[:etime]) end if page_data_count != 0 sorted = all_filter[(page_number-1)*page_data_count...page_number*page_data_count] diff --git a/app/views/announcements/index.html.erb b/app/views/announcements/index.html.erb index f767ddb..f00b115 100644 --- a/app/views/announcements/index.html.erb +++ b/app/views/announcements/index.html.erb @@ -30,7 +30,8 @@ input.search_box{ margin: 0; background: #a2c3df; - color: #9100ff; + font-weight: bold; + color: #00008b; border-radius: 0.7em; outline: 0; } @@ -42,6 +43,18 @@ background: #7201ff; color: white; } + input.search_box::-webkit-input-placeholder { + color: #aa58e8; + opacity: 1; + } + input.search_box:-moz-placeholder { + color: #aa58e8; + opacity: 1; + } + input.search_box::-moz-placeholder { + color: #aa58e8; + opacity: 1; + }