From 4dea025c8af932793951f5c4dbde92fb17af40db Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 31 Jul 2012 10:59:48 +0800 Subject: [PATCH] fix for 1.Announcement 15 per page 2.Search keywords. 3.Redis search index with new code. --- config/locales/en.yml | 2 +- config/locales/zh_tw.yml | 2 +- lib/parsers/parser_common.rb | 2 +- .../panel/announcement/front_end/bulletins_controller.rb | 8 ++++---- .../built_in_modules/announcement/app/models/bulletin.rb | 4 ++-- .../panel/announcement/front_end/bulletins/index.html.erb | 4 ++-- .../widget/bulletins/bulletins_search_block.html.erb | 2 +- .../widget/bulletins/bulletins_side_bar.html.erb | 2 +- .../built_in_modules/announcement/config/locales/en.yml | 1 + .../announcement/config/locales/zh_tw.yml | 1 + vendor/built_in_modules/news/app/models/news_bulletin.rb | 4 ++-- .../panel/news/front_end/news_bulletins/index.html.erb | 2 +- .../news_bulletins/news_bulletins_search_block.html.erb | 2 +- .../news_bulletins/news_bulletins_side_bar.html.erb | 2 +- vendor/built_in_modules/news/config/locales/en.yml | 1 + vendor/built_in_modules/news/config/locales/zh_tw.yml | 1 + 16 files changed, 22 insertions(+), 18 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 23b682cb..98a0d1a8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -302,4 +302,4 @@ en: site_search: Site Search sitesearch: Google Site Search site_setting_help: Please Enter the search argument for Google search. - result_get: "Found %{item_num} items" + result_get: "Searched about ' %{search_word} ' Found %{item_num} items" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 15b1c63d..3fbb2574 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -439,7 +439,7 @@ zh_tw: site_search: "全站搜尋" sitesearch: Google Site Search site_setting_help: 請輸入送交Google搜尋的參數 - result_get: "共搜尋到%{item_num}筆資料" + result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料" activerecord: errors: template: # ~ 2.3.5 backward compatible diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 2c57f3f4..988840cd 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -196,7 +196,7 @@ module ParserCommon ret << part.content rescue '' when 'module_widget' url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true" - options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}" + options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}" ret << "
" when 'public_r_tag' ret << "" 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 5629a2d5..113c7f84 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 @@ -15,18 +15,18 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController search = Redis::Search.query("Bulletin", params[:search_query], :conditions =>search_cond,:limit=>Bulletin.all.count) search_result = search.collect{|t| t["id"]} - @bulletins = Bulletin.all.can_display.any_in(_id:search_result).page( params[:page_main]).per(10) + @bulletins = Bulletin.all.can_display.any_in(_id:search_result).page( params[:page_main]).per(15) else date_now = Time.now if !params[:category_id].blank? - @bulletins = Bulletin.all.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) + @bulletins = Bulletin.all.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(15) @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil elsif !params[:tag_id].blank? @tag = AnnouncementTag.find(params[:tag_id]) rescue nil @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) + @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(15) else - @bulletins = Bulletin.all.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) + @bulletins = Bulletin.all.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(15) end end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index b0be2996..d08400aa 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -76,11 +76,11 @@ class Bulletin # end def s_title - self.title_translations[:zh_tw] + self.title_translations["zh_tw"] end def s_title_en - self.title_translations[:en] + self.title_translations["en"] end # def s_text_en 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 62055872..8e512aa6 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,11 +18,11 @@ <% if @bulletins.blank? and !params[:search_query].blank? %> <%=render :partial => 'shared/search_not_found' %> <% elsif !params[:search_query].blank? %> - <%= t("search.result_get",:item_num=>@bulletins.count) %> + <%= t("search.result_get",:search_word => params[:search_query],:item_num=>@bulletins.count) %> <% end %> <% @bulletins.each do |post| %> - <%= post.bulletin_category.title rescue nil %> + <%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %> <%= 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) %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_search_block.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_search_block.html.erb index 31e04d03..1482c782 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_search_block.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_search_block.html.erb @@ -1,6 +1,6 @@ <%= form_tag panel_announcement_front_end_bulletins_path, method: :get do %>

- <%= text_field_tag :search_query, params[:search_query] %> + <%= text_field_tag :search_query, params[:search_query],{:value => (params[:search_query].blank?? '' : params[:search_query]),:placeholder=>t("announcement.search") }%> <%= submit_tag "Search", name: nil %>

<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_side_bar.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_side_bar.html.erb index 789424f0..3cdf1d3d 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_side_bar.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_side_bar.html.erb @@ -13,7 +13,7 @@

