Merge branch 'master' of github.com:Rulingcom/NCCU
This commit is contained in:
		
						commit
						0078c97b19
					
				|  | @ -14,16 +14,34 @@ class Tag | ||||||
|     for_now = {:start_at=>20.days.ago,:end_at=>Time.now} |     for_now = {:start_at=>20.days.ago,:end_at=>Time.now} | ||||||
|     for_yesterday = {:start_at=>19.days.ago,:end_at=>1.days.ago} |     for_yesterday = {:start_at=>19.days.ago,:end_at=>1.days.ago} | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|     range = self.class.all.collect{ |tag| |     range = self.class.all.collect{ |tag| | ||||||
|       get_impressionist_diff(tag) |       get_impressionist_diff(tag) | ||||||
|     } |     } | ||||||
|     (get_impressionist_diff - range.min).abs |     range.sort!.reverse!.uniq! | ||||||
|  |     offset_size = range.size+4 | ||||||
|  |     section_3 =  range.last..range[-(offset_size/4)] | ||||||
|  |     section_2 =  range[-(offset_size/4)-1]..range[-2*(offset_size/4)] rescue nil | ||||||
|  |     section_1 =  range[-2*(offset_size/4)-1]..range[1]  rescue nil | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     case get_impressionist_diff | ||||||
|  |     when range.first | ||||||
|  |       return :heading1 | ||||||
|  |     when section_1 | ||||||
|  |       return :heading2 | ||||||
|  |     when section_2 | ||||||
|  |       return :heading3 | ||||||
|  |     when section_3 | ||||||
|  |       return :heading4 | ||||||
|  |     end | ||||||
|  |      | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
| protected | protected | ||||||
|   def get_impressionist_diff(item_tag = self) |   def get_impressionist_diff(item_tag = self) | ||||||
|       for_now = item_tag.impressionist_count(:start_date=>20.days.ago,:end_date=>Time.now) |       for_now = item_tag.impressions.where(:created_at.gte=> 20.days.ago,:created_at.lte => Time.now).count | ||||||
|       for_yesterday = item_tag.impressionist_count(:start_date=>21.days.ago,:end_date=>1.days.ago) |       for_yesterday = item_tag.impressions.where(:created_at.gte=> 21.days.ago,:created_at.lte => 1.days.ago).count | ||||||
|       for_now - for_yesterday |       for_now - for_yesterday | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -14,5 +14,5 @@ Redis::Search.configure do |config| | ||||||
|   # use rmmseg, true to disable it, it can save memroy |   # use rmmseg, true to disable it, it can save memroy | ||||||
|   config.disable_rmmseg = false |   config.disable_rmmseg = false | ||||||
| end | end | ||||||
| Bulletin.new | # Bulletin.new | ||||||
| NewsBulletin.new | # NewsBulletin.new | ||||||
|  | @ -305,4 +305,4 @@ en: | ||||||
|     site_search: Site Search |     site_search: Site Search | ||||||
|     sitesearch: Google Site Search |     sitesearch: Google Site Search | ||||||
|     site_setting_help: Please Enter the search argument for Google 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" | ||||||
|  |  | ||||||
|  | @ -442,7 +442,7 @@ zh_tw: | ||||||
|     site_search: "全站搜尋" |     site_search: "全站搜尋" | ||||||
|     sitesearch: Google Site Search |     sitesearch: Google Site Search | ||||||
|     site_setting_help: 請輸入送交Google搜尋的參數 |     site_setting_help: 請輸入送交Google搜尋的參數 | ||||||
|     result_get: "共搜尋到%{item_num}筆資料" |     result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料" | ||||||
|   activerecord: |   activerecord: | ||||||
|     errors: |     errors: | ||||||
|       template: # ~ 2.3.5 backward compatible |       template: # ~ 2.3.5 backward compatible | ||||||
|  |  | ||||||
|  | @ -196,7 +196,7 @@ module ParserCommon | ||||||
|           ret << part.content rescue '' |           ret << part.content rescue '' | ||||||
|         when 'module_widget' |         when 'module_widget' | ||||||
|           url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true" |           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 << "<div class='dymanic_load' path='#{url + options}'></div>" |           ret << "<div class='dymanic_load' path='#{url + options}'></div>" | ||||||
|         when 'public_r_tag' |         when 'public_r_tag' | ||||||
|           ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>" |           ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>" | ||||||
|  |  | ||||||
|  | @ -8,4 +8,40 @@ namespace :matt_dev do | ||||||
|     p a |     p a | ||||||
|     # p Pinyin.t('台灣不是中國的一部分') |     # p Pinyin.t('台灣不是中國的一部分') | ||||||
|   end |   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]] | ||||||
|  | 
 | ||||||
