diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 32cd4d197..bdbbb8e37 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -66,17 +66,28 @@ class BoardsController < ApplicationController 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)" @topic_count = @board.topics.count - #@topic_pages = paginateHelper @board.topics,10 - #@topic_pages = Paginator.new @topic_count, per_page_option, params['page'] - board_topics = @board.topics. - reorder("#{Message.table_name}.sticky DESC"). - includes(:last_reply). - # limit(@topic_pages.per_page). - # offset(@topic_pages.offset). - order(sort_clause). - preload(:author, {:last_reply => :author}). - all - @topics = paginateHelper board_topics,10 + if @project + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @topics = @board.topics. + reorder("#{Message.table_name}.sticky DESC"). + includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + order(sort_clause). + preload(:author, {:last_reply => :author}). + all + elsif @course + board_topics = @board.topics. + reorder("#{Message.table_name}.sticky DESC"). + includes(:last_reply). + # limit(@topic_pages.per_page). + # offset(@topic_pages.offset). + order(sort_clause). + preload(:author, {:last_reply => :author}). + all + @topics = paginateHelper board_topics,10 + end + @message = Message.new(:board => @board) #modify by nwb if @project diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b72cb9218..b50b2720f 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -44,18 +44,35 @@ class MessagesController < ApplicationController end @reply_count = @topic.children.count - @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page - @replies = @topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.created_on DESC"). - limit(@reply_pages.per_page). - offset(@reply_pages.offset). - all + # @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page + # @replies = @topic.children. + # includes(:author, :attachments, {:board => :project}). + # reorder("#{Message.table_name}.created_on DESC"). + # limit(@reply_pages.per_page). + # offset(@reply_pages.offset). + # all @reply = Message.new(:subject => "RE: #{@message.subject}") if @course + messages_replies = @topic.children. + includes(:author, :attachments, {:board => :project}). + reorder("#{Message.table_name}.created_on DESC"). + #limit(@reply_pages.per_page). + #offset(@reply_pages.offset). + all + @replies = paginateHelper messages_replies,10 + @reply = Message.new(:subject => "RE: #{@message.subject}") render :action => "show", :layout => "base_courses"#by young else + @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page + @replies = @topic.children. + includes(:author, :attachments, {:board => :project}). + reorder("#{Message.table_name}.created_on DESC"). + limit(@reply_pages.per_page). + offset(@reply_pages.offset). + all + + @reply = Message.new(:subject => "RE: #{@message.subject}") render :action => "show", :layout => "base_projects"#by young end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index eefcea6ca..1f628c8e1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -270,7 +270,7 @@ module ApplicationHelper onclick = "$('##{id}').slideToggle(); " onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ") onclick << "return false;" - link_to(name, "#", :onclick => onclick) + link_to(name, "#", :onclick => onclick,:class => options[:class]) end def image_to_function(name, function, html_options = {}) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 7ddb4eb9c..256ca2b0a 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -14,7 +14,7 @@ <%= l(:label_message_new) %> <%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => false, :id => 'message-form'} do |f| %> - <%= render :partial => 'messages/form', :locals => {:f => f} %> + <%= render :partial => 'messages/form_course', :locals => {:f => f} %>

<%= l(:button_submit)%> diff --git a/app/views/messages/_course_new.html.erb b/app/views/messages/_course_new.html.erb index 265c273d9..ba83b271e 100644 --- a/app/views/messages/_course_new.html.erb +++ b/app/views/messages/_course_new.html.erb @@ -5,8 +5,9 @@

<%= l(:label_message_new) %>

diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index f5c2a4211..e79913380 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -53,144 +53,104 @@ /*border-radius: 10px;*/ } -
- - - <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> - -
- <%= watcher_link(@topic, User.current) %> - <%= link_to( - l(:button_quote), - {:action => 'quote', :id => @topic}, - :remote => true, - :method => 'get', - :class => 'icon icon-comment', - :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - l(:button_edit), - {:action => 'edit', :id => @topic}, - :class => 'icon icon-edit' - ) if @message.course_editable_by?(User.current) %> - <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => @topic}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'icon icon-del' - ) if @message.course_destroyable_by?(User.current) %> -
-
-
- <%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %> -
-

- <%= link_to @topic.author, user_path(@topic.author) %> -

