From 71e7725e5c63b78b1361145010dee20a2bb4a14f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 26 Sep 2017 08:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B4=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/debates.js.coffee | 3 + app/assets/stylesheets/debates.css.scss | 3 + app/controllers/debates_controller.rb | 2 + app/controllers/forums_controller.rb | 6 +- app/helpers/debates_helper.rb | 2 + app/views/forums/index.html.erb | 184 +++++++++++++++++---- app/views/layouts/_logined_header.html.erb | 1 + config/routes.rb | 4 + 8 files changed, 175 insertions(+), 30 deletions(-) create mode 100644 app/assets/javascripts/debates.js.coffee create mode 100644 app/assets/stylesheets/debates.css.scss create mode 100644 app/controllers/debates_controller.rb create mode 100644 app/helpers/debates_helper.rb diff --git a/app/assets/javascripts/debates.js.coffee b/app/assets/javascripts/debates.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/debates.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/debates.css.scss b/app/assets/stylesheets/debates.css.scss new file mode 100644 index 000000000..6c45b3be9 --- /dev/null +++ b/app/assets/stylesheets/debates.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the debates controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb new file mode 100644 index 000000000..5e442e4bb --- /dev/null +++ b/app/controllers/debates_controller.rb @@ -0,0 +1,2 @@ +class DebatesController < ApplicationController +end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index ed646354c..a8d3adb0a 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -121,6 +121,7 @@ class ForumsController < ApplicationController def index order = "" @order_str = "" + @user = User.current if(params[:reorder_complex]) order = "replies_count #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}" @order_str = "reorder_complex="+params[:reorder_complex] @@ -148,10 +149,13 @@ class ForumsController < ApplicationController @my_forums_count = Memo.where("author_id =? and parent_id is null", User.current.id).count @my_memos_count = Memo.where("author_id =? and parent_id is not null", User.current.id).count @errors = params[:errors] + memos_id = Memo.where("author_id =?", User.current.id).map(&:id) + @memos_praise_count = PraiseTread.where(:praise_tread_object_id => memos_id, :praise_tread_object_type => "Memo").count + respond_to do |format| format.js format.html { - render :layout => 'base_new_forum' + render :layout => 'base_edu' }# show.html.erb format.json { render json: @forum } end diff --git a/app/helpers/debates_helper.rb b/app/helpers/debates_helper.rb new file mode 100644 index 000000000..f551d98d1 --- /dev/null +++ b/app/helpers/debates_helper.rb @@ -0,0 +1,2 @@ +module DebatesHelper +end diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 5b9f374f8..3c42ad24e 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -1,3 +1,128 @@ +
+

+ + <%= @user.show_name %> > 讨论 +

+
+
+ +
    +
  • <%= @memos_praise_count %>
    被赞
  • +
  • <%= @my_memos_count %>
    回复/评论
  • +
  • <%= @my_forums_count %>
    主题
  • +
+
+
+
+
+

问吧

+ + 新话题 +
+
+ +
+ +
+ 华沙沙 +

+ 五个值得推荐的英语学习网站,不可错过哦! +

+

1.练习口语 在线英语: http://dwz.cn/1XHGmL(免费在线口语课领取,外教一对一交流互动~) 特点:有正式课程挂网上公开,注册可免费听口语课,与外国老师实时交流哦~哈哈哈哈哈哈

+

+ 10 + 10 + 10 + + 最后更新:2小时前 +

+ +
+
+ +
+ +
+ 华沙沙 +

+ 五个值得推荐的英语学习网站,不可错过哦! +

+

1.练习口语 在线英语: http://dwz.cn/1XHGmL(免费在线口语课领取,外教一对一交流互动~) 特点:有正式课程挂网上公开,注册可免费听口语课,与外国老师实时交流哦~哈哈哈哈哈哈

+

+ 10 + 10 + 10 + + 最后更新:2小时前 +

+ +
+
+ +
+ +
+ 华沙沙 +

+ 五个值得推荐的英语学习网站,不可错过哦! +

+

1.练习口语 在线英语: http://dwz.cn/1XHGmL(免费在线口语课领取,外教一对一交流互动~) 特点:有正式课程挂网上公开,注册可免费听口语课,与外国老师实时交流哦~哈哈哈哈哈哈

+

+ 10 + 10 + 10 + + 最后更新:2小时前 +

+ + +
+
+
+
+
+ +
+
+
+
+
+ +<% if false %> <%= content_for(:header_tags) do %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> <% end %> @@ -107,34 +232,34 @@ }); var first_click = true; -// function check_and_submit(){ -// if(!check_memo_name()){ -// return; -// } -// if($("textarea[name='memo[subject]']").val().trim() != "" && !memo_content.isEmpty() && first_click){ -// first_click = false; -// memo_content.sync(); -// $.ajax({ -// url:'/forums/'+'<%#= @forum.id.to_s%>'+'/memos', -// type:'post', -// data:$("#new_memo").serialize(), -// success:function(data){ -// -// }, -// error:function(){ -// alert('请检查当前网络连接') -// } -// }); -// //$("#new_memo").submit(); -// }else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.isEmpty()){ -// $("#error").html("主题和内容不能为空").show(); -// } -// else if($("textarea[name='memo[subject]']").val().trim() == "" && !memo_content.isEmpty() ){ -// $("#error").html("主题不能为空").show(); -// }else if($("textarea[name='memo[subject]']").val().trim() != "" && memo_content.isEmpty()){ -// $("#error").html("内容不能为空").show(); -// } -// } + // function check_and_submit(){ + // if(!check_memo_name()){ + // return; + // } + // if($("textarea[name='memo[subject]']").val().trim() != "" && !memo_content.isEmpty() && first_click){ + // first_click = false; + // memo_content.sync(); + // $.ajax({ + // url:'/forums/'+'<%#= @forum.id.to_s%>'+'/memos', + // type:'post', + // data:$("#new_memo").serialize(), + // success:function(data){ + // + // }, + // error:function(){ + // alert('请检查当前网络连接') + // } + // }); + // //$("#new_memo").submit(); + // }else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.isEmpty()){ + // $("#error").html("主题和内容不能为空").show(); + // } + // else if($("textarea[name='memo[subject]']").val().trim() == "" && !memo_content.isEmpty() ){ + // $("#error").html("主题不能为空").show(); + // }else if($("textarea[name='memo[subject]']").val().trim() != "" && memo_content.isEmpty()){ + // $("#error").html("内容不能为空").show(); + // } + // } function check_memo_name(){ if($("#memo_subject").val().trim().length > 50){ @@ -156,4 +281,5 @@ memo_content.html('') $('#error').html('').hide(); } - \ No newline at end of file + +<% end %> diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 73acfb0e7..2085a3c5d 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -18,6 +18,7 @@
  • <%= link_to "全部实训", shixuns_path, :class => "new-nav-a font-16" %>
  • <%= link_to "实训路径", subjects_path, :class => "new-nav-a font-16" %>
  • <%= link_to "在线课堂", courses_path, :class => "new-nav-a font-16" %>
  • +
  • <%= link_to "讨论", forums_path, :class => "new-nav-a font-16" %>
  • diff --git a/config/routes.rb b/config/routes.rb index 700d20d6a..403cf5eaa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -738,6 +738,10 @@ RedmineApp::Application.routes.draw do end end + resources :debates do + + end + resources :cooperation do collection do