Merge branch 'dev_tieba' of https://git.trustie.net/jacknudt/trustieforge into dev_tieba

Conflicts:
	config/routes.rb
This commit is contained in:
huang 2016-12-30 16:51:23 +08:00
commit baaaaf95d8
7 changed files with 61 additions and 29 deletions

View File

@ -282,6 +282,19 @@ class ForumsController < ApplicationController
end end
end end
# 更新贴吧描述
def update_memo_description
@forum = Forum.find(params[:id])
if @forum.blank?
result = { :result => false }
else
forum_decription = params[:forum][:description]
@forum.update_attributes(:description => forum_decription )
result = { :result => true }
end
render :json => result
end
def search_forum def search_forum
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'") # @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
q = "%#{params[:name].strip}%" q = "%#{params[:name].strip}%"

View File

@ -1,6 +1,6 @@
class MemosController < ApplicationController class MemosController < ApplicationController
default_search_scope :memos default_search_scope :memos
before_filter :find_forum, :only => [:new, :create, :preview] before_filter :find_forum, :only => [:new, :create, :preview, :update]
before_filter :find_attachments, :only => [:preview] before_filter :find_attachments, :only => [:preview]
before_filter :find_memo, :except => [:new, :create, :preview] before_filter :find_memo, :except => [:new, :create, :preview]
before_filter :authenticate_user_edit, :only => [:edit, :update] before_filter :authenticate_user_edit, :only => [:edit, :update]
@ -47,7 +47,7 @@ class MemosController < ApplicationController
end end
@memo = Memo.new(params[:memo]) @memo = Memo.new(params[:memo])
@memo.forum_id = params[:forum_id] @memo.forum_id = @forum.id
@memo.author_id = User.current.id @memo.author_id = User.current.id
if params[:memo][:parent_id] if params[:memo][:parent_id]
@ -154,6 +154,8 @@ class MemosController < ApplicationController
end end
def update def update
# 注意,如果不需要
@flag = false @flag = false
respond_to do |format| respond_to do |format|
if( #@memo.update_column(:subject, params[:memo][:subject]) && if( #@memo.update_column(:subject, params[:memo][:subject]) &&
@ -163,10 +165,11 @@ class MemosController < ApplicationController
@memo.update_column(:subject,params[:memo][:subject]) && @memo.update_column(:subject,params[:memo][:subject]) &&
@memo.update_column(:updated_at,Time.now)) @memo.update_column(:updated_at,Time.now))
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))
@memo.forum_id = @forum.id
@flag = @memo.save @flag = @memo.save
# @memo.root.update_attribute(:updated_at, @memo.updated_at) # @memo.root.update_attribute(:updated_at, @memo.updated_at)
format.js format.js
format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"} format.html {redirect_to back_memo_url, notice: "#{l :label_memo_update_succ}"}
else else
format.js format.js
format.html { render action: "edit" } format.html { render action: "edit" }

View File

