一级回复与点赞功能

This commit is contained in:
daiao 2017-09-28 15:28:03 +08:00
parent e4f304d431
commit bfd4ee86ec
13 changed files with 461 additions and 187 deletions

View File

@ -185,13 +185,10 @@ class ForumsController < ApplicationController
end
@memo = Memo.new(:forum => @forum)
@topic_count = @forum.topics.count
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@memos = @forum.topics.includes(:last_reply).
limit(@topic_pages.per_page).
offset(@topic_pages.offset).
reorder(order).
preload(:author, {:last_reply => :author}).
all
@limit = 20
@is_remote = true
@topic_pages = Paginator.new @topic_count, @limit, params['page'] || 1
@memos = paginateHelper @forum.topics.includes(:last_reply).reorder(order).preload(:author, {:last_reply => :author}), @limit
@my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and parent_id is null").count
@my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and parent_id is not null").count
@errors = params[:errors]

View File

@ -1,6 +1,6 @@
class MemosController < ApplicationController
default_search_scope :memos
before_filter :find_forum, :only => [:new, :create, :preview, :update]
before_filter :find_forum, :only => [:new, :create, :preview, :update, :reply]
before_filter :find_attachments, :only => [:preview]
before_filter :find_memo, :except => [:new, :create, :preview]
before_filter :authenticate_user_edit, :only => [:edit, :update]
@ -88,6 +88,7 @@ class MemosController < ApplicationController
REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE)
def show
@user = User.current
# 更新贴吧帖子留言对应的memo_messages的viewed字段
unless @memo.children.blank?
@memo.children.each do |child|
@ -141,7 +142,7 @@ class MemosController < ApplicationController
respond_to do |format|
format.js
format.html {render :layout => 'base_new_forum'}
format.html {render :layout => 'base_edu'}
format.json { render json: @memo }
format.xml { render xml: @memo }
end
@ -182,6 +183,52 @@ class MemosController < ApplicationController
end
end
def reply
if params[:parent_id]
parent = Memo.find params[:memo][:parent_id]
@memo = params[:activity_id].blank? ? parent : Memo.find(params[:activity_id].to_i)
@reply = Memo.new
@reply.author = User.current
@reply.forum_id = parent.forum_id
@reply.content = params[:memo][:content]
@reply.subject = "RE: #{@memo.subject}"
#@reply.reply_id = params[:id]
@reply.root_id = parent.root_id.nil? ? parent.id : parent.root_id
# @reply.reply_id = params[:id]
parent.children << @reply
else
@reply = Memo.new()
@reply.content = params[:content]
@reply.subject = @memo.subject
@reply.author = User.current
@reply.forum_id = @forum.id
#@reply.content = @quote + @reply.content
#@reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
@reply.root_id = @memo.id
@reply.safe_attributes = params[:reply]
@memo.children << @reply
# @reply.reply_id = params[:id]
end
redirect_to message_replies_forum_memo_path(@memo.forum, @memo)
end
def message_replies
@replies = Memo.where(:root_id => @memo.id).order("created_at desc")
@reply_count = @replies.count
@replies = get_no_children_comments_all @replies
#@limit_count = @replies.count
#@page = params[:page] ? params[:page].to_i + 1 : 0
#@limit = 10
#@replies = @replies[@page * @limit..@page * @limit + 9]
@reply = Message.new()
@user_activity_id = params[:user_activity_id].blank? ? @memo.id : params[:user_activity_id].to_i
respond_to do |format|
format.js
end
end
def destroy
@memo.destroy

View File