|  |   ranges.each{ |range| | ||||||
|  |     cal(range) | ||||||
|  |   } | ||||||
|  |   end | ||||||
|  | def cal(range_t) | ||||||
|  |       range = range_t.sort.reverse | ||||||
|  |       puts '='*20 | ||||||
|  |       puts range.to_s | ||||||
|  |       puts '='*20 | ||||||
|  |       offset_size = range.size+4 | ||||||
|  |         section_3 =  range.last..range[-(offset_size/4)] | ||||||
|  |       puts(section_3) | ||||||
|  |         section_2 =  range[-(offset_size/4)-1]..range[-2*(offset_size/4)] rescue nil | ||||||
|  |       puts(section_2) | ||||||
|  |         section_1 =  range[-2*(offset_size/4)-1]..range[1]  rescue nil | ||||||
|  |       puts(section_1) | ||||||
|  |        | ||||||
|  |       range.each{|num|  | ||||||
|  |         result= case num | ||||||
|  |           when range.first | ||||||
|  |             :heading1 | ||||||
|  |           when section_1 | ||||||
|  |             :heading2 | ||||||
|  |           when section_2 | ||||||
|  |             :heading3 | ||||||
|  |           when section_3 | ||||||
|  |             :heading4 | ||||||
|  |           end | ||||||
|  |         puts "Num:#{num}   Result: #{result}" | ||||||
|  |       }  | ||||||
|  |       puts("END") | ||||||
|  |     end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -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 = Redis::Search.query("Bulletin", params[:search_query], :conditions =>search_cond,:limit=>Bulletin.all.count) | ||||||
|       search_result = search.collect{|t| t["id"]} |       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 |     else | ||||||
|       date_now = Time.now |       date_now = Time.now | ||||||
|       if !params[:category_id].blank? |       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 |         @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil | ||||||
|       elsif !params[:tag_id].blank? |       elsif !params[:tag_id].blank? | ||||||
|         @tag = AnnouncementTag.find(params[:tag_id]) rescue nil |         @tag = AnnouncementTag.find(params[:tag_id]) rescue nil | ||||||
|         @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag |         @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 |       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 | ||||||
|     end |     end | ||||||
| 	   | 	   | ||||||
|  |  | ||||||
|  | @ -76,11 +76,11 @@ class Bulletin | ||||||
|   # end |   # end | ||||||
| 
 | 
 | ||||||
|   def s_title |   def s_title | ||||||
|    self.title_translations[:zh_tw] |    self.title_translations["zh_tw"] | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def s_title_en |   def s_title_en | ||||||
|    self.title_translations[:en] |    self.title_translations["en"] | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   # def s_text_en |   # def s_text_en | ||||||
|  |  | ||||||
|  | @ -18,11 +18,11 @@ | ||||||
|     <% if @bulletins.blank? and !params[:search_query].blank? %> |     <% if @bulletins.blank? and !params[:search_query].blank? %> | ||||||
|       <%=render :partial => 'shared/search_not_found'  %> |       <%=render :partial => 'shared/search_not_found'  %> | ||||||
|       <% elsif  !params[:search_query].blank?  %> |       <% 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 %> |      <% end %> | ||||||
| <% @bulletins.each do |post| %> | <% @bulletins.each do |post| %> | ||||||
|   <tr> |   <tr> | ||||||
| 	<td><%= post.bulletin_category.title rescue nil %></td> | 	<td><%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %></td> | ||||||
| 	<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> | 	<td><%= 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) %> | 	<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> | ||||||
| 	</td> | 	</td> | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| <%= form_tag panel_announcement_front_end_bulletins_path, method: :get do %> | <%= form_tag panel_announcement_front_end_bulletins_path, method: :get do %> | ||||||
|   <p> |   <p> | ||||||
|     <%= 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 %> |     <%= submit_tag "Search", name: nil %> | ||||||
|   </p> |   </p> | ||||||
| <% end %> | <% end %> | ||||||
|  | @ -13,7 +13,7 @@ | ||||||
| 	<h3 class="h3"><%= t('announcement.tag_cloud') %></h3> 								 | 	<h3 class="h3"><%= t('announcement.tag_cloud') %></h3> 								 | ||||||
| 	<div class="cloud"> 		 | 	<div class="cloud"> 		 | ||||||
| 		<% @tags.each do |tag| %>	 | 		<% @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 => "#{tag.cloud_amper} hot#{rand(4) + 1} #{(tag.id.to_s.eql?(params[:tag_id]) || tag.key.eql?(params[:tag_id])) ? 'active' : nil} " %> | ||||||
| 		<% end %> | 		<% end %> | ||||||
| 	</div> 							 | 	</div> 							 | ||||||
| </div> 							 | </div> 							 | ||||||
|  |  | ||||||
|  | @ -62,6 +62,7 @@ en: | ||||||
|     categories: Categories |     categories: Categories | ||||||
|     error:  |     error:  | ||||||
|       no_avilb_cate_for_posting: You need a category to submit your post,please contact admin |       no_avilb_cate_for_posting: You need a category to submit your post,please contact admin | ||||||
|  |     search: Search in announcement | ||||||
|     sure?: Sure? |     sure?: Sure? | ||||||
|     campus_news: Campus News |     campus_news: Campus News | ||||||
|     more: more+ |     more: more+ | ||||||
|  |  | ||||||
|  | @ -42,6 +42,7 @@ zh_tw: | ||||||
|       no_avilb_cate_for_posting: 您目前沒有分類可以刊登公告,請聯絡系統管理員為您開通分類 |       no_avilb_cate_for_posting: 您目前沒有分類可以刊登公告,請聯絡系統管理員為您開通分類 | ||||||
|     tags: 標籤 |     tags: 標籤 | ||||||
|     categories: 分類 |     categories: 分類 | ||||||
|  |     search: 搜尋公告 | ||||||
|     status: 狀態 |     status: 狀態 | ||||||
|     sure?: 確定嗎? |     sure?: 確定嗎? | ||||||
|     campus_news: 校園新聞 |     campus_news: 校園新聞 | ||||||
|  |  | ||||||
|  | @ -101,11 +101,11 @@ class NewsBulletin | ||||||
| # end | # end | ||||||
| 
 | 
 | ||||||