@ -2,7 +2,7 @@
<li class="mb10 clear"> <li class="mb10 clear">
<label class="fl" style="width: 90px;text-align: right;">贴吧名称&nbsp;&nbsp;:&nbsp;</label> <label class="fl" style="width: 90px;text-align: right;">贴吧名称&nbsp;&nbsp;:&nbsp;</label>
<!--<input maxlength="80" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" >--> <!--<input maxlength="80" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" >-->
<%= f.text_field :name, :label => "", :name => "forum[name]", :id => "forum_name", :class => "issues_calendar_input fl", :style => "width:320px;height:28px;", :placeholder => "请输入贴吧名称最多50个字符", :onfocus => "$('#forum_name_error_tips').hide();" %> <%= f.text_field :name, :label => "", :name => "forum[name]", :id => "forum_name", :onblur => "check_forum_name()", :class => "issues_calendar_input fl", :style => "width:320px;height:28px;", :placeholder => "请输入贴吧名称最多50个字符", :onfocus => "$('#forum_name_error_tips').hide();" %>
<!--<input type="text" name="forum[name]" id="forum_name" onfocus="$('#forum_name_error_tips').hide();" placeholder="请输入贴吧名称最多50个字符" class="issues_calendar_input fl" style="width:320px;height:28px;">--> <!--<input type="text" name="forum[name]" id="forum_name" onfocus="$('#forum_name_error_tips').hide();" placeholder="请输入贴吧名称最多50个字符" class="issues_calendar_input fl" style="width:320px;height:28px;">-->
<div class="clear"></div> <div class="clear"></div>
<p class="c_red ml90" style="display: none" id="forum_name_error_tips"></p> <p class="c_red ml90" style="display: none" id="forum_name_error_tips"></p>
@ -22,12 +22,22 @@
<script> <script>
function check_forum_name(){
if ($("#forum_name").val().trim() == ""){
$("#forum_name_error_tips").html("贴吧名称不能为空").show();
}else if($("#forum_name").val().length > 50){
$("#forum_name_error_tips").html("贴吧名称不能超过50个字符").show();
}
}
function forums_commit(){ function forums_commit(){
$("#forum_name_error_tips").hide(); $("#forum_name_error_tips").hide();
$("#forum_description_error_tips").hide(); $("#forum_description_error_tips").hide();
if ($("#forum_name").val().trim() == ""){ if ($("#forum_name").val().trim() == ""){
$("#forum_name_error_tips").html("贴吧名称不能为空").show(); $("#forum_name_error_tips").html("贴吧名称不能为空").show();
} }
else if($("#forum_name").val().length > 50){
$("#forum_name_error_tips").html("贴吧名称不能超过50个字符").show();
}
else if($("#forum_desc").val().trim() == ""){ else if($("#forum_desc").val().trim() == ""){
$("#forum_description_error_tips").html("贴吧描述不能为空").show(); $("#forum_description_error_tips").html("贴吧描述不能为空").show();
} }

View File

@ -1,33 +1,38 @@
<div class="homepageLeft-new"> <div class="homepageLeft-new">
<div class="postDetailContainer"> <div class="postDetailContainer">
<div class="fl mr10 pr"> <%= link_to image_tag(url_to_avatar(@forum.creator),:width=>75,:height => 75,:alt=>'贴吧图像' ), user_path( @forum.creator) %> <div class="fl mr10 pr"> <%= link_to image_tag(url_to_avatar(@forum.creator),:width => 75,:height => 75,:alt => '贴吧图像' ), user_path( @forum.creator) %>
<!--<div class="homepageEditProfile"><a href="javascript:void(0);" class="homepageEditProfileIcon"></a></div>--> <!--<div class="homepageEditProfile"><a href="javascript:void(0);" class="homepageEditProfileIcon"></a></div>-->
</div> </div>
<div class="fl"> <div class="fl" style="width: 120px;">
<%= link_to @forum.name, forum_path(@forum), :class => "f16 fontBlue", :style => "word-break: break-all; word-wrap:break-word;white-space:pre-wrap;" %>
<% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %> <% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %>
<div class="fontGrey2 mb8 mt10">吧主:<a href="<%= user_path(@forum.creator)%>" class="linkBlue"><%= user_name %></a></div> <div class="fl mb8 mt10">吧主:</div>
<div class="fontGrey3">回答:<a href="javascript:void(0);" class="linkOrange mr5" style="cursor: default"><%= @my_replies_count %></a> 帖子:<a href="javascript:void(0);" class="linkOrange" style="cursor: default"><%= @my_topic_count %></a></div> <a href="<%= user_path(@forum.creator)%>" target="_blank" class="linkBlue w80 fl mb8 mt10" style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis; "><%= user_name %></a>
<div class="fontGrey3 fl">回答:<a href="javascript:void(0);" class="linkOrange mr5" style="cursor: default"><%= @my_replies_count %></a> 帖子:<a href="javascript:void(0);" class="linkOrange" style="cursor: default"><%= @my_topic_count %></a></div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="fontGrey2 mt10"><span id="forum_desc_span" style="word-break:normal; width:auto; display:block; white-space:pre-wrap;word-wrap : break-word ;overflow: hidden ;"><%= @forum.description.html_safe%></span> <div class="fl">
<%if @forum.creator.id == User.current.id%> <%= link_to @forum.name, forum_path(@forum), :class => "f16 fontBlue", :style => "word-break: break-all; word-wrap:break-word;white-space:pre-wrap;" %>
</div>
<div class="cl"></div>
<div class="fontGrey2 mt10">
<span id="forum_desc_span" style="word-break:normal; width:auto; display:block; white-space:pre-wrap;word-wrap : break-word ;overflow: hidden ;"><%= h @forum.description.html_safe%></span>
<% if @forum.creator.id == User.current.id %>
<a href="javascript:void(0);" onclick="edit_desc();"> <a href="javascript:void(0);" onclick="edit_desc();">
<%= image_tag('signature_edit.png',{:width=>12,:height=>12}) %> <%= image_tag('signature_edit.png',{:width => 12,:height => 12}) %>
</a> </a>
<% end %> <% end %>
</div> </div>
<!--<div class="mt15">--> <!--<div class="mt15">-->
<!--<div id="forum_tag_list">--> <!--<div id="forum_tag_list">-->
<!--<%#= render :partial => 'forums/forum_tag_list', :locals => {:forum => @forum} %>--> <!--<%#= render :partial => 'forums/forum_tag_list', :locals => {:forum => @forum} %>-->
<!--</div>--> <!--</div>-->
<!--<%# if(@forum.creator.id == User.current.id) %>--> <!--<%# if(@forum.creator.id == User.current.id) %>-->
<!--<a href="javascript:void(0)" class="yellowBtn f_l" onclick="$('#add_tag01').slideToggle();">+ 添加标签</a>--> <!--<a href="javascript:void(0)" class="yellowBtn f_l" onclick="$('#add_tag01').slideToggle();">+ 添加标签</a>-->
<!--<%# end %>--> <!--<%# end %>-->
<!--<span id="add_tag01" style="display:none; vertical-align: middle;" class="ml10 f_l">--> <!--<span id="add_tag01" style="display:none; vertical-align: middle;" class="ml10 f_l">-->
<!--<input type="text" name="addTag" size="20" class="isTxt w90 f_l" maxlength="<%#= Setting.tags_max_length %>" minlength="<%#= Setting.tags_min_length%>" />--> <!--<input type="text" name="addTag" size="20" class="isTxt w90 f_l" maxlength="<%#= Setting.tags_max_length %>" minlength="<%#= Setting.tags_min_length%>" />-->
<!--<input type="button" class="submit f_l" onclick="addTag();" />--> <!--<input type="button" class="submit f_l" onclick="addTag();" />-->
<!--</span></div>--> <!--</span></div>-->
<!--<div class="cl"></div>--> <!--<div class="cl"></div>-->
<% if @forum.creator.id == User.current.id %> <% if @forum.creator.id == User.current.id %>
<span class="postEdit"></span> <span class="postEdit"></span>
@ -46,23 +51,22 @@
<script> <script>
var desc; var desc;
function edit_desc(){ function edit_desc(){
if(<%= @forum.creator.id == User.current.id %>) {
desc = $("#forum_desc_span").html(); desc = $("#forum_desc_span").html();
$("#forum_desc_span").html("<textarea id='forum_desc_input' onblur='change_forum_desc();' style='width: 200px;height: 80px; max-width: 207px; max-height: 80px; border: 1px solid #d9d9d9;outline: none;margin: 0px 0px 12px 0px;'>" + desc + "</textarea>"); $("#forum_desc_span").html("<textarea id='forum_desc_input' onblur='change_forum_desc();' style='width: 200px;height: 80px; max-width: 207px; max-height: 80px; border: 1px solid #d9d9d9;outline: none;margin: 0px 0px 12px 0px;'>" + desc + "</textarea>");
$("#forum_desc_input").focus(); $("#forum_desc_input").focus();
}
} }
function change_forum_desc(){ function change_forum_desc(){
$.ajax({ $.ajax({
url: '<%= forums_path + '/'+@forum.id.to_s+".js" %>', url: '<%= update_memo_description_forum_path(@forum) %>',
type: 'PUT', type: 'post',
dataType: 'json',
data:{"forum[description]":$("#forum_desc_input").val().trim()}, data:{"forum[description]":$("#forum_desc_input").val().trim()},
success:function(data){ success:function(data){
if(data == true){ if(data.result == true){
$("#forum_desc_input").hide();
$("#forum_desc_span").html($("#forum_desc_input").val().trim()); $("#forum_desc_span").html($("#forum_desc_input").val().trim());
}else{ }else{
alert("失败");
$("#forum_desc_span").html(desc); $("#forum_desc_span").html(desc);
} }
} }

View File

@ -44,7 +44,7 @@
<%= @memo.subject %> <%= @memo.subject %>
</div> </div>
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id=>'edit_memo'}) do |f| %> <%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id => 'new_memo'}) do |f| %>
<%= render :partial => "memos/form", :locals => {:f => f} %> <%= render :partial => "memos/form", :locals => {:f => f} %>
<% end %> <% end %>

View File

@ -1758,6 +1758,7 @@ zh:
label_borad_org_subfield: 资源栏目讨论区 label_borad_org_subfield: 资源栏目讨论区
view_borad_course: 课程讨论 view_borad_course: 课程讨论
label_memo_create_succ: 发布成功 label_memo_create_succ: 发布成功
label_memo_update_succ: 更新成功
label_memo_create_fail: 发布失败 label_memo_create_fail: 发布失败
label_forum_create_succ: 贴吧新建成功 label_forum_create_succ: 贴吧新建成功
label_forum_create_fail: 贴吧新建失败 label_forum_create_fail: 贴吧新建失败

View File

@ -458,6 +458,7 @@ RedmineApp::Application.routes.draw do
post 'create_memo' post 'create_memo'
post 'create_feedback' post 'create_feedback'
post 'mail_feedback' post 'mail_feedback'
post 'update_memo_description'
match 'search_memo', :via => [:get, :post] match 'search_memo', :via => [:get, :post]
match 'delete_forum_tag',:via =>[:get] match 'delete_forum_tag',:via =>[:get]
match 'add_forum_tag',:via=>[:get] match 'add_forum_tag',:via=>[:get]