@ -29,11 +29,13 @@
<div id="forum_list" class="forum_table mh650">
<% @memos.each_with_index do |memo, index| %>
<div class="forum_table_item">
<a class="fr mr15"><img src="http://tx.haiqq.com/uploads/allimg/150331/214H3HN-8.jpg" class="bor-radius-all mt3" width="50" height="50"/></a>
<a class="fr mr15">
<%= image_tag(url_to_avatar(memo.author), :width => 50, :height => 50,:alt=>'用户头像', :class=>"bor-radius-all mt3" ) %>
</a>
<div class="fl color-grey pr" style="flex: 1;">
<a href="javascript:void(0)"><%= User.find(memo.author_id).try(:show_name) %></a>
<a href="<%= user_path(memo.author_id) %>" ><%= User.find(memo.author_id).try(:show_name) %></a>
<p class="font-16">
<a href="javascript:void(0)" class="clearfix item_name"><%= memo.subject %></a>
<a href="<%= forum_memo_path(memo.forum, memo) %>" class="clearfix item_name" target="_blank"><%= memo.subject %></a>
</p>
<p style="width: 1103px;" class="overellipsis"><%= memo.content %></p>
<p class="clearfix font-12 mt5">
@ -46,7 +48,7 @@
<div class="edu-position-hidebox" style="position: absolute;right: 10px;top:0px;">
<a href="javascript:void(0);"><i class="fa fa-bars font-16"></i></a>
<ul class="edu-position-hide undis">
<li><a href="javascript:void(0)">精&nbsp;&nbsp;选</a></li>
<li><a href="javascript:void(0)">置&nbsp;&nbsp;顶</a></li>
<li><a href="javascript:void(0);">编&nbsp;&nbsp;辑</a></li>
<li><a href="javascript:void(0)">删&nbsp;&nbsp;除</a></li>
</ul>
@ -58,11 +60,7 @@
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<li><a href="javascript:void(0)" class="pages-big" data-remote="true">上一页</a></li>
<li><a class="active">1</a></li>
<li><a href="javascript:void(0)" class="page c_blue" data-remote="true">2</a></li>
<li><a href="javascript:void(0)" class="page c_blue" data-remote="true">3</a></li>
<li><a href="javascript:void(0)" class="pages-big pages-border-right" data-remote="true">下一页</a></li>
<%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>

View File

@ -0,0 +1,112 @@
<div class="panel-mes-head clearfix">
<h4 class="fl">全部回复<span class="ml5">(<%= count %>)</span></h4>
<p class="fr mr15">
<a href="javascript:void(0);" class="mr15 white-btn orange-btn" onclick="editor_focus(<%= memo.id %>);"><i class="fa fa-comments-o mr5"></i>回复<!--<span class="ml5"><%#= count %></span>--></a>
<!--<span class="mr10 color-grey"><i class="fa fa-eye color-grey mr5"></i><%#= @topic.visits %></span>-->
<!--<span id="praise_count_<%#=activity.id %>">
<%#= render :partial => 'praise_tread/edu_praise', :locals => {:activity=>activity, :user_activity_id=>activity.id,:type=>"activity"} %>
</span>-->
<span id="praise_count_<%= memo.id %>" class="fr mr10">
<%= render :partial => 'praise_tread/activity_praise', :locals => {:activity => memo, :user_activity_id => memo.id, :type => "Memo"} %>
</span>
</p>
</div>
<div class="panel-comment_item">
<% no_children_comments.each do |comment| %>
<% unless comment.nil? %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<div class="comment_item_cont clearfix">
<div class="J_Comment_Face fl">
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 50, :height => 50, :alt => "用户头像"), user_url_in_org(comment.creator_user), :target => '_blank' %>
</div>
<div class="t_content fl">
<div class="J_Comment_Reply">
<div class="comment_orig_content" style="margin:0px">
<% if !comment.parent.nil? && !comment.parent.parent.nil? %>
<% parents_rely = [] %>
<% parents_rely = get_reply_parents_no_root parents_rely, comment %>
<% length = parents_rely.length %>
<div id="comment_reply_<%= comment.id %>">
<% if length <= 5 %>
<%=render :partial => 'messages/message_reply', :locals => {:comment => comment.parent, :parent_id => comment.id, :user_activity_id => memo.id, :type => memo.class.to_s} %>
<% else %>
<div class="orig_cont clearfix">
<div class="orig_cont clearfix">
<div class="orig_cont clearfix">
<div class="orig_cont clearfix">
<div class="orig_cont clearfix">
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[length - 1], :type => memo.class.to_s, :user_activity_id => memo.id, :parent_id => comment.id} %>
</div>
<div class="orig_cont_hide clearfix">
<i class="fa fa-long-arrow-down mr5"></i>
<%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment, :type => comment.class, :user_activity_id => memo.id, :parent_id => comment.id),:remote=>true, :class => '' %>
</div>
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[3], :type => memo.class.to_s, :user_activity_id => memo.id, :parent_id => comment.id} %>
</div>
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[2], :type => memo.class.to_s, :user_activity_id => memo.id, :parent_id => comment.id} %>
</div>
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[1], :type => memo.class.to_s, :user_activity_id => memo.id, :parent_id => comment.id} %>
</div>
<%=render :partial => 'student_work/homework_reply_detail', :locals => {:comment => parents_rely[0], :type => memo.class.to_s, :user_activity_id => memo.id, :parent_id => comment.id} %>
</div>
<% end %>
</div>
<% end %>
<!--onmouseover="$('#delete_reply_<%#=activity.id %>_<%#=comment.id %>').show();" onmouseout="$('#delete_reply_<%#=activity.id %>_<%#=comment.id %>').hide();"-->
<div class="comment_content clearfix" >
<div class="color-grey3"><%= comment.content_detail.html_safe %></div>
<div class="">
<div class="cl"></div>
<div id="reply_message_<%= comment.id%>" class="reply_to_message"></div>
</div>
</div>
<!--回复end-->
</div>
</div>
<div class="J_Comment_Info clearfix">
<div class="t_info fl">
<%= link_to comment.creator_user.show_real_name, user_url_in_org(comment.creator_user), :class => "content-username hide fl" %>
<span class="t_area fl"><%= time_from_now(comment.created_at) %></span>
</div>
<p class="fr mr10 orig_reply">
<% if comment.creator_user == User.current %>
<a href="javascript:void(0);" class="color-grey" id="delete_reply_<%= memo.id %>_<%=comment.id %>" onclick="delete_confirm_box_2('<%= forum_memo_path(memo.forum, memo) %>', '确定要删除该条回复吗?')"><i class="fa fa-trash-o mr5"></i>删除</a>
<% end %>
<span class="ml5 mr5 color-grey">|</span>
<%= link_to(
'<i class="fa fa-mail-reply mr5"></i>回复'.html_safe,
{:controller => 'users' ,:action => 'reply_to',:reply_id => comment.id, :type => memo.class.to_s, :user_activity_id => memo.id},
:remote => true,
:method => 'get',
:title => l(:button_reply),:class => "color-grey") %>
<span class="ml5 mr5 color-grey">|</span>
<span class="reply_praise_count_<%= comment.id %>">
<%=render :partial=> "praise_tread/edu_praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%>
</span>
</p>
</div>
</div>
<div class="cl"></div>
</div>
<% end %>
<% end %>
</div>
<script>
function ThumbUp(item){
$(item).toggleClass("orange-btn");
$(item).toggleClass("orange-bg-btn");
if($(item).attr("attr-thumb")=="0"){
$(item).find("span").html(parseInt($(item).find("span").html())+1);
$(item).attr("attr-thumb","1");
}else{
$(item).find("span").html(parseInt($(item).find("span").html())-1);
$(item).attr("attr-thumb","0");
}
}
</script>