|  def s_title |  def s_title | ||||||
|    self.title_translations[:zh_tw] |     self.title_translations["zh_tw"] | ||||||
|  end |  end | ||||||
| 
 | 
 | ||||||
|  def s_title_en |  def s_title_en | ||||||
|    self.title_translations[:en] |    self.title_translations["en"] | ||||||
|  end |  end | ||||||
| 
 | 
 | ||||||
|  # def s_text_en |  # def s_text_en | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ | ||||||
| 	   <% if @news_bulletins.blank? and !params[:search_query].blank? %> | 	   <% if @news_bulletins.blank? and !params[:search_query].blank? %> | ||||||
| 	   	<%=render :partial => 'shared/search_not_found'  %> | 	   	<%=render :partial => 'shared/search_not_found'  %> | ||||||
| 	   <% elsif  !params[:search_query].blank?  %> | 	   <% 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 %> | 	   <% end %> | ||||||
| <table class="table table-bordered"> | <table class="table table-bordered"> | ||||||
| 	<tbody> | 	<tbody> | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| <%= form_tag panel_news_front_end_news_bulletins_path, method: :get do %> | <%= form_tag panel_news_front_end_news_bulletins_path, method: :get do %> | ||||||
|   <p> |   <p> | ||||||
|     <%= 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] %> |     <%= hidden_field_tag :category_id, params[:category_id] %> | ||||||
|     <%= submit_tag "Search", name: nil %> |     <%= submit_tag "Search", name: nil %> | ||||||
|   </p> |   </p> | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ | ||||||
| 	<h3 class="h3"><%= t('announcement.tag_cloud') %></h3> 								 | 	<h3 class="h3"><%= t('announcement.tag_cloud') %></h3> 								 | ||||||
| 	<div class="cloud"> 		 | 	<div class="cloud"> 		 | ||||||
| 		<% @tags.each do |tag| %>	 | 		<% @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 => "#{tag.cloud_amper} hot#{rand(4) + 1} #{(tag.id.to_s.eql?(params[:tag_id]) || tag.key.eql?(params[:tag_id])) ? 'active' : nil} " %> | ||||||
| 		<% end %>	 | 		<% end %>	 | ||||||
| 	</div> 							 | 	</div> 							 | ||||||
| </div> 							 | </div> 							 | ||||||
|  |  | ||||||
|  | @ -59,6 +59,7 @@ en: | ||||||
|     all_articles: List |     all_articles: List | ||||||
|     add_new: Add |     add_new: Add | ||||||
|     sure?: Sure? |     sure?: Sure? | ||||||
|  |     search: Search in news | ||||||
|     campus_news: Campus News |     campus_news: Campus News | ||||||
|     more: more+ |     more: more+ | ||||||
|     news_bulletins: NewsBulletins |     news_bulletins: NewsBulletins | ||||||
|  |  | ||||||
|  | @ -39,6 +39,7 @@ zh_tw: | ||||||
|     all_articles: 列表 |     all_articles: 列表 | ||||||
|     tags: 標籤 |     tags: 標籤 | ||||||
|     categories: 分類 |     categories: 分類 | ||||||
|  |     search: 搜尋新聞 | ||||||
|     status: 狀態 |     status: 狀態 | ||||||
|     sure?: 確定嗎? |     sure?: 確定嗎? | ||||||
|     campus_news: 校園新聞 |     campus_news: 校園新聞 | ||||||
|  |  | ||||||
		Reference in New Issue