From 11df7d27877a36fe18091f6f511d69f8ead77b65 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 12 Aug 2013 20:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86tag=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/praise_tread_controller.rb | 2 - app/controllers/users_controller.rb | 2 +- app/helpers/praise_tread_helper.rb | 15 +++-- app/views/issues/show.html.erb | 4 +- app/views/layouts/base_bids.html.erb | 2 +- app/views/layouts/base_old.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 2 +- app/views/praise_tread/_praise_tread.html.erb | 12 ++-- app/views/praise_tread/tread_plus.js.erb | 5 ++ app/views/projects/_project.html.erb | 2 +- app/views/tags/_tag.html.erb | 47 ++++++++++++++ app/views/tags/_tag_name.html.erb | 61 ++++++++++++++++++ app/views/users/show_old.html.erb | 2 +- app/views/users/tag_save.js.erb | 4 +- public/images/issue_tag.png | Bin 0 -> 3904 bytes 15 files changed, 137 insertions(+), 25 deletions(-) create mode 100644 app/views/praise_tread/tread_plus.js.erb create mode 100644 app/views/tags/_tag.html.erb create mode 100644 app/views/tags/_tag_name.html.erb create mode 100644 public/images/issue_tag.png diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index 48574bca..0fdb1b2c 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -10,7 +10,6 @@ class PraiseTreadController < ApplicationController @obj_id = params[:obj_id] @obj_type = params[:obj_type] @obj = find_object_by_type_and_id(@obj_type,@obj_id) - # @is_in_list = params[:is_in_list] praise_tread_plus(@obj_type,@obj_id,1) end end @@ -46,7 +45,6 @@ class PraiseTreadController < ApplicationController @obj_id = params[:obj_id] @obj_type = params[:obj_type] @obj = find_object_by_type_and_id(@obj_type,@obj_id) - # @is_in_list = params[:is_in_list] praise_tread_plus(@obj_type,@obj_id,0) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 20494dad..e33104f9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -31,7 +31,7 @@ class UsersController < ApplicationController accept_api_auth :index, :show, :create, :update, :destroy,:tag_save #william - before_filter :need_login,:only => :tag_save + before_filter :require_login,:only => :tag_save helper :sort diff --git a/app/helpers/praise_tread_helper.rb b/app/helpers/praise_tread_helper.rb index 26e4e5f4..90ce6d61 100644 --- a/app/helpers/praise_tread_helper.rb +++ b/app/helpers/praise_tread_helper.rb @@ -9,17 +9,18 @@ module PraiseTreadHelper end #end - def get_praise_num(object,flag) + def get_praise_num(object) @obj_type = object.class @obj_id = object.id @record = PraiseTreadCache.find_by_object_id_and_object_type(@obj_id,@obj_type) if @record - case flag - when 1 - return @record.praise_num.nil? ? 0 : @record.praise_num - when 0 - return @record.tread_num.nil? ? 0 : @record.tread_num - end + # case flag + # when 1 + # return @record.praise_num.nil? ? 0 : @record.praise_num + # when 0 + # return @record.tread_num.nil? ? 0 : @record.tread_num + # end + return (@record.praise_num.to_i-@record.tread_num.to_i) else return 0 end diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 2917bdf4..e03587c5 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -2,6 +2,8 @@

<%= issue_heading(@issue) %>