View File

@ -1,40 +1,65 @@
<% @replies.each do |reply| %>
<script type="text/javascript">
$(function(){
$("#activity_description_<%= reply.id %> p,#activity_description_<%= reply.id %> span,#activity_description_<%= reply.id %> em").each(function(){
var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; ");
postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
postContent = postContent.replace(/<script>*/g, "<script>");
postContent = postContent.replace(/<html>*/g, "<html>");
$(this).html(postContent);
<%#= render :partial => "messages/common_reply_box", :locals => {:count => @reply_count, :activity => @topic, :no_children_comments => @replies, :is_teacher => is_teacher} %>
<%= render :partial => "memos/common_reply_box", :locals => {:count => @reply_count, :memo => @memo, :no_children_comments => @replies} %>
<div class="comment_item_cont clearfix">
<div class="comment_reply_box">
<div class="J_Comment_Face fl">
<%= link_to image_tag(url_to_avatar(User.current), :width => "50", :height => "50"), :target => "_blank", :alt => "用户头像" %>
</div>
<div nhname='new_message_<%= @memo.id%>' class="fr ml20 mr20" style="display:none; width: 92%;">
<%= form_for('memo', :as => :reply, :url => reply_forum_memo_path(@memo.forum, @memo), :method => "post", :remote => true) do |f|%>
<%#= form_for @memo, :as => :reply, :url => {:action => 'reply', :id => @topic}, :remote => true, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<%#= f.hidden_field :subject, :required => true, value: @memo.subject %>
<%#= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %>
<%#= f.hidden_field :parent_id, :required => true, value: @memo.id %>
<div nhname='toolbar_container_<%= @memo.id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= @memo.id %>' name="content"></textarea>
<a id="new_message_submit_btn_<%= @memo.id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="mt10 task-btn task-btn-blue fr">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= @memo.id%>'></p>
<% end%>
</div>
<div class="cl"></div>
</div>
</div>
<% if false %>
<% @replies.each do |reply| %>
<script type="text/javascript">
$(function(){
$("#activity_description_<%= reply.id %> p,#activity_description_<%= reply.id %> span,#activity_description_<%= reply.id %> em").each(function(){
var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; ");
postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
postContent = postContent.replace(/<script>*/g, "<script>");
postContent = postContent.replace(/<html>*/g, "<html>");
$(this).html(postContent);
});
autoUrl('activity_description_<%= reply.id %>');
description_show_hide(<%= reply.id %>);
});
autoUrl('activity_description_<%= reply.id %>');
description_show_hide(<%= reply.id %>);
});
$(".homepagePostReplyDes").mouseover(function(){
$(this).find("a[id*='delete_memo_reply']").show();
}).mouseout(function(){
$(this).find("a[id*='delete_memo_reply']").hide();
});
</script>
$(".homepagePostReplyDes").mouseover(function(){
$(this).find("a[id*='delete_memo_reply']").show();
}).mouseout(function(){
$(this).find("a[id*='delete_memo_reply']").hide();
});
</script>
<div class="homepagePostReplyContainer" >
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
</div>
<div class="homepagePostReplyDes" onmouseover="$('#delete_reply_<%=reply.id %>').show();" onmouseout="$('#delete_reply_<%=reply.id %>').hide();">
<div class="homepagePostReplyPublisher">
<%= render :partial => 'users/message_contents', :locals => {:comment => reply, :type => 'Memo', :user_activity_id => @memo.id}%>
</div>
<div class="homepagePostReplyContent break_word" style="margin-bottom:15px;" id="activity_description_<%= reply.id %>">
<p><%= reply.content.gsub(/\/script/, "script").gsub(/script/, "&nbsp;script").html_safe %></p>
</div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
<div class="homepagePostReplyContainer" >
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
</div>
<div class="homepagePostReplyDes" onmouseover="$('#delete_reply_<%=reply.id %>').show();" onmouseout="$('#delete_reply_<%=reply.id %>').hide();">
<div class="homepagePostReplyPublisher">
<%= render :partial => 'users/message_contents', :locals => {:comment => reply, :type => 'Memo', :user_activity_id => @memo.id}%>
</div>
<div class="homepagePostReplyContent break_word" style="margin-bottom:15px;" id="activity_description_<%= reply.id %>">
<p><%= reply.content.gsub(/\/script/, "script").gsub(/script/, "&nbsp;script").html_safe %></p>
</div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
<span class="reply-right">
<span class="reply_praise_count_<%= reply.id %>">
<%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %>
@ -58,20 +83,21 @@
:title => l(:button_delete)
) if @memo.author.id == User.current.id || User.current.admin? || User.current == @forum.creator %>
</span>
<div class="cl"></div>
<div class="cl"></div>
</div>
</div>
<div id="reply_message_<%= comment.id%>" class="reply_to_message"></div>
</div>
<div class="cl"></div>
</div>
<% end %>
<% if @limit_count > @page * @limit + 10 %>
<div id="more_memo_replies">
<div class="detail_cont_hide clearfix">
<span class="orig_icon" >&darr; </span>
<span class="orig_icon" style="display:none;" > &uarr;</span>
<%= link_to '点击展开更多回复', forum_memo_path(@memo.forum_id, @memo, :page => @page),:remote=>true %>
</div>
</div>
<div id="reply_message_<%= reply.id%>" class="reply_to_message"></div>
</div>
<div class="cl"></div>
</div>
<% end %>
<% if @limit_count > @page * @limit + 10 %>
<div id="more_memo_replies">
<div class="detail_cont_hide clearfix">
<span class="orig_icon" >&darr; </span>
<span class="orig_icon" style="display:none;" > &uarr;</span>
<%= link_to '点击展开更多回复', forum_memo_path(@memo.forum_id, @memo, :page => @page),:remote=>true %>
</div>
</div>
<% end %>
<% end %>

View File

@ -1 +1 @@
window.location.href='<%= forum_memo_path(:forum_id=>@memo.forum_id,:id=>@memo.id ) %>'
window.location.href='<%= forum_memo_path(:forum_id => @memo.forum_id, :id => @memo.id ) %>';

View File

@ -0,0 +1,9 @@
<%# if @user_activity_id != @memo.id %>
/* $("#activity_post_reply_<%#= @user_activity_id %>").html("<%#= escape_javascript(render :partial => 'users/course_message_post_reply',
:locals => { :activity => @memo,
:user_activity_id => @user_activity_id}) %>");
sd_create_editor_from_data(<%#= @user_activity_id%>,"","100%", "UserActivity");*/
<%# else %>
$("#message_replies_box").html("<%= escape_javascript(render :partial => 'memos/memo_all_replies') %>");
sd_create_editor_from_data(<%= @memo.id %>,"","100%", "<%= @memo.class.to_s %>");
<%# end %>

View File

@ -1,131 +1,206 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
<%= javascript_include_tag 'forum' %>
<% end %>
<div class="newMain clearfix">
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
<i class="fa fa-map-marker mr5 color-grey"></i>
<a href="javascript:void(0)"><%= @user.show_name %></a> &gt; <a href="<%= forums_path %>">讨论 </a>
</p>
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20">
<p class="ml15 color-grey3 fl"><%= h @memo.subject %></p>
<!-- <p class="color-grey fr font-12 mr15 mt5"><a href="javascript:void(0)">返回</a></p>-->
</div>
<div class="edu-tab clearfix mb20 user_bg_shadow bor-grey-e">
<div class="panel-inner-fourm nobg">
<div class="clearfix pr">
<a href="/users/innov" class="fl">
<%= image_tag(url_to_avatar(@memo.author), :width => 60, :height => 60, :alt=>'用户头像', :class=>"panel-list-img mr15" ) %>
</a>
<div class="panel-list-infobox fl" style="margin:0;margin-left: 9px">
<p><a href="<%= user_path(@memo.author) %>" class="font-14 mr15 color-grey" target="_blank"><%= @memo.author.show_name %></a></p>
<p class="color-grey panel-lightgrey fl mt3">
<!--<span class="fl mr10 mt2">类别:分享</span>--><span class="fl mr10 mt2">发表于<%= time_from_now @memo.updated_at %></span>
</p>
</div>
<div class="banner-big f16 fontGrey3 mb10">
<%= link_to "问吧", forums_path, :class => "c_blue" %> > <%= link_to @forum.name, forum_path(@forum), :class => "c_blue" %> > <%=h @memo.subject %>
<div class="edu-position-hidebox" style="position: absolute;right: 10px;top:0px;">
<a href="javascript:void(0);"><i class="fa fa-bars font-16"></i></a>
<ul class="edu-position-hide undis">
<li><a href="javascript:void(0)">精&nbsp;&nbsp;选</a></li>
<li><a href="javascript:void(0);">编&nbsp;&nbsp;辑</a></li>
<li><a href="javascript:void(0)">删&nbsp;&nbsp;除</a></li>
</ul>
</div>
</div>
<div class="panel-inner-info clearfix">
<!--帖子内容-->
<%= @memo.content.html_safe %>
</div>
<ul class="panel-inner-info mt10">
<!--上传的文件内容-->
<% if @memo.attachments.any?%>
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>
<%= render :partial => 'attachments_links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %>
<% end %>
</ul>
</div>
<div class="panel-mesbox" id="message_replies_box">
<%= render :partial => "memo_all_replies" %>
</div>
</div>
</div>
</div>
<script>
$(function() {
sd_create_editor_from_data(<%= @memo.id%>,null,"100%", "<%=@memo.class.to_s%>");
});
function del_confirm(){
if(confirm('确认删除么?')){
$("#del_memo_link").click();
function ThumbUp(item){
$(item).toggleClass("orange-btn");
$(item).toggleClass("orange-bg-btn");
if($(item).attr("attr-thumb")=="0"){
$(item).find("span").html(parseInt($(item).find("span").html())+1);
$(item).attr("attr-thumb","1");
}else{
$(item).find("span").html(parseInt($(item).find("span").html())-1);
$(item).attr("attr-thumb","0");
}
}
$(function(){
sd_create_editor_from_data(<%= @memo.id %>, null, "100%", "<%= @memo.class.to_s %>");
});
</script>
<div class="postRightContainer mr10">
<div class="postThemeContainer">
<div class="postDetailPortrait">
<%= link_to image_tag(url_to_avatar(@memo.author),:width=>50,:height => 50,:alt=>'贴吧图像' ),user_path(@memo.author) %>
</div>
<div class="postThemeWrap">
<% if @memo.author.id == User.current.id || User.current.admin? || User.current == @forum.creator %>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<% if @memo.author.id == User.current.id || User.current.admin? %>
<li><a href="<%= edit_forum_memo_path(@memo.forum,@memo)%>" class="postOptionLink">编辑</a></li>
<% end %>
<% if User.current.admin? || User.current == @forum.creator %>
<% if @memo.sticky %>
<li><a href="<%= change_sticky_forum_memo_path(@memo.forum,@memo) %>" class="postOptionLink">取消置顶</a></li>
<% else %>
<li><a href="<%= change_sticky_forum_memo_path(@memo.forum,@memo) %>" class="postOptionLink">置顶</a></li>
<% end %>
<% end %>
<li><a href="javascript:void(0);" class="postOptionLink" onclick="del_confirm();">删除</a></li>
<li style="display: none"><a href="<%= forum_memo_path(@memo.forum, @memo) %>" data-method="delete" id="del_memo_link" ></a></li>
</ul>
</li>
</ul>
</div>
<% end %>
<div class="postDetailTitle fl">
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= @memo.subject%></a>
</div>
<%= render :partial => "memos/praise_tread",:locals => {:obj => @memo,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%>
<div class="cl"></div>
<div class="postDetailCreater">
<%= link_to @memo.author.show_name, user_path(@memo.author), :class => "linkBlue2", :target=> "_blank"%></div>
<div class="postDetailDate mb5"><%= format_date( @memo.created_at)%></div>
<div class="cl"></div>
<div class="homepagePostIntro memo-content ke-block" id="activity_description_<%= @memo.id %>" style="word-break: break-all; word-wrap:break-word;margin-bottom: 0px !important;" >
<%= @memo.content.html_safe%>
</div>
<div class="cl"></div>
<div class=" fl" style="width: 600px">
<% if @memo.attachments.any?%>
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>
<%= render :partial => 'attachments_links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %>
<% end %>
</div>
<div class="cl"></div>
<span class=" fr" style="color: #888888; font-size: 12px;">更新时间:<%= format_date(@memo.updated_at)%></span>
<% if false %>
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
<%= javascript_include_tag 'forum' %>
<% end %>
<div class="banner-big f16 fontGrey3 mb10">
<%= link_to "问吧", forums_path, :class => "c_blue" %> > <%= link_to @forum.name, forum_path(@forum), :class => "c_blue" %> > <%=h @memo.subject %>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
<div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复(<%= @reply_count %></div>
<div class="homepagePostReplyBannerTime"></div>
</div>
<div class="" id="reply_div_<%= @memo.id %>">
<%= render :partial => 'memos/memo_all_replies' %>
</div>
<div class="cl"></div>
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= @memo.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="homepagePostReplyInputContainer mb10">
<% if User.current.logged? %>
<div nhname='new_message_<%= @memo.id%>' style="display:none;">
<%= form_for('memo',:url=>forum_memos_path,:method => "post") do |f|%>
<%= f.hidden_field :subject, :required => true, value: @memo.subject %>
<%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %>
<%= f.hidden_field :parent_id, :required => true, value: @memo.id %>
<%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %>
<div nhname='toolbar_container_<%= @memo.id%>' class="kindeditor"></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= @memo.id %>' name="memo[content]"></textarea>
<a id="new_message_submit_btn_<%= @memo.id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= @memo.id%>'></p>
<% end%>
</div>
<% else %>
<%= render :partial => "users/show_unlogged" %>
<% end %>
<script>
$(function() {
sd_create_editor_from_data(<%= @memo.id%>,null,"100%", "<%=@memo.class.to_s%>");
});
function del_confirm(){
if(confirm('确认删除么?')){
$("#del_memo_link").click();
}else{
}
}
</script>
<div class="postRightContainer mr10">
<div class="postThemeContainer">
<div class="postDetailPortrait">
<%= link_to image_tag(url_to_avatar(@memo.author),:width=>50,:height => 50,:alt=>'贴吧图像' ),user_path(@memo.author) %>
</div>
<div class="postThemeWrap">
<% if @memo.author.id == User.current.id || User.current.admin? || User.current == @forum.creator %>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<% if @memo.author.id == User.current.id || User.current.admin? %>
<li><a href="<%= edit_forum_memo_path(@memo.forum,@memo)%>" class="postOptionLink">编辑</a></li>
<% end %>
<% if User.current.admin? || User.current == @forum.creator %>
<% if @memo.sticky %>
<li><a href="<%= change_sticky_forum_memo_path(@memo.forum,@memo) %>" class="postOptionLink">取消置顶</a></li>
<% else %>
<li><a href="<%= change_sticky_forum_memo_path(@memo.forum,@memo) %>" class="postOptionLink">置顶</a></li>
<% end %>
<% end %>
<li><a href="javascript:void(0);" class="postOptionLink" onclick="del_confirm();">删除</a></li>
<li style="display: none"><a href="<%= forum_memo_path(@memo.forum, @memo) %>" data-method="delete" id="del_memo_link" ></a></li>
</ul>
</li>
</ul>
</div>
<% end %>
<div class="postDetailTitle fl">
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= @memo.subject%></a>
</div>
<%= render :partial => "memos/praise_tread",:locals => {:obj => @memo,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%>
<div class="cl"></div>
<div class="postDetailCreater">
<%= link_to @memo.author.show_name, user_path(@memo.author), :class => "linkBlue2", :target=> "_blank"%></div>
<div class="postDetailDate mb5"><%= format_date( @memo.created_at)%></div>
<div class="cl"></div>
<div class="homepagePostIntro memo-content ke-block" id="activity_description_<%= @memo.id %>" style="word-break: break-all; word-wrap:break-word;margin-bottom: 0px !important;" >
<%= @memo.content.html_safe%>
</div>
<div class="cl"></div>
<div class=" fl" style="width: 600px">
<% if @memo.attachments.any?%>
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>
<%= render :partial => 'attachments_links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %>
<% end %>
</div>
<div class="cl"></div>
<span class=" fr" style="color: #888888; font-size: 12px;">更新时间:<%= format_date(@memo.updated_at)%></span>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
<div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复(<%= @reply_count %></div>
<div class="homepagePostReplyBannerTime"></div>
</div>
<div class="" id="reply_div_<%= @memo.id %>">
<%= render :partial => 'memos/memo_all_replies' %>
</div>
<div class="cl"></div>
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= @memo.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="homepagePostReplyInputContainer mb10">
<% if User.current.logged? %>
<div nhname='new_message_<%= @memo.id%>' style="display:none;">
<%= form_for('memo',:url=>forum_memos_path,:method => "post") do |f|%>
<%= f.hidden_field :subject, :required => true, value: @memo.subject %>
<%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %>
<%= f.hidden_field :parent_id, :required => true, value: @memo.id %>
<%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %>
<div nhname='toolbar_container_<%= @memo.id%>' class="kindeditor"></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= @memo.id %>' name="memo[content]"></textarea>
<a id="new_message_submit_btn_<%= @memo.id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= @memo.id%>'></p>
<% end%>
</div>
<% else %>
<%= render :partial => "users/show_unlogged" %>
<% end %>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
</div>
</div>
<div class="fl">
<%= render :partial => "memos/my_show_count_message" %>
</div>
</div>
</div>
<div class="fl">
<%= render :partial => "memos/my_show_count_message" %>
</div>
<script type="text/javascript">
$(function(){
$("#activity_description_<%= @memo.id %> p,#activity_description__<%= @memo.id %> span,#activity_description_<%= @memo.id %> em").each(function(){
var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; ");
postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
<script type="text/javascript">
$(function(){
$("#activity_description_<%= @memo.id %> p,#activity_description__<%= @memo.id %> span,#activity_description_<%= @memo.id %> em").each(function(){
var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; ");
postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('activity_description_<%= @memo.id %>');
description_show_hide(<%= @memo.id %>);
});
autoUrl('activity_description_<%= @memo.id %>');
description_show_hide(<%= @memo.id %>);
});
</script>
</script>
<% end %>

View File

@ -4,8 +4,9 @@
:user_activity_id => user_activity_id,
:type => type }) %>' data-remote="true" class="white-btn orange-btn" title="点赞">
<i class="fa fa-thumbs-up mr5"></i>赞
<% num = activity.praise_tread_cache ? activity.praise_tread_cache.praise_num : 0 %>
<span><%= (num.nil? ? 0 : num) > 0 ? num : 0 %></span>
<%# num = activity.praise_tread_cache ? activity.praise_tread_cache.praise_num : 0 %>
<!--<span><%#= (num.nil? ? 0 : num) > 0 ? num : 0 %></span>-->
<span><%= get_praise_num(activity) %></span>
</a>
<% else %>
<a href='<%= praise_tread_praise_minus_path({:obj_id => activity.id,
@ -13,7 +14,8 @@
:user_activity_id => user_activity_id,
:type => type }) %>' data-remote="true" class="white-btn orange-bg-btn" title="取消点赞" >
<i class="fa fa-thumbs-up mr5"></i>赞
<% num = activity.praise_tread_cache ? activity.praise_tread_cache.praise_num : 0 %>
<span><%= (num.nil? ? 0 : num) > 0 ? num : 0 %></span>
<span><%= get_praise_num(activity) %></span>
<%# num = activity.praise_tread_cache ? activity.praise_tread_cache.praise_num : 0 %>
<!--<span><%#= (num.nil? ? 0 : num) > 0 ? num : 0 %></span>-->
</a>
<% end %>

View File

@ -4,8 +4,9 @@
:user_activity_id => user_activity_id,
:type => type }) %>' data-remote="true" class="fr mr5 color-grey" title="点赞">
<i class="fa fa-thumbs-up mr5"></i>赞
<% num = activity.praise_tread_cache ? activity.praise_tread_cache.praise_num : 0 %>
<span class="ml5"><%= (num.nil? ? 0 : num) > 0 ? num : 0 %></span>
<%# num = activity.praise_tread_cache ? activity.praise_tread_cache.praise_num : 0 %>
<!-- <span class="ml5"><%#= (num.nil? ? 0 : num) > 0 ? num : 0 %></span>-->
<span class="ml5"><%= get_praise_num(activity) %></span>
</a>
<% else %>
<a href='<%= praise_tread_praise_minus_path({:obj_id => activity.id,
@ -13,7 +14,8 @@
:user_activity_id => user_activity_id,
:type => type }) %>' data-remote="true" class="fr mr5 color-orange03" title="取消点赞" >
<i class="fa fa-thumbs-up mr5"></i>赞
<% num = activity.praise_tread_cache ? activity.praise_tread_cache.praise_num : 0 %>
<span class="ml5"><%= (num.nil? ? 0 : num) > 0 ? num : 0 %></span>
<span class="ml5"><%= get_praise_num(activity) %></span>
<%# num = activity.praise_tread_cache ? activity.praise_tread_cache.praise_num : 0 %>
<!--<span class="ml5"><%#= (num.nil? ? 0 : num) > 0 ? num : 0 %></span>-->
</a>
<% end %>

View File

@ -5,6 +5,8 @@
<% else %>
$('#praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"activity"})%>');
<% end %>
<% elsif @type.to_s == 'Memo' %>
$('#praise_count_<%= @obj.id %>').html('<%= j(render :partial => 'praise_tread/activity_praise', :locals => {:activity => @obj, :user_activity_id => @obj.id, :type => "Memo"})%>');
<% else @type.to_s == 'reply' %>
<% if ((@obj_type == 'JournalsForMessage' && @obj.jour_type == 'HomeworkCommon') || @obj_type == 'Message') && @obj_id == @user_activity_id %>
$('.reply_praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/edu_praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"reply"})%>');

View File

@ -5,6 +5,8 @@
<% else %>
$('#praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"activity"})%>');
<% end %>
<% elsif @type.to_s == 'Memo' %>
$('#praise_count_<%= @obj.id %>').html('<%= j(render :partial => 'praise_tread/activity_praise', :locals => {:activity => @obj, :user_activity_id => @obj.id, :type => "Memo"})%>');
<% else @type.to_s == 'reply' %>
<% if ((@obj_type == 'JournalsForMessage' && @obj.jour_type == 'HomeworkCommon') || @obj_type == 'Message') && @obj_id == @user_activity_id %>
$('.reply_praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/edu_praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"reply"})%>');
@ -13,8 +15,8 @@
<% end %>
<% end %>
<% elsif @obj_type == 'Memo'%>
$('#praise_tread_<%= @obj.id %>').html('<%= j(
render :partial => "/memos/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id,:horizontal => @horizontal}
$('#praise_count__<%= @obj.id %>').html('<%= j(
render :partial => 'praise_tread/activity_praise', :locals => {:activity => @obj, :user_activity_id => @obj.id, :type => "Memo"}
)%>');
<% elsif @obj_type == 'Discuss'%>
$('#dis_praise_<%= @obj.id %>').html('<%= j(

View File

@ -734,6 +734,8 @@ RedmineApp::Application.routes.draw do
end
member do
get "change_sticky"
post "reply"
match "message_replies", :via => [:get, :post]
end
end
end