From 4f2298fd2230f964778f01f5434d8c5402bb03a6 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Jul 2014 10:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AA=E4=BA=BA=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E9=A6=96=E9=A1=B5=E4=B8=AD=E7=95=99=E8=A8=80=E7=AD=89?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=98=BE=E7=A4=BA=E6=9C=89=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 4 +- app/models/news.rb | 6 +++ app/views/users/show.html.erb | 60 ++++++++++++------------ app/views/users/user_activities.html.erb | 5 +- 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6bbf6ed6..0a84b7a55 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -256,8 +256,8 @@ module ApplicationHelper end def format_activity_description(text) - h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...') - ).gsub(/[\r\n]+/, "
").html_safe + h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "
").html_safe + #h(truncate(text.to_s, :length => 120).gsub(/<\/?.*?>/,"")).html_safe end def format_version_name(version) diff --git a/app/models/news.rb b/app/models/news.rb index 9a0f8b75c..66e339291 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -74,6 +74,12 @@ class News < ActiveRecord::Base visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all end + # 新闻的短描述信息 + def short_description(length = 255) + description.gsub(/<\/?.*?>/,"").html_safe if description + #description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description + end + private def add_author_as_watcher diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index ec469a5b9..f2fa522cd 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -26,7 +26,7 @@ @@ -51,31 +51,31 @@ <% case e.act_type %> <% when 'JournalsForMessage' %> <% if User.current.login == e.user.try(:login) %> - <%# if e.user_id == act.jour.id %> - <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%= - link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %> + <%# if e.user_id == act.jour.id %> + <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %> + <%= link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %> <%# else %> <%# end %> <% else %> - <%= link_to("#{e.user.name}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%= - link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %> + <%= link_to("#{e.user.name}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%= + link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %> <% end %> - -

<%= textilizable act.notes %>

-
<%= link_to(l(:label_goto), user_newfeedback_user_path(e.user_id)) %> -
- - + +

<%= textilizable act.notes %>

+
<%= link_to(l(:label_goto), user_newfeedback_user_path(e.user_id)) %> +
+ + - - -
- <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> -
-
- - + + +
+ <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
+ + <% when 'Bid' %> <% if act.reward_type ==3 %> @@ -92,7 +92,7 @@ <% end %> <% end %> -

<%= h act.description %>

+

<%= act.description.html_safe %>

@@ -109,7 +109,7 @@ <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to( l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.identifier))%> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %> <% end %> -

<%= h act.notes %>

+

<%= act.notes.html_safe %>

@@ -126,7 +126,7 @@ <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %> <% end %> -

<%= h act.long_comments %>

+

<%= act.long_comments.html_safe %>

@@ -145,11 +145,11 @@

<%= h act.content.truncate(240, omission: '...') %>

- +
<%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %>
-
+
<% when 'Principal' %> @@ -161,8 +161,8 @@ <% end %>

- - + +
<%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %>
@@ -177,7 +177,7 @@ <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %> <% end %> -

<%= h act.description %>

+

<%= act.description.html_safe %>

@@ -193,7 +193,7 @@ <%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %> <% end %> -

<%= textilizable act.description %>

+

<%= textilizable(act.description) %>

@@ -251,7 +251,7 @@ -
<%= link_to(h(e.user), user_path(e.user)) %> + <%= link_to(h(e.user), user_path(e.user)) %> <% if e.instance_of?(JournalsForMessage)%> <% if e.reply_id == User.current.id%> <%if e.jour_type == 'Bid'%> diff --git a/app/views/users/user_activities.html.erb b/app/views/users/user_activities.html.erb index faea90fd3..2b4cf8819 100644 --- a/app/views/users/user_activities.html.erb +++ b/app/views/users/user_activities.html.erb @@ -39,8 +39,9 @@
- + + <% end %> -<% end %> +<% end %>
<% end %>