From 19eaa012b78bc8eca912ef3fc22b20a8a926468f Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 24 Mar 2015 17:12:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 10 ++- app/controllers/messages_controller.rb | 7 ++ app/controllers/news_controller.rb | 6 +- app/views/attachments/_form_course.html.erb | 4 +- app/views/boards/_course_show.html.erb | 81 ++++++------------ app/views/files/_attachement_list.html.erb | 5 +- app/views/files/_course_file.html.erb | 7 +- app/views/files/_upload_show.html.erb | 9 +- app/views/messages/_course_new.html.erb | 13 +++ app/views/messages/_form.html.erb | 91 ++++++++++----------- app/views/messages/new.html.erb | 19 ++--- app/views/news/_course_form.html.erb | 77 +++++++++++++++-- app/views/news/_course_news.html.erb | 75 +---------------- app/views/news/new.html.erb | 27 ++++-- config/locales/courses/zh.yml | 6 +- config/locales/zh.yml | 1 + public/javascripts/course.js | 14 +++- public/stylesheets/courses.css | 2 +- 18 files changed, 230 insertions(+), 224 deletions(-) create mode 100644 app/views/messages/_course_new.html.erb diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index f797c7a2f..32cd4d197 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -66,15 +66,17 @@ class BoardsController < ApplicationController 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)" @topic_count = @board.topics.count - @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] - @topics = @board.topics. + #@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). + # limit(@topic_pages.per_page). + # offset(@topic_pages.offset). order(sort_clause). preload(:author, {:last_reply => :author}). all + @topics = paginateHelper board_topics,10 @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 d2a253c2a..b72cb9218 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -76,6 +76,13 @@ class MessagesController < ApplicationController layout_file = @project ? 'base_projects' : 'base_courses' render :action => 'new', :layout => layout_file end + else + respond_to do |format| + format.html { + layout_file = @project ? 'base_projects' : 'base_courses' + render :layout => layout_file + } + end end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index e00121d97..617e56575 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -68,15 +68,15 @@ class NewsController < ApplicationController elsif @course if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) scope = @course ? @course.news.course_visible : News.course_visible - scope_page = paginateHelper scope,10 + @news_count = scope.count #@news_pages = Paginator.new @news_count, @limit, params['page'] #@offset ||= scope_page.offset - @newss = scope_page.all(:include => [:author, :course], + scope_order = scope.all(:include => [:author, :course], :order => "#{News.table_name}.created_on DESC") # :offset => @offset, # :limit => @limit) - + @newss = paginateHelper scope_order,10 respond_to do |format| format.html { @news = News.new diff --git a/app/views/attachments/_form_course.html.erb b/app/views/attachments/_form_course.html.erb index b2089d629..bfe600131 100644 --- a/app/views/attachments/_form_course.html.erb +++ b/app/views/attachments/_form_course.html.erb @@ -38,7 +38,7 @@ <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> -<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()" %> +<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()",:class =>"sub_btn" %> <%= file_field_tag 'attachments[dummy][file]', :id => '_file', :class => 'file_selector', @@ -52,7 +52,7 @@ :upload_path => uploads_path(:format => 'js'), :description_placeholder => l(:label_optional_description) } %> -<%= l(:label_no_file_uploaded)%> +<%= l(:label_no_file_uploaded)%> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index eac85e2d7..7ddb4eb9c 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -26,10 +26,11 @@ -
- <%=h @board.name %> +
+

<%= l(:label_board_plural) %>

+ <% if !User.current.logged?%>
<%= l(:label_user_login_course_board) %> @@ -37,71 +38,35 @@
<% end %> - -
- - 共有 - <%=link_to @topic_count,:controller => 'boards',:action => 'index' %> - 个贴子 - - - <%= link_to l(:label_message_new), - new_board_message_path(@board), - :class => 'icon icon-add', - :onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %> - +
+

<%= l(:label_totle) %><%= @topic_count %><%= l(:label_course_momes_count) %>