<%= t('announcement.tag_cloud') %>

<% @tags.each do |tag| %> - <%= link_to tag[I18n.locale], panel_announcement_front_end_bulletins_path(:tag_id => tag.id),:style=>"font-size: #{100+ tag.cloud_amper * 10}%", :class => "hot#{rand(4) + 1} #{(tag.id.to_s.eql?(params[:tag_id]) || tag.key.eql?(params[:tag_id])) ? 'active' : nil}" %> + <%= link_to tag[I18n.locale], panel_announcement_front_end_bulletins_path(:tag_id => tag.id), :class => "hot#{rand(4) + 1} #{(tag.id.to_s.eql?(params[:tag_id]) || tag.key.eql?(params[:tag_id])) ? 'active' : nil}" %> <% end %>
diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 3d941335..36b4665a 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -62,6 +62,7 @@ en: categories: Categories error: no_avilb_cate_for_posting: You need a category to submit your post,please contact admin + search: Search in announcement sure?: Sure? campus_news: Campus News more: more+ diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index 1752d0ba..21f26ae9 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -42,6 +42,7 @@ zh_tw: no_avilb_cate_for_posting: 您目前沒有分類可以刊登公告,請聯絡系統管理員為您開通分類 tags: 標籤 categories: 分類 + search: 搜尋公告 status: 狀態 sure?: 確定嗎? campus_news: 校園新聞 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 bf468f89..6ad31e04 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -101,11 +101,11 @@ class NewsBulletin # end def s_title - self.title_translations[:zh_tw] + self.title_translations["zh_tw"] end def s_title_en - self.title_translations[:en] + self.title_translations["en"] end # def s_text_en 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 b8749136..f5bc945a 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,7 @@ <% if @news_bulletins.blank? and !params[:search_query].blank? %> <%=render :partial => 'shared/search_not_found' %> <% elsif !params[:search_query].blank? %> - <%= t("search.result_get",:item_num=>@news_bulletins.count) %> + <%= t("search.result_get",:search_word => params[:search_query],:item_num=>@news_bulletins.count) %> <% end %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb index a1ff5639..03b1e5fc 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_search_block.html.erb @@ -1,6 +1,6 @@ <%= form_tag panel_news_front_end_news_bulletins_path, method: :get do %>

- <%= text_field_tag :search_query, params[:search_query] %> + <%= text_field_tag :search_query, params[:search_query],{:value => (params[:search_query].blank?? '' : params[:search_query]),:placeholder=>t("news.search") }%> <%= hidden_field_tag :category_id, params[:category_id] %> <%= submit_tag "Search", name: nil %>

diff --git a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_side_bar.html.erb b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_side_bar.html.erb index a65a0c97..dae7acfb 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_side_bar.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_side_bar.html.erb @@ -13,7 +13,7 @@

<%= t('announcement.tag_cloud') %>

<% @tags.each do |tag| %> - <%= link_to tag[I18n.locale], panel_news_front_end_news_bulletins_path(:tag_id => tag.id), :style => "font-size: #{100+ tag.cloud_amper * 10}%",:class => "hot#{rand(4) + 1} #{(tag.id.to_s.eql?(params[:tag_id]) || tag.key.eql?(params[:tag_id])) ? 'active' : nil}" %> + <%= link_to tag[I18n.locale], panel_news_front_end_news_bulletins_path(:tag_id => tag.id),:class => "hot#{rand(4) + 1} #{(tag.id.to_s.eql?(params[:tag_id]) || tag.key.eql?(params[:tag_id])) ? 'active' : nil}" %> <% end %>
diff --git a/vendor/built_in_modules/news/config/locales/en.yml b/vendor/built_in_modules/news/config/locales/en.yml index 94f3f556..71888726 100644 --- a/vendor/built_in_modules/news/config/locales/en.yml +++ b/vendor/built_in_modules/news/config/locales/en.yml @@ -59,6 +59,7 @@ en: all_articles: List add_new: Add sure?: Sure? + search: Search in news campus_news: Campus News more: more+ news_bulletins: NewsBulletins diff --git a/vendor/built_in_modules/news/config/locales/zh_tw.yml b/vendor/built_in_modules/news/config/locales/zh_tw.yml index 469f2d41..0d65fbff 100644 --- a/vendor/built_in_modules/news/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/news/config/locales/zh_tw.yml @@ -39,6 +39,7 @@ zh_tw: all_articles: 列表 tags: 標籤 categories: 分類 + search: 搜尋新聞 status: 狀態 sure?: 確定嗎? campus_news: 校園新聞