-
-
-
- <% if @project %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project),title: @topic.subject.to_s %> - <% elsif @course %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, course_boards_path(@topic.course),title: @topic.subject.to_s %> - <% end %> -
-
- <%= textilizable(@topic, :content) %> - <%= link_to_attachments @topic, :author => false %> -
-
-
- <%= authoring @topic.created_on, @topic.author %> -
-
- <% if User.current.logged? %> - <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> - <% else %> - <%= link_to l(:button_reply), signin_path %> - <% end %> -
-
-
-
+
+

<%= l(:label_board) %>

+
+
<%= link_to image_tag(url_to_avatar(@topic.author),:width => '46',:height => '46'), user_path(@topic.author) %>
+
+

<%= link_to @topic.subject, course_boards_path(@topic.course),title: @topic.subject.to_s %>

+
+

由<%= link_to_user_header @topic.author,false,:class=> 'problem_name' %> 添加于<%= format_time(@topic.created_on) %>

+
+ + <%= watcher_link(@topic, User.current) %> + <%= link_to( + l(:button_edit), + {:action => 'edit', :id => @topic}, + :class => 'talk_edit fr' + ) if @message.course_editable_by?(User.current) %> + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => @topic}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'talk_edit fr' + ) if @message.course_destroyable_by?(User.current) %> +
+
<%= textilizable(@topic, :content) %>
+
<%= link_to_attachments @topic, :author => false %>
+ +
+ <% if User.current.logged? %> + <%= toggle_link l(:button_reply), "reply", :focus => 'message_content',:class => 'talk_edit fr' %> + <% else %> + <%= link_to l(:button_reply), signin_path,:class => 'talk_edit fr' %> + <% end %> + <%= link_to( + l(:button_quote), + {:action => 'quote', :id => @topic}, + :remote => true, + :method => 'get', + :class => 'talk_edit fr', + :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %> +
+
<% unless @replies.empty? %> -
-
-
-
-

- <%= l(:label_reply_plural) %> - (<%= @reply_count %>) -

<% reply_count = 0 %> <% @replies.each do |message| %> -
"> - - - - - - - - - - - - - -
- <%= link_to image_tag(url_to_avatar(message.author), :class => "avatar"), user_path(message.author) %> - -
- <%= link_to( - l(:button_quote), - {:action => 'quote', :id => message}, - :remote => true, - :method => 'get', - :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - #image_tag('edit.png'), - l(:button_edit), - {:action => 'edit', :id => message}, - :title => l(:button_edit) - ) if message.course_editable_by?(User.current) %> - <%= link_to( - #image_tag('delete.png'), - l(:button_delete), - {:action => 'destroy', :id => message}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if message.course_destroyable_by?(User.current) %> -
-
- <%= textilizable message,:content,:attachments => message.attachments %> -
- <%= link_to_attachments message, :author => false %> -
- <%= authoring message.created_on, message.author %> -
-
- +
"> +
<%= link_to image_tag(url_to_avatar(message.author), :width => '46',:height => '46'), user_path(message.author) %>
+
+
+ <%= link_to_user_header message.author,false,:class => 'c_blue fb fl mb10 ' %> + <%= format_time(message.created_on) %> +
+ <%= textilizable message,:content,:attachments => message.attachments %> + <%= link_to_attachments message, :author => false %> +
+
+ <%= link_to( + l(:button_quote), + {:action => 'quote', :id => message}, + :remote => true, + :method => 'get', + :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> + <%= link_to( + #image_tag('edit.png'), + l(:button_edit), + {:action => 'edit', :id => message}, + :title => l(:button_edit) + ) if message.course_editable_by?(User.current) %> + <%= link_to( + #image_tag('delete.png'), + l(:button_delete), + {:action => 'destroy', :id => message}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if message.course_destroyable_by?(User.current) %> +
+
+
+
+
<% end %> - <% end %> <% if !@topic.locked? && authorize_for_course('messages', 'reply') %> <% end %> - + <% html_title @topic.subject %> <%= error_messages_for 'message' %> <% replying ||= false %> -<% extra_option = replying ? { readonly: true} : { maxlength: 200 } %> -
  • - - <% if replying %> - <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585" }.merge(extra_option) %> - <% else %> - <%= f.text_field :subject, { size: 60, id: "message_subject", onkeyup: "regexSubject();",:class=>"talk_input w585" }.merge(extra_option) %> - <% end %> - -
  • -
  • - <% unless replying %> - <% if @message.safe_attribute? 'sticky' %> - <%= f.check_box :sticky %> - <%= label_tag 'message_sticky', l(:label_board_sticky) %> - <% end %> - <% if @message.safe_attribute? 'locked' %> - <%= f.check_box :locked %> - <%= label_tag 'message_locked', l(:label_board_locked) %> - <% end %> - <% end %> -
    -
  • -
  • - +
    + + <% extra_option = replying ? { readonly: true} : { maxlength: 200 } %> +

    + +
    + <% if replying %> + <%= f.text_field :subject, { size: 60, style: "width: 99%;", id: "message_subject" }.merge(extra_option) %> + <% else %> + <%= f.text_field :subject, { size: 60, style: "width: 99%;", id: "message_subject", onkeyup: "regexSubject();" }.merge(extra_option) %> + <% end %> + +

    +

    + <% unless replying %> + <% if @message.safe_attribute? 'sticky' %> + <%= f.check_box :sticky %> + <%= label_tag 'message_sticky', l(:label_board_sticky) %> + <% end %> + <% if @message.safe_attribute? 'locked' %> + <%= f.check_box :locked %> + <%= label_tag 'message_locked', l(:label_board_locked) %> + <% end %> + <% end %> +

    +

    +

    <%= text_area :quote,:quote,:style => 'display:none' %> - <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> - -
  • -
    -
  • - - <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %> -
  • -
  • - <%= l(:button_submit)%> - <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form' ,target='preview',{:class => 'blue_btn grey_btn fl c_white'} )%> -
    -
  • +

    +

    + <%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %> + <%= f.text_area :content, :cols => 80, :rows => 13, :class => 'wiki-edit', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000 %> + +

    +

    + <%= l(:label_attachment_plural) %> +
    + <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %> +

    +
    \ No newline at end of file diff --git a/app/views/messages/_form_course.html.erb b/app/views/messages/_form_course.html.erb new file mode 100644 index 000000000..cc788004c --- /dev/null +++ b/app/views/messages/_form_course.html.erb @@ -0,0 +1,82 @@ + +<%= error_messages_for 'message' %> +<% replying ||= false %> +<% extra_option = replying ? { readonly: true} : { maxlength: 200 } %> + +
  • + + <% if replying %> + <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585" }.merge(extra_option) %> + <% else %> + <%= f.text_field :subject, { size: 60, id: "message_subject", onkeyup: "regexSubject();",:class=>"talk_input w585" }.merge(extra_option) %> + <% end %> + +
  • +
  • + <% unless replying %> + <% if @message.safe_attribute? 'sticky' %> + <%= f.check_box :sticky %> + <%= label_tag 'message_sticky', l(:label_board_sticky) %> + <% end %> + <% if @message.safe_attribute? 'locked' %> + <%= f.check_box :locked %> + <%= label_tag 'message_locked', l(:label_board_locked) %> + <% end %> + <% end %> +
    +
  • +
  • +
    + + <%= text_area :quote,:quote,:style => 'display:none' %> + <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> +
    + +
  • +
    +
  • + + <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %> +
  • +
  • +
    +
  • diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index d656af555..b37619b19 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -1,23 +1,45 @@ -<% if @message.project %> +
    +

    <%= l(:label_course_board) %>

    +
    + + <% if @message.project %> <%= board_breadcrumb(@message) %> +

    <%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %>

    + + <%= form_for @message, { + :as => :message, + :url => {:action => 'edit'}, + :html => {:multipart => true, + :id => 'message-form', + :method => :post} + } do |f| %> + <%= render :partial => 'form', + :locals => {:f => f, :replying => !@message.parent.nil?} %> + + <%= l(:button_save) %> + + <%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "ButtonColor m3p10" %> + <% end %> <% elsif @message.course %> <%= course_board_breadcrumb(@message) %> +
    + +
    <% end %> -

    <%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %>

    -<%= form_for @message, { - :as => :message, - :url => {:action => 'edit'}, - :html => {:multipart => true, - :id => 'message-form', - :method => :post} - } do |f| %> - <%= render :partial => 'form', - :locals => {:f => f, :replying => !@message.parent.nil?} %> - - <%= l(:button_save) %> - - <%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "ButtonColor m3p10" %> -<% end %>
    diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erb index 07c0164b8..d5d6551ec 100644 --- a/app/views/messages/new.html.erb +++ b/app/views/messages/new.html.erb @@ -5,7 +5,7 @@ <%= l(:label_message_new) %> <%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> + <%= render :partial => 'form', :locals => {:f => f,:is_new => true} %> <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form' ,target='preview',{:class => 'whiteButton m3p10'} )%> <% end %> diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index 167ea8308..a876e2401 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -60,7 +60,7 @@
    -

    课程通知

    +

    <%= l(:label_course_news) %>

    <% if authorize_for_course('news', 'edit') %>