+ <%= link_to l(:label_message_new), + new_board_message_path(@board), + :class => 'problem_new_btn fl c_dorange' if User.current.logged? %> +
-
<% if @topics.any? %> <% @topics.each do |topic| %> - - - - - -
<%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %> - - - - - - - - -
- <%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title: topic.subject.to_s %> - - - - - - - - -
- <%=link_to (topic.replies_count), board_message_path(@board, topic) %> -
- 回答 -
-
- - <%= authoring topic.created_on, topic.author %> -
-
-
-
+
+ <%= link_to image_tag(url_to_avatar(topic.author), :width=>"32",:height=>"32"), user_path(topic.author),:class => 'problem_pic talk_pic fl' %> +
+ <%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title: topic.subject.to_s,:class => "problem_tit fl fb c_dblue" %> + 置顶 +

由<%= link_to topic.author,user_path(topic.author),:class => "problem_name" %>添加于<%= format_time(topic.created_on) %>

+
+ <%=link_to (l(:label_reply) + topic.replies_count.to_s), board_message_path(@board, topic),:class => "talk_btn fr c_white" %> + +
+
<% end %> - <% else %>

<%= l(:label_no_data) %>

<% end %> -
- +
    + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
<% other_formats_links do |f| %> <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> <% end %> diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index 001519a28..d36ff2bd6 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -22,7 +22,7 @@
- + <%= file_field_tag 'attachments[dummy][file]', :id => '_file', :class => 'file_selector', @@ -37,10 +37,9 @@ :description_placeholder => l(:label_optional_description) } %> - \ No newline at end of file diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index ac7a23232..ac02342ed 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -48,7 +48,7 @@ <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> <% end %> <% if is_course_teacher(User.current,@course) %> - 上传资源 + 上传资源 <% end %>
@@ -56,8 +56,11 @@
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@curse_attachments} %>
+
+ <%= render :partial => 'upload_show',:locals => {:course => @course}%> +
+
123
- <% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/_upload_show.html.erb b/app/views/files/_upload_show.html.erb index 91d050d93..bc7fc9030 100644 --- a/app/views/files/_upload_show.html.erb +++ b/app/views/files/_upload_show.html.erb @@ -1,4 +1,7 @@ -
+ +
+
+

<%= l(:label_upload_files)%>

@@ -8,8 +11,8 @@ <%= render :partial => 'attachement_list',:locals => {:course => course} %>
- <%= l(:button_confirm)%> - <%= l(:button_cancel)%> + <%= l(:button_cancel)%> + <%= l(:button_confirm)%> <% end %>
diff --git a/app/views/messages/_course_new.html.erb b/app/views/messages/_course_new.html.erb new file mode 100644 index 000000000..265c273d9 --- /dev/null +++ b/app/views/messages/_course_new.html.erb @@ -0,0 +1,13 @@ +
+

<%= l(:label_board_plural) %>

+
+
+

<%= l(:label_message_new) %>

+
    + <%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + + <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index 3a82d3509..9f05a93f7 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -33,54 +33,51 @@ } return false; } + function submitCoursesBoard() + { + if(regexSubject()&®exContent()){$("#message-form").submit();} + } <%= error_messages_for 'message' %> <% replying ||= false %> +<% extra_option = replying ? { readonly: true} : { maxlength: 200 } %> -
- - <% 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' %> -

-

