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; + }
<% cats = Array(page.categories) @@ -52,9 +65,16 @@ end all_cat = [[t('announcement.all'),'all']] %> -
+
<%= select_tag('category',options_for_select(all_cat.concat(cats.map{|v| [v.title,v.id.to_s]}),:selected => params['category'].to_s),:id=>"category_select_box",:prompt => t('announcement.select_prompt')) %> - + " placeholder="<%= t('announcement.keywords') %>"> +
+ " placeholder="<%= t('announcement.stime') %>" data-format="yyyy/mm/dd"> +
+ ~ +
+ " placeholder="<%= t('announcement.etime') %>" data-format="yyyy/mm/dd"> +
diff --git a/config/locales/en.yml b/config/locales/en.yml index b9bbd0a..f3dd6ac 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,6 +3,8 @@ en: feed: Feed import: Import announcement: + stime: start time + etime: end time select_prompt: --select category-- all: All keywords: Keywords @@ -95,6 +97,7 @@ en: bulletins_and_web_links: Differential Nav. index: Index search: Search + more: More email_reminder: Email Reminder activate_email_reminder: Activate Email Reminder email_sentdate: Email Time diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 098ba2a..2eba1e2 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -3,6 +3,8 @@ zh_tw: feed: 供給 import: 匯入 announcement: + stime: 開始時間 + etime: 結束時間 select_prompt: --選取類別-- all: 全部 keywords: 關鍵字