+> +
<% if @prev_issue_id || @next_issue_id %> diff --git a/app/views/praise_tread/_praise_tread.html.erb b/app/views/praise_tread/_praise_tread.html.erb index 4ed2328c..5c90b972 100644 --- a/app/views/praise_tread/_praise_tread.html.erb +++ b/app/views/praise_tread/_praise_tread.html.erb @@ -1,4 +1,5 @@ + <% if User.current.logged? %>
<% @is_valuate = is_praise_or_tread(obj,user_id)%> @@ -10,7 +11,7 @@ <%= image_tag("/images/praise_tread/praise_true.png") %> - +<%= get_praise_num(obj,1)%> + <%= get_praise_num(obj)%> @@ -24,7 +25,7 @@ - -<%= get_praise_num(obj,0)%> + <%= get_praise_num(obj)%> <%= image_tag("/images/praise_tread/tread_true.png") %> @@ -40,11 +41,7 @@ :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class%> - +<%= get_praise_num(obj,1)%> - - --- - - -<%= get_praise_num(obj,0)%> + <%= get_praise_num(obj)%> <%= link_to image_tag("/images/praise_tread/tread_false.png"),:controller=>"praise_tread", @@ -55,3 +52,4 @@ <% end %>
+<% end %> diff --git a/app/views/praise_tread/tread_plus.js.erb b/app/views/praise_tread/tread_plus.js.erb new file mode 100644 index 00000000..89efec2d --- /dev/null +++ b/app/views/praise_tread/tread_plus.js.erb @@ -0,0 +1,5 @@ + +$('#praise_tread_<%= @obj.id %>').html('<%= j( +render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id} +)%>'); + diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index 33a27076..a89c79e5 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -44,7 +44,7 @@
<%= tag('img', {:src => "/images/sidebar/tags.png"}, false, false) %> - <%= render :partial => 'layouts/tag_name', :locals => {:obj => @project,:object_flag => "2",:non_list_all => true }%> + <%= render :partial => 'tags/tag_name', :locals => {:obj => @project,:object_flag => "2",:non_list_all => true }%>
diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb new file mode 100644 index 00000000..3b3768fb --- /dev/null +++ b/app/views/tags/_tag.html.erb @@ -0,0 +1,47 @@ +
+ <% if User.current.logged? %> + <%= tag('img', {:src => "/images/sidebar/tags.png"}, false, false) %> + <% end %> + + + + <% if object_flag == '3' %> + <% if User.current.logged? %> + <%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form-issue', {:focus => 'name-issue'} %> + <% end %> +
+ <%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %> +
+ +
+ +<% else %> +<% if User.current.logged? %> +<%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form', {:focus => 'name'} %> +<% end %> +
+ <%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %> +
+ + +<% end %> diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb new file mode 100644 index 00000000..ceffa0ad --- /dev/null +++ b/app/views/tags/_tag_name.html.erb @@ -0,0 +1,61 @@ + + +<% @tags = obj.reload.tag_list %> + +<% if non_list_all and (@tags.size > 0) %> + +<% if @tags.size > Setting.show_tags_length.to_i then %> +<% i = 0 %> +<% until i>Setting.show_tags_length.to_i do %> +
+ <%= link_to @tags[i], :controller => "tags",:action => "index",:q => @tags[i],:object_flag => object_flag,:obj_id => obj.id %> +
+<% i += 1%> +<% end %> +<%= link_to l(:label_more_tags),:action => "show",:id => obj.id %> + +<% else %> + +<% @tags.each do |tag| %> +
+ <%= link_to tag,:controller => "tags",:action => "index",:q=>tag,:object_flag => object_flag,:obj_id => obj.id +%> +
+<% end %> +<% end %> + +<% else %> + +<% if @tags.size > 0 %> +<% @tags.each do |tag| %> +
+ <%= link_to tag,:controller => "tags",:action => "index",:q=>tag ,:object_flag => object_flag,:obj_id => obj.id %> +
+<% end %> +<% end %> + +<% end %> \ No newline at end of file diff --git a/app/views/users/show_old.html.erb b/app/views/users/show_old.html.erb index c5eed8d8..9ce6c160 100644 --- a/app/views/users/show_old.html.erb +++ b/app/views/users/show_old.html.erb @@ -149,7 +149,7 @@
- <%= render :partial => 'layouts/tag', :locals => {:obj => @user,:object_flag => "1"}%> + <%= render :partial => 'tags/tag', :locals => {:obj => @user,:object_flag => "1"}%>
diff --git a/app/views/users/tag_save.js.erb b/app/views/users/tag_save.js.erb index a5a07b0b..6b13f6b4 100644 --- a/app/views/users/tag_save.js.erb +++ b/app/views/users/tag_save.js.erb @@ -1,12 +1,12 @@ <% if @obj_flag == '3'%> -$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'layouts/tag_name', +$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); $('#put-tag-form-issue').hide(); $('#name-issue').val(""); <% else %> -$('#tags_show').html('<%= escape_javascript(render :partial => 'layouts/tag_name', +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); $('#put-tag-form').hide(); $('#name').val(""); diff --git a/public/images/issue_tag.png b/public/images/issue_tag.png new file mode 100644 index 0000000000000000000000000000000000000000..eacaf7a549a238c9110f7e747dbcc63f7efb0a53 GIT binary patch literal 3904 zcmeHK=Tj4Y(*Ht02uP6@ige+p0@5u=Ab?1~&_Y+~N^e3ap~L_pC;~y6RB1{vpeRa2 zno2bk0YQ4N1_&ML$IU$Np8E@KZfD!<&g|@dW?$?+F*49$Vd7^30I=vHZ=eC7**x)4 zjF1yeocqXiVxT@qD?b33IsYv*AR~(x049A`EiEG>7jKNWpNqGTh_05Fh>x$gldH#l z0D^|HO#&^Gc6ijrckZ*9YYwbdqxYeE4x)b`*UFbh@At`6cxi{&c%Hu3u)FE z(Z__$j+x3mPjc3H8go0=?C#YS;gO<`VZqep<^A9LHS<~X2c6h1HvAb5$;7#QH*gId zrK&O@oM4D-Y^%l7aw8|`MA+xZ-<;{209b`!gK(I4>IXD$y#X!o>AQ4}qh<0qvf4<} z0*EAn2{Dd&W*Pz-v|ci8kFKf{=I3T6=bYv}sGCjsNA9cMVrrsm<3}~mXz2jE zK^Jw%c6PQO;?qL&&cEKh+}lh)gLh-GR}Tkn3TMwYGwrBMsE1U zcNz?*zj6^9ShKzg)-=Fq?N8l6oIcl}%C32827i_*k2h6=&$K~hfbQcv2!HOGj7j#& zuku$}<|jDrhEsfCr|fuhzVX&PhSF)YGIH9Bs>Gaeh#wH^WQ3*1(}~$5m7e1ZMHXYY zjK!K-eG6$zG~E)dk>cwzzFgPh?jrUG!>u9;P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