修复个人动态首页中留言等动态显示有误的问题

GitlabVersion
sw 11 years ago
parent bed662c2e5
commit 4f2298fd22

@ -256,8 +256,8 @@ module ApplicationHelper
end end
def format_activity_description(text) def format_activity_description(text)
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...') h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />").html_safe
).gsub(/[\r\n]+/, "<br />").html_safe #h(truncate(text.to_s, :length => 120).gsub(/<\/?.*?>/,"")).html_safe
end end
def format_version_name(version) def format_version_name(version)

@ -74,6 +74,12 @@ class News < ActiveRecord::Base
visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all
end end
# 新闻的短描述信息
def short_description(length = 255)
description.gsub(/<\/?.*?>/,"").html_safe if description
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
end
private private
def add_author_as_watcher def add_author_as_watcher

@ -26,7 +26,7 @@
<td align="right"> <td align="right">
<div class="project-search"> <div class="project-search">
<%= text_field_tag 'user', params[:user], :size => 30 %> <%= text_field_tag 'user', params[:user], :size => 30 %>
<%= submit_tag l(:label_search_by_user), :class => "small", :name => nil %> <%= submit_tag l(:label_search_by_user), :class => "small", :name => nil %>
</div> </div>
</td> </td>
</tr> </tr>
@ -51,31 +51,31 @@
<% case e.act_type %> <% case e.act_type %>
<% when 'JournalsForMessage' %> <% when 'JournalsForMessage' %>
<% if User.current.login == e.user.try(:login) %> <% if User.current.login == e.user.try(:login) %>
<%# if e.user_id == act.jour.id %> <%# if e.user_id == act.jour.id %>
<tr><td colspan="2" valign="top"><strong><%= link_to("#{l(:label_i)}", user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_have_feedback) %><%= <tr><td colspan="2" valign="top"><strong><%= link_to("#{l(:label_i)}", user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_have_feedback) %>
link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %></span></td></tr> <%= link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %></span></td></tr>
<%# else %> <%# else %>
<!-- <tr><td colspan="2" valign="top" class="font_lighter"><strong><%#= link_to("#{e.user.name}", user_path(e.user_id)) %> 给 <%#= link_to("#{act.at_user.name if act.at_user}", user_path(act.jour.id)) %> 留言了</strong>&nbsp;</td></tr> --> <!-- <tr><td colspan="2" valign="top" class="font_lighter"><strong><%#= link_to("#{e.user.name}", user_path(e.user_id)) %> 给 <%#= link_to("#{act.at_user.name if act.at_user}", user_path(act.jour.id)) %> 留言了</strong>&nbsp;</td></tr> -->
<%# end %> <%# end %>
<% else %> <% else %>
<tr><td colspan="2" valign="top"><strong><%= link_to("#{e.user.name}", user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_have_feedback) %><%= <tr><td colspan="2" valign="top"><strong><%= link_to("#{e.user.name}", user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_have_feedback) %><%=
link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %></span></td></tr> link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %></span></td></tr>
<% end %> <% end %>
<tr> <tr>
<td colspan="2" width="580"><p class="font_description"> <%= textilizable act.notes %> </p> <td colspan="2" width="580"><p class="font_description"> <%= textilizable act.notes %> </p>
<div style="display: inline-block; float: right; margin-top: 0px"><span><%= link_to(l(:label_goto), user_newfeedback_user_path(e.user_id)) %> <div style="display: inline-block; float: right; margin-top: 0px"><span><%= link_to(l(:label_goto), user_newfeedback_user_path(e.user_id)) %>
</span></div> </span></div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a"> <div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a">
<span class="font_lighter"> <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %></span> <span class="font_lighter"> <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %></span>
</div> </div>
<div style="display: inline-block; float: right; margin-top: 0px"></div> <div style="display: inline-block; float: right; margin-top: 0px"></div>
</td> </td>
</tr> </tr>
<% when 'Bid' %> <% when 'Bid' %>
<tr> <tr>
<% if act.reward_type ==3 %> <% if act.reward_type ==3 %>
@ -92,7 +92,7 @@
<% end %> <% end %>
<% end %> <% end %>
</tr> </tr>
<tr> <td colspan="2" width="580" > <p class="font_description"> <%= h act.description %> </p></td> </tr> <tr> <td colspan="2" width="580" > <p class="font_description"> <%= act.description.html_safe %> </p></td> </tr>
<tr> <tr>
<td> <td>
<div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a"> <div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a">
@ -109,7 +109,7 @@
<td colspan="2" valign="top"><strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= 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}"} %></td> <td colspan="2" valign="top"><strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= 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}"} %></td>
<% end %> <% end %>
</tr> </tr>
<tr> <td colspan="2" width="580" > <p class="font_description"> <%= h act.notes %> </p></td> </tr> <tr> <td colspan="2" width="580" > <p class="font_description"> <%= act.notes.html_safe %> </p></td> </tr>
<tr> <tr>
<td> <td>
<div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a"> <div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a">
@ -126,7 +126,7 @@
<td colspan="2" valign="top"><strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %></td> <td colspan="2" valign="top"><strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %></td>
<% end %> <% end %>
</tr> </tr>
<tr> <td colspan="2" width="580" > <p class="font_description"> <%= h act.long_comments %> </p></td> </tr> <tr> <td colspan="2" width="580" > <p class="font_description"> <%= act.long_comments.html_safe %> </p></td> </tr>
<tr> <tr>
<td> <td>
<div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a"> <div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a">
@ -145,11 +145,11 @@
</tr> </tr>
<tr> <td colspan="2" width="580" > <p class="font_description"> <%= h act.content.truncate(240, omission: '...') %> </p></td> </tr> <tr> <td colspan="2" width="580" > <p class="font_description"> <%= h act.content.truncate(240, omission: '...') %> </p></td> </tr>
<tr> <tr>
<td> <td>
<div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a"> <div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a">
<span class="font_lighter"> <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %></span> <span class="font_lighter"> <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %></span>
</div> </div>
<div style="display: inline-block; float: right; margin-top: 0px"></div> <div style="display: inline-block; float: right; margin-top: 0px"></div>
</td> </td>
</tr> </tr>
<% when 'Principal' %> <% when 'Principal' %>
@ -161,8 +161,8 @@
<% end %> <% end %>
</tr> </tr>
<tr> <td colspan="2" width="580" > <p class="font_description"> </p></td> </tr> <tr> <td colspan="2" width="580" > <p class="font_description"> </p></td> </tr>
<tr> <tr>
<td> <td>
<div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a"> <div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a">
<span class="font_lighter"> <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %></span> <span class="font_lighter"> <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %></span>
</div> </div>
@ -177,7 +177,7 @@
<td colspan="2" valign="top"><strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %></td> <td colspan="2" valign="top"><strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %></td>
<% end %> <% end %>
</tr> </tr>
<tr> <td colspan="2" width="580" > <p class="font_description"> <%= h act.description %> </p></td> </tr> <tr> <td colspan="2" width="580" > <p class="font_description"> <%= act.description.html_safe %> </p></td> </tr>
<tr> <tr>
<td> <td>
<div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a"> <div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a">
@ -193,7 +193,7 @@
<td colspan="2" valign="top"><strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %></td> <td colspan="2" valign="top"><strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %></td>
<% end %> <% end %>
</tr> </tr>
<tr> <td colspan="2" width="580" > <p class="font_description"> <%= textilizable act.description %> </p></td> </tr> <tr> <td colspan="2" width="580" > <p class="font_description"> <%= textilizable(act.description) %> </p></td> </tr>
<tr> <tr>
<td> <td>
<div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a"> <div style="display: inline-block; float: left; margin-top: 0px" width="200" align="right" class="a">
@ -251,7 +251,7 @@
<td> <td>
<table width="580" border="0"> <table width="580" border="0">
<tr> <tr>
<td colspan="2" valign="top"><strong> <%= link_to(h(e.user), user_path(e.user)) %></strong><span class="font_lighter"> <td colspan="2" valign="top"><strong> <%= link_to(h(e.user), user_path(e.user)) %></strong><span class="font_lighter">
<% if e.instance_of?(JournalsForMessage)%> <% if e.instance_of?(JournalsForMessage)%>
<% if e.reply_id == User.current.id%> <% if e.reply_id == User.current.id%>
<%if e.jour_type == 'Bid'%> <%if e.jour_type == 'Bid'%>

@ -39,8 +39,9 @@
</tr> </tr>
<!-- <tr><div class="line_under"></div></tr> --> <!-- <tr><div class="line_under"></div></tr> -->
</table></td> </table></td>
</tr> </tr>
</table>
<% end %> <% end %>
</table><% end %> <% end %>
</div> </div>
<% end %> <% end %>

Loading…
Cancel
Save