- <%= 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 +
  • + + <% 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} %> +
  • +
  • + <%= l(:button_submit)%> + <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form' ,target='preview',{:class => 'blue_btn grey_btn fl c_white'} )%> +
    +
  • diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erb index 04ea99745..07c0164b8 100644 --- a/app/views/messages/new.html.erb +++ b/app/views/messages/new.html.erb @@ -4,18 +4,15 @@ » <%= l(:label_message_new) %> + <%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <%= 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 %> + +
    <% elsif @course %> -

    - <%= link_to h(@board.name), :controller => 'boards', :action => 'show', :course_id => @course, :id => @board %> - » - <%= l(:label_message_new) %> -

    + <%= render :partial => 'course_new' %> <% end %> -<%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> - <%= 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_form.html.erb b/app/views/news/_course_form.html.erb index 3b68bbf76..3c77e8768 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -1,17 +1,78 @@ -
  • + +
  • +
  • +
  • -

    - +

  • + <%= render :partial => 'attachments/form', :locals => {:container => @news} %> -

    - - \ No newline at end of file +
  • +
  • + <%= link_to l(:button_create), "#", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %> + <%= link_to l(:button_cancel), course_news_index_path(@course), :onclick => '$("#add-news").hide()', :class => 'blue_btn grey_btn fl c_white' %> +
    +
  • + \ No newline at end of file diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index 45af13328..731ae78a1 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -3,63 +3,7 @@ label_tips = l(:label_course_news) %> -

    <%= label_tips %>

    @@ -68,26 +12,9 @@

    <%= l(:label_total_news) %><%= @news_count %><%= l(:label_course_news_count) %>

    <% if @course && User.current.allowed_to?(:manage_news, @course) %> <%= link_to(btn_tips,new_course_news_path(@course), - :class => 'problem_new_btn fl c_dorange', - :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> + :class => 'problem_new_btn fl c_dorange')%>
    - <% end %>
    diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb index 8c9bc784a..93040a882 100644 --- a/app/views/news/new.html.erb +++ b/app/views/news/new.html.erb @@ -1,4 +1,8 @@ +<% + btn_tips = l(:label_news_notice) + label_tips = l(:label_course_news) +%> <% if @project %> <%= labelled_form_for @news, :url => project_news_index_path(@project), :html => {:id => 'news-form', :multipart => true} do |f| %> @@ -7,11 +11,22 @@ <%#= preview_link preview_news_path(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> <% end %> <% elsif @course %> - <%= labelled_form_for @news, :url => course_news_index_path(@course), - :html => {:id => 'news-form', :multipart => true} do |f| %> - <%= render :partial => 'news/form', :locals => {:f => f} %> - <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> - <%#= preview_link preview_news_path(:course_id => @course), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> - <% end %> +
    +

    <%= label_tips %>

    +
    +
    + <%= error_messages_for @news %> +

    + <%= l(:bale_news_notice)%> +

    +
      + <%= labelled_form_for @news, :url => course_news_index_path(@course), + :html => {:id => 'news-form', :multipart => true} do |f| %> + <%= render :partial => 'news/course_form', :locals => {:f => f, :is_new => true} %> + + <% end if @course %> +
    +
    +
    <% end %>
    diff --git a/config/locales/courses/zh.yml b/config/locales/courses/zh.yml index c99f4ed55..3e64b61f3 100644 --- a/config/locales/courses/zh.yml +++ b/config/locales/courses/zh.yml @@ -81,4 +81,8 @@ zh: label_course_news_count: "个课程通知" label_release_news: "发布通知" label_create_time: "创建时间" - #news end \ No newline at end of file + #news end + + #boards + label_course_momes_count: "个帖子" + #boards count \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 373943f05..d7e393863 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2079,6 +2079,7 @@ zh: label_end_time: 截止时间 label_send_email: 确定发送 label_input_email: 请输入邮箱地址 + #api end project_module_files: 资源库 label_totle: 共有 diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 666cb6f3b..593bb814a 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -126,4 +126,16 @@ function submit_new_bid(id) { $("#"+id).submit(); } -} \ No newline at end of file +} + +function show_window (id1,id2,top,left) { + $('#'+ id1).css('top',top); + $('#'+ id1).css('left',left); + $('#'+ id1).css('display','block'); + $('#' + id2).css('display','block'); +} + +function close_window(id1,id2){ + $('#' + id1).css('display','none'); + $('#' + id2).css('display','none'); +} diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 730236d8e..2b14daa60 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -69,7 +69,7 @@ ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} .talk_top span{ color:#ff7143;} .talk_txt{ width:460px; margin-left:10px; color:#676868;} .talk_up{ color:#f63c00;} -.talk_pic{width:32px; height:32px; padding:2px;} +a.talk_pic{width:32px; height:32px; padding:2px;} a.talk_btn{ background:#64bdd9; width:50px; height:20px; color:#fff; text-align:center; margin-top:12px; padding-top:3px;} a:hover.talk_btn{ background:#2a9dc1;} /****讨论区内页***/ From 13245282d4c77c80bf7420da895e4b5a59f67150 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 24 Mar 2015 17:21:41 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E5=B8=96=E5=AD=90=E6=95=B0=E9=87=8F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_courses.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index ab70ca8b6..2ad4435c5 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -133,7 +133,7 @@