From 7fe3f9fe716aa3509ccf2eac9a65eb1252a1ca76 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 15 Jul 2016 20:30:50 +0800 Subject: [PATCH 01/52] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/wechat.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/wechat.yml b/config/wechat.yml index d839f1606..6b3799706 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -20,26 +20,26 @@ default: &default encrypt_mode: false # if true must fill encoding_aes_key #production - encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw" - jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" - - #template - binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc" - journal_notice: "uC1zAw4F2q6HTA3Pcj8VUO6wKKKiYFwnPJB4iXxpdoM" - homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps" - class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA" - create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw" - - #test -# encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" +# encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw" # jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" # # #template -# binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU" -# journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE" -# homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" -# class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" -# create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I" +# binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc" +# journal_notice: "uC1zAw4F2q6HTA3Pcj8VUO6wKKKiYFwnPJB4iXxpdoM" +# homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps" +# class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA" +# create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw" + + #test + encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" + jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" + + #template + binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU" + journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE" + homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" + class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" + create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I" production: <<: *default From 51692eadd619f6ffbd5ebab9890916c425134806 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 17 Jul 2016 00:49:35 +0800 Subject: [PATCH 02/52] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=B8=8A=E7=BA=BF?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/wechats_helper.rb | 20 +++++++++ app/views/wechats/user_activities.html.erb | 28 +----------- config/application.rb | 5 ++- lib/tasks/wechat.rake | 31 +++++++++++++ public/javascripts/wechat/build/app.min.js | 51 ++++++++++++++++------ 5 files changed, 95 insertions(+), 40 deletions(-) create mode 100644 app/helpers/wechats_helper.rb create mode 100644 lib/tasks/wechat.rake diff --git a/app/helpers/wechats_helper.rb b/app/helpers/wechats_helper.rb new file mode 100644 index 000000000..5c6b3da8c --- /dev/null +++ b/app/helpers/wechats_helper.rb @@ -0,0 +1,20 @@ +#coding=utf-8 +# + +module WechatsHelper + def include_wechat_jsfile + if Rails.env.production? + javascript_include_tag '/javascripts/wechat/build/app.min.js' + else + wechat_path = File.join(Rails.root, "public", "javascripts", "wechat") + srcs = Rails.application.config.wechat_srcs + paths = [] + srcs.each do |src| + Dir.glob(wechat_path+ "/#{src}" ) do |path| + paths << path[File.join(Rails.root, "public").to_s.size, path.size] + end + end + javascript_include_tag *paths + end + end +end diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb index 6c3da9cf4..d21449648 100644 --- a/app/views/wechats/user_activities.html.erb +++ b/app/views/wechats/user_activities.html.erb @@ -10,7 +10,7 @@ - + <%= stylesheet_link_tag '/stylesheets/weui/weixin.css' %> - - - - - - - - - - - - - - - - - - - - - - - - - +<%= include_wechat_jsfile %> diff --git a/config/application.rb b/config/application.rb index 6f5542a1e..3885751f7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -66,6 +66,7 @@ module RedmineApp # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + config.assets.digest = true config.action_mailer.perform_deliveries = false @@ -82,6 +83,8 @@ module RedmineApp end end + config.wechat_srcs = ['app.js','others/factory.js','others/filter.js', 'controllers/*.js', 'directives/*.js', 'others/routes.js'] + config.before_initialize do end @@ -93,4 +96,4 @@ module RedmineApp end end -end \ No newline at end of file +end diff --git a/lib/tasks/wechat.rake b/lib/tasks/wechat.rake new file mode 100644 index 000000000..bbba9994c --- /dev/null +++ b/lib/tasks/wechat.rake @@ -0,0 +1,31 @@ +#coding=utf-8 +# + +def compress(srcs, outfile) + wechat_path = File.join(Rails.root, "public", "javascripts", "wechat") + out_buffer = '' + + srcs.each do |src| + Dir.glob("#{wechat_path}/#{src}").each do |path| + puts "assets #{path}" + out_buffer = out_buffer + "\n//#{File.basename(path)}\n" + Uglifier.compile(File.read(path)) + end + end + + File.open(File.join(wechat_path, "build/#{outfile}"), 'w+') {|f| f.write(out_buffer)} +end + + +namespace :wechat do + desc "assets javascript file" + task :assets => :environment do + srcs = Rails.application.config.wechat_srcs + compress(srcs, 'app.min.js') + end + + desc "minify angularjs" + task :minify => :environment do + srcs = ['../jquery-1.3.2.js','angular.js', 'angular-route.js', 'angular-sanitize.min.js'] + compress(srcs, 'angular.all.min.js') + end +end diff --git a/public/javascripts/wechat/build/app.min.js b/public/javascripts/wechat/build/app.min.js index b704dfb6e..f7838e901 100644 --- a/public/javascripts/wechat/build/app.min.js +++ b/public/javascripts/wechat/build/app.min.js @@ -1,24 +1,49 @@ -var app=angular.module("wechat",["ngRoute"]);app.constant("config",{rootPath:"/assets/wechat/",rootUrl:"/",apiUrl:"/api/v1/"}),app.run(["$rootScope","auth","$location","$routeParams",function(t,a,e,r){g_redirect_path&&g_redirect_path.length>1&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a,r){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(t,a,e){})}]); -app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,i,e){this.message=i,this.title=t,this.visible=!0,this.cb=e},t.prototype.dismiss=function(){this.message=null,this.title=null,this.visible=!1,this.cb&&this.cb()},{create:function(){return new t}}}),app.factory("auth",["$http","$routeParams","$q","session","config",function(t,i,e,a,c){var s=function(){var c=e.defer(),s=o();if(s&&s.length>10)c.resolve(s);else{window.g_code||i.code||a.get("code");t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?c.reject(t.data.message):(a.save("token",t.data.token),c.resolve(t.data.token))})["catch"](function(t){c.reject(t)})}return c.promise},o=function(){return a.get("token")};return{get_bind:s,token:o}}]),app.factory("session",function(){return{save:function(t,i){sessionStorage.setItem(t,i)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},i=function(i,e){t[i]=e},e=function(i){return t[i]};return{save:i,get:e}}),app.factory("common",["$http","auth","$routeParams","rms",function(t,i,e,a){var c=function(e,a,c,s){if(c.comment&&!(c.comment.length<=0)){var o=c.comment.replace(/\n/g,"
"),n={type:a,content:o,token:i.token()};c.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+e,data:n}).then(function(t){c.disabled=!1,"function"==typeof s&&s()},function(t){})}},s=function(e,a){return t({method:"GET",url:apiUrl+a+"/"+e+"?token="+i.token()})},o=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(t){})},n=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(t){})},r=function(t){t.scope.formData={comment:""};var i=function(i){s(i,t.type).then(function(i){t.loadCallback(i.data)},function(t){})};i(t.id),t.scope.addReply=function(e){console.log(e.comment),c(t.id,t.replyType,e,function(){t.scope.formData={comment:""},i(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count+=1,activities[i].has_praise=!0;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count+=1,course_activities[i].has_praise=!0;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count+=1,project_activities[i].has_praise=!0;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count+=1,t.has_praise=!0,o(t)},t.scope.decreasePraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count-=1,activities[i].has_praise=!1;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count-=1,course_activities[i].has_praise=!1;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count-=1,project_activities[i].has_praise=!1;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count-=1,t.has_praise=!1,n(t)}};return{init:r,addCommonReply:c,loadCommonData:s,addCommonPraise:o,decreaseCommonPraise:n}}]); -app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"教辅":""}}); -app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,e,t,i,c,s,o,r,_){t.replaceUrl=function(a){return a},t.menus=["所有动态","课程动态","项目动态"],t.alertService=_.create(),console.log("ActivityController load"),t.page=o.get("page")||0,t.activities=o.get("activities")||[],t.has_more=o.get("has_more"),t.course_page=o.get("course_page")||0,t.course_activities=o.get("course_activities")||[],t.course_has_more=o.get("course_has_more"),t.project_page=o.get("project_page")||0,t.project_activities=o.get("project_activities")||[],t.project_has_more=o.get("project_has_more"),t.loadActData=function(a,e){switch(container_type="All",a){case 1:container_type="All",t.page=e;break;case 2:container_type="Course",t.course_page=e;break;case 3:container_type="Project",t.project_page=e}i({method:"POST",url:apiUrl+"activities",data:{token:s.token(),page:e,container_type:container_type}}).then(function(a){if(a.data.page>0)switch(a.data.container_type){case"All":t.activities=t.activities.concat(a.data.data);break;case"Course":t.course_activities=t.course_activities.concat(a.data.data);break;case"Project":t.project_activities=t.project_activities.concat(a.data.data);break;case 3:}else switch(a.data.container_type){case"All":t.activities=a.data.data;break;case"Course":t.course_activities=a.data.data;break;case"Project":t.project_activities=a.data.data;break;case 3:}switch(a.data.container_type){case"All":o.save("activities",t.activities),t.has_more=a.data.count+10*a.data.page1&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(){})}]); +//factory.js +app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,i,e){this.message=i,this.title=t,this.visible=!0,this.cb=e},t.prototype.dismiss=function(){this.message=null,this.title=null,this.visible=!1,this.cb&&this.cb()},{create:function(){return new t}}}),app.factory("auth",["$http","$routeParams","$q","session","config",function(t,i,e,a){var c=function(){var c=e.defer(),o=s();if(o&&o.length>10)c.resolve(o);else{{window.g_code||i.code||a.get("code")}t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?c.reject(t.data.message):(a.save("token",t.data.token),c.resolve(t.data.token))})["catch"](function(t){c.reject(t)})}return c.promise},s=function(){return a.get("token")};return{get_bind:c,token:s}}]),app.factory("session",function(){return{save:function(t,i){sessionStorage.setItem(t,i)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},i=function(i,e){t[i]=e},e=function(i){return t[i]};return{save:i,get:e}}),app.factory("common",["$http","auth","$routeParams","rms",function(t,i,e,a){var c=function(e,a,c,s){if(c.comment&&!(c.comment.length<=0)){var o=c.comment.replace(/\n/g,"
"),n={type:a,content:o,token:i.token()};c.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+e,data:n}).then(function(){c.disabled=!1,"function"==typeof s&&s()},function(){})}},s=function(e,a){return t({method:"GET",url:apiUrl+a+"/"+e+"?token="+i.token()})},o=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(){})},n=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(){})},r=function(t){t.scope.formData={comment:""};var i=function(i){s(i,t.type).then(function(i){t.loadCallback(i.data)},function(){})};i(t.id),t.scope.addReply=function(e){console.log(e.comment),c(t.id,t.replyType,e,function(){t.scope.formData={comment:""},i(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count+=1,activities[i].has_praise=!0;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count+=1,course_activities[i].has_praise=!0;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count+=1,project_activities[i].has_praise=!0;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count+=1,t.has_praise=!0,o(t)},t.scope.decreasePraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count-=1,activities[i].has_praise=!1;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count-=1,course_activities[i].has_praise=!1;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count-=1,project_activities[i].has_praise=!1;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count-=1,t.has_praise=!1,n(t)}};return{init:r,addCommonReply:c,loadCommonData:s,addCommonPraise:o,decreaseCommonPraise:n}}]); +//filter.js +app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"\u6559\u8f85":""}}); +//activity.js +app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,e,t,i,c,s,o,r,_){t.replaceUrl=function(a){return a},t.menus=["\u6240\u6709\u52a8\u6001","\u8bfe\u7a0b\u52a8\u6001","\u9879\u76ee\u52a8\u6001"],t.alertService=_.create(),console.log("ActivityController load"),t.page=o.get("page")||0,t.activities=o.get("activities")||[],t.has_more=o.get("has_more"),t.course_page=o.get("course_page")||0,t.course_activities=o.get("course_activities")||[],t.course_has_more=o.get("course_has_more"),t.project_page=o.get("project_page")||0,t.project_activities=o.get("project_activities")||[],t.project_has_more=o.get("project_has_more"),t.loadActData=function(a,e){switch(container_type="All",a){case 1:container_type="All",t.page=e;break;case 2:container_type="Course",t.course_page=e;break;case 3:container_type="Project",t.project_page=e}i({method:"POST",url:apiUrl+"activities",data:{token:s.token(),page:e,container_type:container_type}}).then(function(a){if(a.data.page>0)switch(a.data.container_type){case"All":t.activities=t.activities.concat(a.data.data);break;case"Course":t.course_activities=t.course_activities.concat(a.data.data);break;case"Project":t.project_activities=t.project_activities.concat(a.data.data);break;case 3:}else switch(a.data.container_type){case"All":t.activities=a.data.data;break;case"Course":t.course_activities=a.data.data;break;case"Project":t.project_activities=a.data.data;break;case 3:}switch(a.data.container_type){case"All":o.save("activities",t.activities),t.has_more=a.data.count+10*a.data.page0?u.alertService_2.showMessage("提示","您确定要删除该班级吗?",function(){e.post(l.apiUrl+"courses/"+t.id+"/del",{token:a.token()}).then(function(e){0!=e.data.status?u.alertService_1.showMessage("出错了",e.data.message):u.alertService_1.showMessage("提示","删除班级成功",function(){u.syllabus.courses.splice(s,1)}),console.log(e.data.data)})}):u.syllabus.courses.splice(s,1)},u.newClass=function(s,t){if(s.$setSubmitted(),console.log(t),!s.$valid)return void console.log(s.$error);var r=[],c=[];for(var d in u.syllabus.courses){var b=u.syllabus.courses[d];b.id?b.tmpname!=b.name&&c.push({id:b.id,name:b.tmpname}):r.push(b.tmpname)}e.post(l.apiUrl+"syllabuses/"+i+"/edit",{token:a.token(),id:i,title:u.syllabus.tmptitle,add_courses:r,modify_courses:c}).then(function(s){0!=s.data.status?u.alertService_1.showMessage("出错了",s.data.message):u.alertService_1.showMessage("提示","保存课程成功",function(){n.save("syllabuses",[]),o.path("/class_list")}),console.log(s.data.data)})},u.fadeText=function(){s.change=!0}}]); +//edit_class.js +app.controller("EditClassController",["$scope","$http","auth","config","alertService","$location","$routeParams","rms",function(s,e,a,l,t,o,r,n){var u=s;u.syllabus=n.get("current_edit_syllobus");var i=r.id;if(u.syllabus||e.get(l.apiUrl+"syllabuses/"+i+"?token="+a.token()).then(function(s){if(console.log(s.data),u.syllabus=s.data.data,u.syllabus){for(var e in u.syllabus.courses){var a=u.syllabus.courses[e];a.tmpname=a.name}u.syllabus.tmptitle=u.syllabus.title}}),console.log(u.syllabus),u.syllabus){for(var c in u.syllabus.courses){var d=u.syllabus.courses[c];d.tmpname=d.name}u.syllabus.tmptitle=u.syllabus.title}u.alertService_1=t.create(),u.alertService_2=t.create(),u.addClass=function(){u.syllabus.courses.push({can_setting:!0})},u.deleteClass=function(s){var t=u.syllabus.courses[s];t.id>0?u.alertService_2.showMessage("\u63d0\u793a","\u60a8\u786e\u5b9a\u8981\u5220\u9664\u8be5\u73ed\u7ea7\u5417\uff1f",function(){e.post(l.apiUrl+"courses/"+t.id+"/del",{token:a.token()}).then(function(e){0!=e.data.status?u.alertService_1.showMessage("\u51fa\u9519\u4e86",e.data.message):u.alertService_1.showMessage("\u63d0\u793a","\u5220\u9664\u73ed\u7ea7\u6210\u529f",function(){u.syllabus.courses.splice(s,1)}),console.log(e.data.data)})}):u.syllabus.courses.splice(s,1)},u.newClass=function(s,t){if(s.$setSubmitted(),console.log(t),!s.$valid)return void console.log(s.$error);var r=[],c=[];for(var d in u.syllabus.courses){var b=u.syllabus.courses[d];b.id?b.tmpname!=b.name&&c.push({id:b.id,name:b.tmpname}):r.push(b.tmpname)}e.post(l.apiUrl+"syllabuses/"+i+"/edit",{token:a.token(),id:i,title:u.syllabus.tmptitle,add_courses:r,modify_courses:c}).then(function(s){0!=s.data.status?u.alertService_1.showMessage("\u51fa\u9519\u4e86",s.data.message):u.alertService_1.showMessage("\u63d0\u793a","\u4fdd\u5b58\u8bfe\u7a0b\u6210\u529f",function(){n.save("syllabuses",[]),o.path("/class_list")}),console.log(s.data.data)})},u.fadeText=function(){s.change=!0}}]); +//homework.js app.controller("HomeworkController",["$scope","$http","$routeParams","auth","common",function(o,e,l,n,r){r.init({id:l.id,scope:o,type:"whomeworks",replyType:"HomeworkCommon",loadCallback:function(e){console.log(e),o.homework=e.data},replyCallback:function(){}})}]); -app.controller("InviteCodeController",["$scope","$http","$routeParams","config","auth",function(t,e,i,n,o){var a=t;a.course={};var c=i.id;e.get(n.apiUrl+"courses/"+c+"?token="+o.token()).then(function(t){console.log(t.data),a.course=t.data.data}),a.share=function(){window.WeixinJSBridge.invoke("sendAppMessage",{appid:"wxf694495398c7d470",type:"link",data_url:"",img_url:"http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640",img_height:370,img_width:550,link:"http://view.inews.qq.com/a/WXN2013101101385701",desc:"desc",title:"title"},function(t){})}}]); +//invite_code.js +app.controller("InviteCodeController",["$scope","$http","$routeParams","config","auth",function(t,e,i,n,o){var a=t;a.course={};var c=i.id;e.get(n.apiUrl+"courses/"+c+"?token="+o.token()).then(function(t){console.log(t.data),a.course=t.data.data}),a.share=function(){window.WeixinJSBridge.invoke("sendAppMessage",{appid:"wxf694495398c7d470",type:"link",data_url:"",img_url:"http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640",img_height:370,img_width:550,link:"http://view.inews.qq.com/a/WXN2013101101385701",desc:"desc",title:"title"},function(){})}}]); +//issue.js app.controller("IssueController",["$scope","$http","$routeParams","auth","common",function(o,e,l,s,t){t.init({id:l.id,scope:o,type:"issues",replyType:"Issue",loadCallback:function(e){console.log(e),o.issue=e.data},replyCallback:function(){}})}]); +//journals.js app.controller("JournalsController",["$scope","$http","$routeParams","auth","common",function(o,a,e,l,n){n.init({id:e.id,scope:o,type:"journal_for_messages",replyType:"JournalsForMessage",loadCallback:function(a){o.message=a.data},replyCallback:function(){}})}]); -app.controller("LoginController",["$scope","$http","$location","$routeParams","alertService","config","auth","session",function(e,o,t,a,i,n,s,l){s.get_bind().then(function(){t.path("/activities")}),a.code&&l.save("code",a.code);var r=e;r.loginFailed=!1,r.alertService=i.create(),r.findPwdDialog=i.create(),r.login=function(a,i){return a.$setSubmitted(),console.log(i),a.$valid?(console.log(apiUrl+"auth"),void o.post(n.apiUrl+"users/wxbind",{login:i.login,password:i.password}).then(function(o){console.log(o.data),r.loginFailed=0!=o.data.status,e.loginFailed?r.alertService.showMessage("出错了",o.data.message):r.alertService.showMessage("提示",o.data.message,function(){t.path("/activities")})})["catch"](function(e){r.alertService.showMessage("出错了",e)})):void console.log(a.$error)},r.showBox=function(){r.findPwdDialog.showMessage("提示","请访问www.trustie.net获取密码,谢谢!")},r.goReg=function(){t.path("/reg")}}]); -app.controller("MyResourceController",["$scope","$http","auth","config","$location","rms",function(e,a,o,s,r,t){var c=e;c.menus=["课件","作业","测验"],c.resources=[],c.homeworks=[],c.exercise=[],c.resources_tag=!1,c.homeworks_tag=!1,c.exercises_tag=!1,c.page=t.get("page")||0,c.resources=t.get("resources")||[],c.has_more=t.get("has_more"),c.homework_page=t.get("homework_page")||0,c.homeworks=t.get("homeworks")||[],c.homework_has_more=t.get("homework_has_more"),c.exercise_page=t.get("exercise_page")||0,c.exercise=t.get("exercise")||[],c.exercise_has_more=t.get("exercise_has_more"),c.searchText="",c.sendFile=function(e){r.path("/send_class_list").search({id:e.id})},c.loadResourceData=function(e,s){1==e?(c.page=s,a({method:"POST",url:apiUrl+"resources",data:{token:o.token(),page:s}}).then(function(e){c.resources_tag=!0,e.data.page>0?c.resources=c.resources.concat(e.data.data):c.resources=e.data.data,t.save("resources",c.resources),c.has_more=e.data.count+10*e.data.page0?c.homeworks=c.homeworks.concat(e.data.data):c.homeworks=e.data.data,t.save("homeworks",c.homeworks),c.homework_has_more=e.data.count+10*e.data.page0?c.exercise=c.exercise.concat(e.data.data):c.exercise=e.data.data,t.save("exercise",c.exercise),c.exercise_has_more=e.data.count+10*e.data.page0?c.resources.concat(e.data.data):e.data.data,t.save("resources",c.resources),c.has_more=e.data.count+10*e.data.page0?c.homeworks.concat(e.data.data):e.data.data,t.save("homeworks",c.homeworks),c.homework_has_more=e.data.count+10*e.data.page0?c.exercise.concat(e.data.data):e.data.data,t.save("exercise",c.exercise),c.exercise_has_more=e.data.count+10*e.data.page Date: Mon, 18 Jul 2016 11:08:02 +0800 Subject: [PATCH 03/52] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=EF=BC=9A=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=A2=9E=E5=8A=A0=E5=8F=91=E9=80=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 9 +- app/api/mobile/apis/resources.rb | 16 ++- app/services/resources_service.rb | 119 ++++++++++++++++++ public/assets/wechat/class.html | 2 +- public/assets/wechat/myresource.html | 6 +- .../javascripts/wechat/controllers/class.js | 20 +-- .../wechat/controllers/myresource.js | 11 +- .../wechat/controllers/send_class_list.js | 5 +- 8 files changed, 172 insertions(+), 16 deletions(-) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index caabad198..aa1e573ed 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -200,8 +200,13 @@ module Mobile # course = Course.find(params[:id]) cs = CoursesService.new course = cs.show_course(params,current_user) - present :data, course, with: Mobile::Entities::Course,user: current_user - { status: 0} + + if course[:course][:is_delete] == 1 + {status:-1, message: '该班级不存在或已被删除啦' } + else + present :data, course, with: Mobile::Entities::Course,user: current_user + present :status, 0 + end end end diff --git a/app/api/mobile/apis/resources.rb b/app/api/mobile/apis/resources.rb index d5823d5b4..ebfef7f2d 100644 --- a/app/api/mobile/apis/resources.rb +++ b/app/api/mobile/apis/resources.rb @@ -85,12 +85,26 @@ module Mobile requires :token, type: String requires :course_ids, type: Array[Integer] requires :send_id, type: Integer + requires :send_type, type: Integer end post 'send' do authenticate! rs = ResourcesService.new - ori, flag, save_message = rs.send_resource_to_course(current_user,params) + + ori = nil + flag = false + save_message = nil + + case params[:send_type] + when 1 + ori, flag, save_message = rs.send_resource_to_course(current_user,params) + when 2 + ori, flag, save_message = rs.send_homework_to_course(current_user,params) + when 3 + ori, flag, save_message = rs.send_exercise_to_course(current_user,params) + end + if flag present :status, 0 else diff --git a/app/services/resources_service.rb b/app/services/resources_service.rb index bc97437e4..b56da8ad3 100644 --- a/app/services/resources_service.rb +++ b/app/services/resources_service.rb @@ -49,6 +49,125 @@ class ResourcesService [@ori, @flag, @save_message] end + def send_homework_to_course user,params + homework = HomeworkCommon.find params[:send_id].to_i + @ori = homework + course_ids = params[:course_ids] + @flag = false + unless course_ids.nil? + course_ids.each do |course_id| + course = Course.find course_id.to_i + new_homework = HomeworkCommon.new + new_homework.name = homework.name + new_homework.user_id = user.id + new_homework.description = homework.description + new_homework.homework_type = homework.homework_type + new_homework.late_penalty = homework.late_penalty + new_homework.course_id = course.id + new_homework.teacher_priority = homework.teacher_priority + new_homework.anonymous_comment = homework.anonymous_comment + new_homework.quotes = 0 + new_homework.is_open = homework.is_open + homework.attachments.each do |attachment| + att = attachment.copy + att.container_id = nil + att.container_type = nil + att.copy_from = attachment.id + att.save + new_homework.attachments << att + end + homework_detail_manual = homework.homework_detail_manual + homework_detail_programing = homework.homework_detail_programing + homework_detail_group = homework.homework_detail_group + if homework_detail_manual + new_homework.homework_detail_manual = HomeworkDetailManual.new + new_homework_detail_manual = new_homework.homework_detail_manual + new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion + new_homework_detail_manual.comment_status = 0 + new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num + new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty + end + if homework_detail_programing + new_homework.homework_detail_programing = HomeworkDetailPrograming.new + new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion + new_homework.homework_detail_programing.language = homework_detail_programing.language + homework.homework_tests.each_with_index do |homework_test| + new_homework.homework_tests << HomeworkTest.new( + input: homework_test.input, + output: homework_test.output + ) + end + end + + if homework_detail_group + new_homework.homework_detail_group = HomeworkDetailGroup.new + new_homework.homework_detail_group.min_num = homework_detail_group.min_num + new_homework.homework_detail_group.max_num = homework_detail_group.max_num + new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project + end + if new_homework.save + new_homework_detail_manual.save if new_homework_detail_manual + new_homework.homework_detail_programing.save if new_homework.homework_detail_programing + new_homework.homework_detail_group.save if new_homework.homework_detail_group + @flag = true + else + @flag = false + @save_message = new_homework.errors.full_messages + break + end + homework.update_column(:quotes, homework.quotes+1) + end + end + [@ori, @flag, @save_message] + end + + def send_exercise_to_course user,params + # send_id = params[:send_id] + # @ori = Attachment.find_by_id(send_id) + # course_ids = params[:course_ids] + # @flag = false + # unless course_ids.nil? + # course_ids.each do |id| + # next if @ori.blank? + # @exist = false + # Course.find(id).attachments.each do |att| #如果课程中包含该资源 + # if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from + # att.created_on = Time.now + # att.save + # @exist = true + # @flag = true + # break + # end + # end + # next if @exist + # attach_copied_obj = @ori.copy + # attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联 + # attach_copied_obj.container = Course.find(id) + # attach_copied_obj.created_on = Time.now + # attach_copied_obj.author_id = user.id + # attach_copied_obj.is_public = 0 + # attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from + # if attach_copied_obj.attachtype == nil + # attach_copied_obj.attachtype = 4 + # end + # if attach_copied_obj.save + # # 更新引用次数 + # quotes = @ori.quotes.to_i + 1 + # @ori.update_attribute(:quotes, quotes) unless @ori.nil? + # @ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + # @flag = true + # else + # @flag = false + # @save_message = attach_copied_obj.errors.full_messages + # break + # end + # + # end + # end + + [@ori, @flag, @save_message] + end + # 我的资源-课件 已发布的 def all_course_attachments user diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index c328ed226..2f9af6554 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -56,5 +56,5 @@ - + diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index c89f39684..28fc69cc3 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -12,7 +12,7 @@
- {{r.filename}}发送
+ {{r.filename}}发送
大小:{{r.attafile_size}}
@@ -22,7 +22,7 @@ 请登录Trustie网站,在PC浏览器中上传课件。

-
{{r.homework_name}}发送
+
{{r.homework_name}}发送
@@ -32,7 +32,7 @@ 请登录Trustie网站,在PC浏览器中创建作业。

-
{{r.exercise_name}}发送
+
{{r.exercise_name}}发送
diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index 87703b681..cf2a3ee88 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -1,4 +1,4 @@ -app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){ +app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService', function($scope, config, $http, auth, $location, $routeParams,alertService){ var vm = $scope; var courseid = $routeParams.id; @@ -97,15 +97,14 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location } } - - - vm.course = {}; vm.students = []; vm.teachers = []; vm.resources = []; vm.homeworks = []; vm.exercises = []; + + vm.alertService = alertService.create(); vm.invite = function(){ $location.path("/invite_code").search({id: courseid}); @@ -118,9 +117,16 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( function(response) { console.log(response.data); - vm.course = response.data.data; - resetMenu(vm.course.current_user_is_teacher); - vm.tab(1); + + if (response.data.status == 0){ + vm.course = response.data.data; + resetMenu(vm.course.current_user_is_teacher); + vm.tab(1); + } + else{ + vm.alertService.showMessage('提示', response.data.message); + } + } ); diff --git a/public/javascripts/wechat/controllers/myresource.js b/public/javascripts/wechat/controllers/myresource.js index fb564cde8..15428bb34 100644 --- a/public/javascripts/wechat/controllers/myresource.js +++ b/public/javascripts/wechat/controllers/myresource.js @@ -10,21 +10,30 @@ app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', '$l vm.homeworks_tag = false; vm.exercises_tag = false; + //课件 vm.page = rms.get('page') || 0; vm.resources = rms.get("resources") || []; vm.has_more = rms.get("has_more"); + //作业 vm.homework_page = rms.get('homework_page') || 0; vm.homeworks = rms.get("homeworks") || []; vm.homework_has_more = rms.get("homework_has_more"); + //测验 vm.exercise_page = rms.get('exercise_page') || 0; vm.exercise = rms.get("exercise") || []; vm.exercise_has_more = rms.get("exercise_has_more"); vm.searchText = ""; - vm.sendFile = function(r){ + //发送类别 1课件 2作业 3测验 + vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1; + + vm.sendFile = function(r,index){ + vm.myresource_sendIndex = index; + rms.save('myresource_sendIndex',index); + $location.path("/send_class_list").search({id: r.id}); } diff --git a/public/javascripts/wechat/controllers/send_class_list.js b/public/javascripts/wechat/controllers/send_class_list.js index 16875af9f..c80943e39 100644 --- a/public/javascripts/wechat/controllers/send_class_list.js +++ b/public/javascripts/wechat/controllers/send_class_list.js @@ -2,6 +2,9 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co var vm = $scope; var send_id = $routeParams.id; + //发送类别 1课件 2作业 3测验 + vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1; + vm.alertService = alertService.create(); vm.syllabuses = []; @@ -39,7 +42,7 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co } $http.post(config.apiUrl + "resources/send", { - token: auth.token(), course_ids: course_ids, send_id: send_id + token: auth.token(), course_ids: course_ids, send_id: send_id,send_type:vm.myresource_sendIndex }).then(function(response){ console.log(response.data); if(response.data.status == 0){ From ff13d2e572045bd6af626ae58f699e96e7462de2 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 18 Jul 2016 14:24:59 +0800 Subject: [PATCH 04/52] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8F=91=E9=80=81=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=9A=84=E6=9D=83=E9=99=90=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 6 +++--- app/api/mobile/entities/attachment.rb | 8 ++++++++ app/api/mobile/entities/exercise.rb | 8 ++++++++ app/api/mobile/entities/homework.rb | 7 +++++++ app/controllers/wechats_controller.rb | 15 ++++++++------ config/menu.yml.test | 20 +++++++++++++------ public/assets/wechat/class.html | 6 +++--- public/assets/wechat/myresource.html | 6 +++--- .../javascripts/wechat/controllers/class.js | 9 +++++++-- .../wechat/controllers/send_class_list.js | 2 +- 10 files changed, 63 insertions(+), 24 deletions(-) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index aa1e573ed..1c6fd7008 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -217,7 +217,7 @@ module Mobile get "homeworks/:id" do cs = CoursesService.new homeworks = cs.homework_list params,current_user - present :data, homeworks, with: Mobile::Entities::Homework + present :data, homeworks, with: Mobile::Entities::Homework,user: current_user present :status, 0 end @@ -264,7 +264,7 @@ module Mobile post ":course_id/attachments" do cs = CoursesService.new count = cs.course_attachments params - present :data, count, with: Mobile::Entities::Attachment + present :data, count, with: Mobile::Entities::Attachment,user: current_user present :status, 0 end @@ -398,7 +398,7 @@ module Mobile course = Course.find(params[:course_id]) exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") - present :data,exercises,with:Mobile::Entities::Exercise + present :data,exercises,with:Mobile::Entities::Exercise,user: current_user present :status,0 end diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 49cb6bd2b..028ad633d 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -3,6 +3,7 @@ module Mobile class Attachment < Grape::Entity include Redmine::I18n include ActionView::Helpers::NumberHelper + include ApplicationHelper def self.attachment_expose(field) expose field do |f,opt| if f.is_a?(Hash) && f.key?(field) @@ -22,6 +23,7 @@ module Mobile (number_to_human_size(f.filesize)).gsub("ytes", "").to_s when :coursename f.course.nil? ? "" : f.course.name + end end end @@ -36,6 +38,12 @@ module Mobile attachment_expose :file_dir attachment_expose :attafile_size attachment_expose :coursename #所属班级名 + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/exercise.rb b/app/api/mobile/entities/exercise.rb index 05066f8a4..ce6a2fb39 100644 --- a/app/api/mobile/entities/exercise.rb +++ b/app/api/mobile/entities/exercise.rb @@ -27,6 +27,14 @@ module Mobile expose :exercise_name expose :exercise_description exercise_expose :coursename #所属班级名 + + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end + end end end diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index 3f1631c96..cea15ece9 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -98,6 +98,13 @@ module Mobile homework_expose :coursename #所属班级名 + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end + end end end \ No newline at end of file diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ea305d967..c72e04e14 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -78,12 +78,7 @@ class WechatsController < ActionController::Base end # When user view URL in the menu button on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| - uw = user_binded?(request[:FromUserName]) - unless uw - sendBind(request) - else - request.reply.text "#{request[:FromUserName]} view #{view}" - end + request.reply.text "#{request[:FromUserName]} view #{view}" end # When user sent the imsage @@ -147,6 +142,14 @@ class WechatsController < ActionController::Base default_msg(request) end + on :click, with: 'PROJECT' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end + + on :click, with: 'JOIN_PROJECT' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end + on :click, with: 'JOIN_CLASS' do |request, key| uw = user_binded?(request[:FromUserName]) unless uw diff --git a/config/menu.yml.test b/config/menu.yml.test index a43d72816..521ff290a 100644 --- a/config/menu.yml.test +++ b/config/menu.yml.test @@ -2,18 +2,22 @@ button: - type: "view" name: "我的动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" - - name: "我的课程" + name: "我的群组" sub_button: - type: "view" - name: "课程" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + name: "我的课程" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + - + type: "click" + name: "我的项目" + key: "PROJECT" - type: "view" - name: "资源" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" + name: "我的宝库" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" - name: "更多" @@ -22,6 +26,10 @@ button: type: "click" name: "加入班级" key: "JOIN_CLASS" + - + type: "click" + name: "加入项目" + key: "JOIN_PROJECT" - type: "click" name: "反馈" diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 2f9af6554..01628c2f4 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -23,7 +23,7 @@
-
{{r.filename}}发送
+
{{r.filename}}发送

暂无课件,
请登录Trustie网站,在PC浏览器中上传课件。

@@ -42,14 +42,14 @@
-
{{r.homework_name}}发送
+
{{r.homework_name}}发送

暂无作业,
请登录Trustie网站,在PC浏览器中上传作业。

-
{{r.exercise_name}}发送
+
{{r.exercise_name}}发送

暂无小测验,
请登录Trustie网站,在PC浏览器中上传小测验。

diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index 28fc69cc3..c06c57238 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -12,7 +12,7 @@
- {{r.filename}}发送
+ {{r.filename}}发送
大小:{{r.attafile_size}}
@@ -22,7 +22,7 @@ 请登录Trustie网站,在PC浏览器中上传课件。

-
{{r.homework_name}}发送
+
{{r.homework_name}}发送
@@ -32,7 +32,7 @@ 请登录Trustie网站,在PC浏览器中创建作业。

-
{{r.exercise_name}}发送
+
{{r.exercise_name}}发送
diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index cf2a3ee88..75e1709cc 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -1,4 +1,4 @@ -app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService', function($scope, config, $http, auth, $location, $routeParams,alertService){ +app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms', function($scope, config, $http, auth, $location, $routeParams,alertService,rms){ var vm = $scope; var courseid = $routeParams.id; @@ -104,13 +104,18 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.homeworks = []; vm.exercises = []; + //发送类别 1课件 2作业 3测验 + vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1; + vm.alertService = alertService.create(); vm.invite = function(){ $location.path("/invite_code").search({id: courseid}); }; - vm.sendFile = function(r){ + vm.sendFile = function(r,index){ + vm.myresource_sendIndex = index; + rms.save('myresource_sendIndex',index); $location.path("/send_class_list").search({id: r.id}); } diff --git a/public/javascripts/wechat/controllers/send_class_list.js b/public/javascripts/wechat/controllers/send_class_list.js index c80943e39..1eabfa94c 100644 --- a/public/javascripts/wechat/controllers/send_class_list.js +++ b/public/javascripts/wechat/controllers/send_class_list.js @@ -46,7 +46,7 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co }).then(function(response){ console.log(response.data); if(response.data.status == 0){ - vm.alertService.showMessage('提示', '发送成功', function () { + vm.alertService.showMessage('发送成功', '题目已发送到目标班级的作业列表,但需要您访问Trustie网站设置发布和截止时间,以激活相应作业,谢谢!', function () { window.history.back(); }); } else { From fea8d56d8d6087eed9e662e10fa02d9348731d45 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 18 Jul 2016 14:28:45 +0800 Subject: [PATCH 05/52] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=89=88=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/wechat.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/wechat.yml b/config/wechat.yml index f09cca3d5..8b2caffc8 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -8,12 +8,12 @@ default: &default #secret: "743e038392f1d89540e95f8f7645849a" #production - appid: "wx8e1ab05163a28e37" - secret: "beb4d3bc4b32b3557811680835357841" +# appid: "wx8e1ab05163a28e37" +# secret: "beb4d3bc4b32b3557811680835357841" #test -# appid: "wxc09454f171153c2d" -# secret: "dff5b606e34dcafe24163ec82c2715f8" + appid: "wxc09454f171153c2d" + secret: "dff5b606e34dcafe24163ec82c2715f8" token: "123456" access_token: "1234567" From b2f9839d1347dbacc0493b607964396d683f53a3 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 18 Jul 2016 14:43:54 +0800 Subject: [PATCH 06/52] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=EF=BC=9A=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=89=88=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/config/menu.yml b/config/menu.yml index 1817ab44d..0acb58b96 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,18 +2,22 @@ button: - type: "view" name: "我的动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" - - name: "我的课程" + name: "我的群组" sub_button: - - type: "click" - name: "课程" - key: "DEV" + type: "view" + name: "我的课程" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" - type: "click" - name: "资源" - key: "DEV" + name: "我的项目" + key: "PROJECT" + - + type: "view" + name: "我的宝库" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" - name: "更多" @@ -22,6 +26,10 @@ button: type: "click" name: "加入班级" key: "JOIN_CLASS" + - + type: "click" + name: "加入项目" + key: "JOIN_PROJECT" - type: "click" name: "反馈" From bc0d8cd299fe8e9772d045ea25eb0d26cee1b4f8 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 10:25:45 +0800 Subject: [PATCH 07/52] =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E5=AD=97=E4=BD=93=E5=8F=98=E7=81=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/edit_class.html | 4 ++-- public/javascripts/wechat/controllers/edit_class.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/public/assets/wechat/edit_class.html b/public/assets/wechat/edit_class.html index 5953e046b..d6bc7e03c 100644 --- a/public/assets/wechat/edit_class.html +++ b/public/assets/wechat/edit_class.html @@ -3,9 +3,9 @@
管理课程
-
课程
+
课程
-
班级删除
+
班级删除
完成
diff --git a/public/javascripts/wechat/controllers/edit_class.js b/public/javascripts/wechat/controllers/edit_class.js index b5ee1a025..5f377e594 100644 --- a/public/javascripts/wechat/controllers/edit_class.js +++ b/public/javascripts/wechat/controllers/edit_class.js @@ -107,8 +107,4 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale } - vm.fadeText = function () { - $scope.change = true; - } - }] ); \ No newline at end of file From bc1b4c1b85efeb091ab0ec12b8af31ea84fed1d3 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 19 Jul 2016 10:50:36 +0800 Subject: [PATCH 08/52] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E7=A0=81=E5=BC=B9=E6=A1=86=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=88=91?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E6=80=81=E5=9B=9E=E5=A4=8D=E6=95=B0=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 2 +- app/api/mobile/entities/activity.rb | 20 +++++---- app/api/mobile/entities/blog_comment.rb | 4 +- app/api/mobile/entities/issue.rb | 4 +- app/api/mobile/entities/jours.rb | 4 +- app/api/mobile/entities/message.rb | 3 ++ app/api/mobile/entities/news.rb | 3 ++ app/services/courses_service.rb | 4 +- public/assets/wechat/class_list.html | 3 +- public/assets/wechat/myresource.html | 1 + public/assets/wechat/templates/alert3.html | 15 +++++++ .../wechat/controllers/class_list.js | 43 ++++++++++--------- public/javascripts/wechat/directives/alert.js | 24 +++++++++++ public/javascripts/wechat/others/factory.js | 3 ++ 14 files changed, 97 insertions(+), 36 deletions(-) create mode 100644 public/assets/wechat/templates/alert3.html diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 1c6fd7008..60e00280e 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -397,7 +397,7 @@ module Mobile authenticate! course = Course.find(params[:course_id]) - exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") + exercises = course.exercises.where("exercise_status <> 1").reorder("created_at desc") present :data,exercises,with:Mobile::Entities::Exercise,user: current_user present :status,0 end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 9e2a39a5a..bdeff7ae9 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -20,15 +20,17 @@ module Mobile ac.act unless ac.nil? || ac.act.nil? end when :reply_count - if ac.act_type == "HomeworkCommon" - ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count - elsif ac.act_type == "News" - ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count - elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" - ac.nil? || ac.act.nil? ? 0 : ac.act.children.count - elsif ac.act_type == "Issue" - ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count - end + # if ac.act_type == "HomeworkCommon" + # ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count + # elsif ac.act_type == "News" + # ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count + # elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" + # ac.nil? || ac.act.nil? ? 0 : ac.act.children.count + # elsif ac.act_type == "Issue" + # ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count + # end + all_comments = [] + ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count when :subject if ac.act_type == "HomeworkCommon" ac.act.name unless ac.nil? || ac.act.nil? diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index 67904d11e..a61864900 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -25,7 +25,9 @@ module Mobile when :act_id u.id when :comment_count - u.children.count + # u.children.count + all_comments = [] + get_all_children(all_comments, u).count end end end diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index ef3d09450..b99ea03a5 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -23,7 +23,9 @@ module Mobile when :issue_status IssueStatus.find(issue.status_id).name when :journals_count - issue.journals.where("notes is not null and notes != ''").count + # issue.journals.where("notes is not null and notes != ''").count + all_comments = [] + get_all_children(all_comments, f).count when :project_name issue.project.name when :praise_count diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 15e22174c..f98d7a9ed 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -18,7 +18,9 @@ module Mobile when :lasted_comment time_from_now f.created_on when :reply_count - f.children.count + # f.children.count + all_comments = [] + get_all_children(all_comments, f).count when :praise_count get_activity_praise_num(f) when :act_type diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index 051c92886..d58192378 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -30,6 +30,9 @@ module Mobile 'Message' when :act_id u.id + when :replies_count + all_comments = [] + get_all_children(all_comments, u).count end end end diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index 4f973d82e..ff1452b1c 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -24,6 +24,9 @@ module Mobile 'News' when :act_id f.id + when :comments_count + all_comments = [] + get_all_children(all_comments, f).count end end elsif f.is_a?(Hash) && !f.key?(field) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 39c77de4b..091e2749e 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -392,7 +392,7 @@ class CoursesService def homework_list params,current_user course = Course.find(params[:id]) if course.is_public != 0 || current_user.member_of_course?(course) - bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).order('created_at DESC') + bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).reorder('created_at DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] bids.each do |bid| @@ -495,7 +495,7 @@ class CoursesService def course_attachments params result = [] course = Course.find(params[:course_id]) - attachments = course.attachments.where("is_publish = 1").order("created_on desc") + attachments = course.attachments.where("is_publish = 1").reorder("created_on desc") if !params[:name].nil? && params[:name] != "" attachments.each do |atta| result << atta if atta.filename.include?(params[:name]) diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html index a3c709cb5..d0074f343 100644 --- a/public/assets/wechat/class_list.html +++ b/public/assets/wechat/class_list.html @@ -36,5 +36,6 @@ 我的资源
- + +
\ No newline at end of file diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index c06c57238..90fb13892 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -20,6 +20,7 @@

暂无课件,
请登录Trustie网站,在PC浏览器中上传课件。

+
{{r.homework_name}}发送
diff --git a/public/assets/wechat/templates/alert3.html b/public/assets/wechat/templates/alert3.html new file mode 100644 index 000000000..11e2c6d28 --- /dev/null +++ b/public/assets/wechat/templates/alert3.html @@ -0,0 +1,15 @@ +
+
+
+

{{message}}

+
+ +
+ 取消 +
+
+
+ 确定 +
+
+
\ No newline at end of file diff --git a/public/javascripts/wechat/controllers/class_list.js b/public/javascripts/wechat/controllers/class_list.js index b3f8a6ea3..9e0087135 100644 --- a/public/javascripts/wechat/controllers/class_list.js +++ b/public/javascripts/wechat/controllers/class_list.js @@ -8,7 +8,8 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo var vm = $scope; vm.syllabuses = rms.get('syllabuses') || []; - vm.alertService = alertService.create(); + vm.alertService_1 = alertService.create(); + vm.alertService_3 = alertService.create(); var loadClassList = function () { $http.get(config.apiUrl + "syllabuses?token=" + auth.token()).then( @@ -36,7 +37,7 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo function (response) { console.log(response.data); if (response.data.auth == 0) { - vm.alertService.showMessage('提示', '非教师身份不能创建课程哦~'); + vm.alertService_1.showMessage('提示', '非教师身份不能创建课程哦~'); } else{ $location.path("/new_class"); @@ -50,26 +51,28 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo } vm.joinClass = function () { - var code = window.prompt("请输入5位班级邀请码(不区分大小写)"); - if (code && code.length == 5) { - $http.post(config.apiUrl + "courses/join", { - token: auth.token(), - invite_code: code - }).then(function (response) { - console.log(response.data); - if (response.data.status != 0) { - vm.alertService.showMessage('错误', response.data.message); - } else { - vm.alertService.showMessage('提示', '加入课程成功'); - loadClassList(); + vm.alertService_3.showMessage('提示', '请输入5位班级邀请码(不区分大小写)', function(){ + if (vm.alertService_3.invite && vm.alertService_3.invite.length == 5) { + $http.post(config.apiUrl + "courses/join", { + token: auth.token(), + invite_code: vm.alertService_3.invite + }).then(function (response) { + console.log(response.data); + if (response.data.status != 0) { + vm.alertService_1.showMessage('错误', response.data.message); + } else { + vm.alertService_1.showMessage('提示', '加入课程成功'); + vm.alertService_3.invite = ""; + loadClassList(); + } + }); + } else { + if(vm.alertService_3.invite){ + vm.alertService_1.showMessage('错误', '邀请码格式不正确'); } - }); - } else { - if(code){ - vm.alertService.showMessage('错误', '邀请码格式不正确'); - } - } + } + }); }; vm.onSetting = function (syllabus) { diff --git a/public/javascripts/wechat/directives/alert.js b/public/javascripts/wechat/directives/alert.js index 4b703811c..e9401de34 100644 --- a/public/javascripts/wechat/directives/alert.js +++ b/public/javascripts/wechat/directives/alert.js @@ -40,3 +40,27 @@ app.directive('myAlert2', ['config', function(config){ } } }]); + +app.directive('myAlert3', ['config', function(config){ + return { + templateUrl: config.rootPath+ 'templates/alert3.html', + scope: { + title: "=", + message: "=", + visible: "=", + cb: "=", + invite: "=" + }, + link: function(scope){ + scope.dismiss = function(){ + scope.visible = false; + }; + scope.confirm = function(){ + scope.visible = false; + if(typeof scope.cb === 'function'){ + scope.cb(); + } + } + } + } +}]); diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 6c7709df3..2b0d4f994 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -4,6 +4,7 @@ app.factory('alertService', function(){ this.message = null; this.visible = null; this.cb = null; + this.invite = ""; } Alert.prototype.showMessage = function(title, msg, cb){ @@ -11,12 +12,14 @@ app.factory('alertService', function(){ this.title = title; this.visible = true; this.cb = cb; + this.invite = ""; } Alert.prototype.dismiss = function(){ this.message = null; this.title = null; this.visible = false; + this.invite = ""; if(this.cb) {this.cb();} } From ea88c92d31a1e815042d1f82d5ab694a437d2625 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 19 Jul 2016 10:54:04 +0800 Subject: [PATCH 09/52] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 9b4bdb5d6..5a0345207 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -1,25 +1,25 @@ #coding=utf-8 module Mobile - require_relative 'middleware/error_handler' - require_relative 'apis/auth' - require_relative 'apis/users' - require_relative 'apis/courses' - require_relative 'apis/watches' - require_relative 'apis/upgrade' - require_relative 'apis/homeworks' - require_relative 'apis/comments' - require_relative 'apis/issues' - require_relative 'apis/activities' - require_relative 'apis/whomeworks' - require_relative 'apis/newss' - require_relative 'apis/journal_for_messages' - require_relative 'apis/messages' - require_relative 'apis/blog_comments' - require_relative 'apis/new_comment' - require_relative 'apis/praise' - require_relative 'apis/resources' - require_relative 'apis/syllabuses' + # require_relative 'middleware/error_handler' + # require_relative 'apis/auth' + # require_relative 'apis/users' + # require_relative 'apis/courses' + # require_relative 'apis/watches' + # require_relative 'apis/upgrade' + # require_relative 'apis/homeworks' + # require_relative 'apis/comments' + # require_relative 'apis/issues' + # require_relative 'apis/activities' + # require_relative 'apis/whomeworks' + # require_relative 'apis/newss' + # require_relative 'apis/journal_for_messages' + # require_relative 'apis/messages' + # require_relative 'apis/blog_comments' + # require_relative 'apis/new_comment' + # require_relative 'apis/praise' + # require_relative 'apis/resources' + # require_relative 'apis/syllabuses' class API < Grape::API version 'v1', using: :path From 27965bee01f71556b32854ed285b8d9093b805c2 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 11:17:46 +0800 Subject: [PATCH 10/52] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E6=A0=B7=E5=BC=8F=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/templates/alert3.html | 4 ++-- public/stylesheets/weui/weixin.css | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/templates/alert3.html b/public/assets/wechat/templates/alert3.html index 11e2c6d28..c7516450c 100644 --- a/public/assets/wechat/templates/alert3.html +++ b/public/assets/wechat/templates/alert3.html @@ -5,11 +5,11 @@
- 取消 + 取消
- 确定 + 确定
\ No newline at end of file diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 7082955e3..a81541e39 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -55,6 +55,8 @@ blockquote {border:1px solid #d4d4d4; padding: 0.6em; margin: 5px 0.4em 5px 1.4e a {color:#707070;} a.c-grey {color:#707070;} a.c-grey2 {color:#9a9a9a;} +a.c-grey3 {color:#353535;} +a.c-green {color:#0bb20c;} a:link,a:visited{text-decoration:none;} a:hover,a:active{cursor:pointer;} a.link-blue {color:#269ac9;} @@ -154,7 +156,7 @@ a.underline {text-decoration:underline;} /*20150612加入班级样式*/ .add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; margin:0 auto; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%);} -.add-class-tip {padding-top:20px; padding-bottom:20px;} +.add-class-tip {padding-top:1.2em; padding-bottom:.5em; font-weight:400;} .class-number-input {width:80%; max-width:240px; height:28px; border:1px solid #ccc; padding-left:5px; margin:0 auto; display:block;} .cancel-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} .submit-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} From 2af1a5ffb9fd111f8fc299facf688edeea54157a Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 15:07:11 +0800 Subject: [PATCH 11/52] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E5=92=8C=E7=AE=A1=E7=90=86=E7=8F=AD=E7=BA=A7=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E9=AB=98=E5=BA=A6=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/weui/weixin.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index a81541e39..ac3faeec4 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -155,7 +155,7 @@ a.underline {text-decoration:underline;} .locked_btn_cir {background: url("/images/wechat/locked.png") 0 0 no-repeat; cursor: default;} /*20150612加入班级样式*/ -.add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; margin:0 auto; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%);} +.add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%);} .add-class-tip {padding-top:1.2em; padding-bottom:.5em; font-weight:400;} .class-number-input {width:80%; max-width:240px; height:28px; border:1px solid #ccc; padding-left:5px; margin:0 auto; display:block;} .cancel-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} @@ -211,7 +211,7 @@ a.underline {text-decoration:underline;} .students-amount {height:14px; line-height:14px; vertical-align:middle; padding:2px 5px; background-color:#e6e6e6; border-radius:10px;} .new-class-btn {font-size:15px; color:#fff; background-color:#3b94d6; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} .join-class-btn {font-size:15px; color:#444; background-color:#ccc; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} -.new-class-input {width:60%; color:#555; height:35px; line-height:35px; vertical-align:middle; border:none; outline:none;} +.new-class-input {width:60%; color:#555; height:16px; line-height:16px; vertical-align:middle; border:none; outline:none; padding:10px 0;} /*20160616登录注册*/ .login-wrap {padding:0 10px;} From 5b3c6cc012be4e08cc6a04a75a2fe5d272def8d3 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 15:41:40 +0800 Subject: [PATCH 12/52] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/directives/input_auto.js | 4 ++-- public/stylesheets/weui/weixin.css | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/javascripts/wechat/directives/input_auto.js b/public/javascripts/wechat/directives/input_auto.js index 28cb792ab..1f2550882 100644 --- a/public/javascripts/wechat/directives/input_auto.js +++ b/public/javascripts/wechat/directives/input_auto.js @@ -8,11 +8,11 @@ app.directive('inputAuto',function(){ element.on('input',function(){ console.log(sendButton); copyContainer.html(element[0].value); - var textHeight = copyContainer[0].scrollHeight; + var textHeight = copyContainer[0].scrollHeight-10; element.css('height', textHeight + 'px'); }); sendButton.on('click',function(){ - element.css('height','28px'); + element.css('height','18px'); }); } } diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index ac3faeec4..a5b7d3a7a 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -129,8 +129,8 @@ a.underline {text-decoration:underline;} .post-reply-date, .post-reply-trigger {font-size:13px;} .post-input-container {position:relative; padding-right:70px;} .copy-input-container {position:relative; padding-right:70px;} -.copy-input {width:100%; height:28px; line-height:28px; padding:0 5px; vertical-align: middle; font-size:12px; border-radius:3px; position:absolute; left:-999em;} -.post-reply-input {width:100%; height:28px; max-height:84px; line-height:28px; vertical-align: middle; font-size:13px; border:1px solid #e6e6e6; outline:none; padding:0 5px; margin:0; border-radius:3px; overflow-y:auto; resize:none; background-color:#f0eff4;} +.copy-input {width:100%; height:18px; line-height:18px; padding:5px; vertical-align: middle; font-size:12px; border-radius:3px; position:absolute; left:-999em;} +.post-reply-input {width:100%; height:18px; max-height:54px; line-height:18px; vertical-align: middle; font-size:13px; border:1px solid #e6e6e6; outline:none; padding:5px; margin:0; border-radius:3px; overflow-y:auto; resize:none; background-color:#f0eff4;} .post-reply-submit {position:absolute; font-size:13px; height:30px; line-height:30px; vertical-align:middle; padding:0 8px; color:#fff; background-color:#269ac9; outline:none; border:none; top:0; right:0;} .reply-icon {background:url(/images/wechat/icon_list.gif) -150px -155px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} .praise-icon {background:url(/images/wechat/icon_list.gif) -36px -88px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} From cf04bb5ec6b6257d4d46ae52271079c2e56aa0c0 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Jul 2016 15:59:52 +0800 Subject: [PATCH 13/52] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- app/controllers/repositories_controller.rb | 2 +- app/models/changeset.rb | 4 ++-- lib/tasks/gitlab_act_project.rake | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 03dbb5785..a94f1b33b 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'elasticsearch-rails' ### profile -gem 'oneapm_rpm' +# gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 6b41e39fc..65b4a15d6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -48,7 +48,7 @@ class RepositoriesController < ApplicationController include RepositoriesHelper helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH - require 'net/ssh' + # require 'net/ssh' rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new diff --git a/app/models/changeset.rb b/app/models/changeset.rb index f72342257..20b919d37 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -23,7 +23,7 @@ class Changeset < ActiveRecord::Base has_many :filechanges, :class_name => 'Change', :dependent => :delete_all # fq - has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :forge_activities, :class_name => 'ForgeActivity', :as => :forge_act, :dependent => :destroy # end #Added by nie @@ -118,7 +118,7 @@ class Changeset < ActiveRecord::Base # 项目中提交动态,类型Changeset # type:0 为老版本即Trsutie数据 1为gitlab中获取的动态 def act_as_forge_activity - self.acts << ForgeActivity.new(:user_id => self.user_id, :project_id => self.project_id, :type => true) + self.forge_acts << ForgeActivity.new(:user_id => self.user_id, :project_id => self.project_id, :type => true) end def scan_for_issues diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index ee9ca1a9a..91990b175 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -11,8 +11,9 @@ namespace :gitlab do # 总的提交次数 commit_count = g.user_static(project.gpid, :rev => g_default_branch).count pages = commit_count / 20 + 1 - pages.each do |page| - commits = g.commits(g_project.gpid, :ref_name => g_default_branch, :page => page) + puts "#{pages}" + (0..pages).each do |page| + commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) end From 707df88c7f7fa964ae43f3ac745bcc07556d06b2 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 19 Jul 2016 16:05:39 +0800 Subject: [PATCH 14/52] =?UTF-8?q?tab=E5=AE=B9=E5=99=A8=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E7=99=BE=E5=88=86=E7=99=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/weui/weixin.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index a5b7d3a7a..8a755b323 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -86,7 +86,7 @@ a.underline {text-decoration:underline;} .btn2 {width:145px; height:35px; color:#fff; font-size:15px; line-height:35px; text-align:center; vertical-align:middle; margin:18px auto 20px auto; border-radius:50px; display:block;} /*tab*/ -.tab-wrap {position:relative; line-height:38px; display:-webkit-box; display:-moz-box; display:-ms-flexbox; display:-webkit-flex; display:flex; font-size:13px; background-color:#fff;} +.tab-wrap {position:relative; width:100%; line-height:38px; display:-webkit-box; display:-moz-box; display:-ms-flexbox; display:-webkit-flex; display:flex; font-size:13px; background-color:#fff;} .tab-wrap a {position:relative; display:block; -webkit-box-flex:1; -moz-box-flex:1; -ms-flex:1; flex:1;} .tab-wrap a:first-child:after {display:none;} .tab-wrap a:after {content:" "; position:absolute; left:0; top:0; width:1px; height:100%; border-left:1px solid #ccc; color:#707070;} From 0c0dfbd09354585c6a3e003c74dd967effd92718 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Jul 2016 17:38:11 +0800 Subject: [PATCH 15/52] =?UTF-8?q?changeset=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/changeset.rb | 6 +++--- lib/tasks/gitlab_act_project.rake | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 20b919d37..ae1faf40a 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -22,9 +22,7 @@ class Changeset < ActiveRecord::Base #after_save :be_user_score # user_score has_many :filechanges, :class_name => 'Change', :dependent => :delete_all - # fq - has_many :forge_activities, :class_name => 'ForgeActivity', :as => :forge_act, :dependent => :destroy - # end + has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy #Added by nie has_one :project_status, :dependent => :destroy @@ -59,6 +57,8 @@ class Changeset < ActiveRecord::Base validates :committed_on, presence: true validates :commit_date, presence: true validates :scmid, uniqueness: {scope: :repository_id, allow_nil: true} + attr_accessible :product + attr_accessible :type scope :visible, lambda {|*args| includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args)) diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 91990b175..259fdc58e 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -3,7 +3,8 @@ namespace :gitlab do task :forge_acts => :environment do begin g = Gitlab.client - projects = Project.find_by_sql("select * from projects where gpid is not null") + # projects = Project.find_by_sql("select * from projects where gpid is not null") + projects = Project.find("select * from projects where gpid is not null and id != 2") projects.each do |project| g_project = g.project(project.gpid) # 获取默认分支 @@ -15,7 +16,7 @@ namespace :gitlab do (0..pages).each do |page| commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| - Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) + Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at, :type => true) end end end From 53feb0bbd4c4690e7c42294f789d5fab8473b8e2 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 20 Jul 2016 09:11:05 +0800 Subject: [PATCH 16/52] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=90=8D=E7=A7=B0=E5=AE=BD=E5=BA=A6=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/class_list.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html index d0074f343..063e92861 100644 --- a/public/assets/wechat/class_list.html +++ b/public/assets/wechat/class_list.html @@ -4,7 +4,7 @@
我创建的课程
-
{{syllabus.title}}
+
  • @@ -18,7 +18,7 @@
    我参与的课程
    -
    {{syllabus.title}}
    +
    • From 14e6db457b8cbf0ded900458ae7a825d9f6eb597 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 20 Jul 2016 09:38:23 +0800 Subject: [PATCH 17/52] rake --- app/models/changeset.rb | 2 +- lib/tasks/gitlab_act_project.rake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index ae1faf40a..3a772eb6b 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -57,7 +57,7 @@ class Changeset < ActiveRecord::Base validates :committed_on, presence: true validates :commit_date, presence: true validates :scmid, uniqueness: {scope: :repository_id, allow_nil: true} - attr_accessible :product + attr_accessible :product, :project_id, :repository_id, :revision, :committer, :comments, :committed_on attr_accessible :type scope :visible, lambda {|*args| diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 259fdc58e..962dac221 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -4,7 +4,7 @@ namespace :gitlab do begin g = Gitlab.client # projects = Project.find_by_sql("select * from projects where gpid is not null") - projects = Project.find("select * from projects where gpid is not null and id != 2") + projects = Project.find_by_sql("select * from projects where gpid is not null and id != 2") projects.each do |project| g_project = g.project(project.gpid) # 获取默认分支 From 1ce7b22c0eaa78316b62f66c3dd865ac9860d1ac Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Jul 2016 10:09:27 +0800 Subject: [PATCH 18/52] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 38 +++++++------- app/api/mobile/apis/blog_comments.rb | 7 ++- app/api/mobile/entities/blog_comment.rb | 49 ++++++++++++++++++- public/javascripts/wechat/controllers/blog.js | 14 +++++- public/javascripts/wechat/others/factory.js | 10 ++-- 5 files changed, 90 insertions(+), 28 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 5a0345207..9b4bdb5d6 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -1,25 +1,25 @@ #coding=utf-8 module Mobile - # require_relative 'middleware/error_handler' - # require_relative 'apis/auth' - # require_relative 'apis/users' - # require_relative 'apis/courses' - # require_relative 'apis/watches' - # require_relative 'apis/upgrade' - # require_relative 'apis/homeworks' - # require_relative 'apis/comments' - # require_relative 'apis/issues' - # require_relative 'apis/activities' - # require_relative 'apis/whomeworks' - # require_relative 'apis/newss' - # require_relative 'apis/journal_for_messages' - # require_relative 'apis/messages' - # require_relative 'apis/blog_comments' - # require_relative 'apis/new_comment' - # require_relative 'apis/praise' - # require_relative 'apis/resources' - # require_relative 'apis/syllabuses' + require_relative 'middleware/error_handler' + require_relative 'apis/auth' + require_relative 'apis/users' + require_relative 'apis/courses' + require_relative 'apis/watches' + require_relative 'apis/upgrade' + require_relative 'apis/homeworks' + require_relative 'apis/comments' + require_relative 'apis/issues' + require_relative 'apis/activities' + require_relative 'apis/whomeworks' + require_relative 'apis/newss' + require_relative 'apis/journal_for_messages' + require_relative 'apis/messages' + require_relative 'apis/blog_comments' + require_relative 'apis/new_comment' + require_relative 'apis/praise' + require_relative 'apis/resources' + require_relative 'apis/syllabuses' class API < Grape::API version 'v1', using: :path diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb index bb5758e71..5b970e0ba 100644 --- a/app/api/mobile/apis/blog_comments.rb +++ b/app/api/mobile/apis/blog_comments.rb @@ -8,8 +8,13 @@ module Mobile desc "get special topic" get ':id' do user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 + blog = BlogComment.find params[:id] - present :data, blog, with: Mobile::Entities::BlogComment,user: user + present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page present :status, 0 end end diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index a61864900..cd7902097 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -53,7 +53,18 @@ module Mobile blog_comment_expose :praise_count expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) - c.children.reverse + ##自己的父回复为空 才有子回复 + if !opt[:children] + if c.parent.nil? && opt[:type] == 0 + opt[:children] = true + all_comments = [] + tStart = opt[:page]*5 + tEnd = (opt[:page]+1)*5 - 1 + + all_comments = get_all_children(all_comments, c)[tStart..tEnd] + all_comments + end + end end end expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options| @@ -63,6 +74,42 @@ module Mobile has_praise = obj.empty? ? false : true has_praise end + + expose :parents_reply_bottom, using:Mobile::Entities::BlogComment do |c,opt| + if c.is_a? (::BlogComment) + #取二级回复的底楼层 + if (opt[:type] == 1 && !opt[:bottom]) + opt[:bottom] = true + parents_reply = [] + parents_reply = c.parent.nil? ? [] : parents_reply << c.parent #get_reply_parents_no_root(parents_reply, c)[0] + parents_reply + end + end + end + + expose :parents_reply_top, using:Mobile::Entities::BlogComment do |c,opt| + if c.is_a? (::BlogComment) + #取二级回复的顶楼层 + if (opt[:type] == 1 && !opt[:top]) + opt[:top] = true + + parents_reply = [] + parents_reply = get_reply_parents_no_root(parents_reply, c) + + tStart = opt[:page]*2 + tEnd = (opt[:page]+1)*2 - 1 + + parents_reply = parents_reply.reverse[tStart,tEnd] + parents_reply + end + end + end + + expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options| + parents_reply = [] + parents_reply = get_reply_parents_no_root(parents_reply, instance) + parents_reply.count + end end end end \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js index 4c2403944..48bd2863a 100644 --- a/public/javascripts/wechat/controllers/blog.js +++ b/public/javascripts/wechat/controllers/blog.js @@ -7,8 +7,18 @@ app.controller('BlogController', scope: $scope, type: 'blog_comments', replyType: 'BlogComment', - loadCallback: function(data){ - $scope.blog = data.data; + loadCallback: function(data,replytype,page){ + console.log(data.data); + + if (replytype == 0 && page == 0 ) { + $scope.blog = data.data; + } + else{ + + + + + } }, replyCallback: function(){ } diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 2b0d4f994..3e5b4c4f3 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -158,19 +158,19 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au var init = function(args){ args.scope.formData = {comment: ''}; - var loadData = function(id){ - loadCommonData(id, args.type).then(function successCallback(response) { - args.loadCallback(response.data); + var loadData = function(id,replytype,page){ + loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { + args.loadCallback(response.data,replytype,page); }, function errorCallback(response) { }); }; - loadData(args.id); + loadData(args.id,0,0); args.scope.addReply = function(data){ console.log(data.comment); addCommonReply(args.id, args.replyType, data, function(){ args.scope.formData = {comment: ''}; - loadData(args.id); + loadData(args.id,0,0); if(typeof args.replyCallback === 'function'){ args.replyCallback(); } From e99c76a0de40dbb64a8fe1be4d44fefab9656489 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 20 Jul 2016 10:09:55 +0800 Subject: [PATCH 19/52] resolve edit problem of jenkins job --- app/controllers/projects_controller.rb | 16 ++++------------ app/controllers/quality_analysis_controller.rb | 5 +---- app/views/quality_analysis/_show.html.erb | 4 ++-- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index cb86f1165..f3ba6f76c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -300,8 +300,6 @@ class ProjectsController < ApplicationController return end - logger.debug "111111111"*100 - # over @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) @page = params[:page] ? params[:page].to_i + 1 : 0 # 根据私密性,取出符合条件的所有数据 @@ -321,7 +319,7 @@ class ProjectsController < ApplicationController else @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10); end - logger.debug "2"*100 + # g = Gitlab.client unless @project.gpid.nil? || @project.project_score.changeset_num == 0 # rep_statics_commit = @project.rep_statics.order("commits_num desc") @@ -335,20 +333,14 @@ class ProjectsController < ApplicationController @a_commits_del = rep_statics_code.map {|s| s.del.to_i } @a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i } g = Gitlab.client - logger.debug "3"*100 begin gid = @project.gpid - logger.debug "31"*100 - g_branch = g.project(gid) - logger.debug "4"*100 - g_branch = g_branch.default_branch.to_s - logger.debug "5"*100 + g_project = g.project(gid) + g_branch = g_project.default_branch.to_s rescue =>e - logger.error("get gitlab project failed: " + e) + logger.error("get default branch failed: " + e) end - logger.debug "6"*100 @rev = g_branch.nil? ? "master" : g_branch - logger.debug "7"*100 end # 根据对应的请求,返回对应的数据 respond_to do |format| diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 6b50c1788..cff255fe6 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -165,7 +165,7 @@ class QualityAnalysisController < ApplicationController logger.info("result: delete job ###################==>#{d_job}") qa.delete respond_to do |format| - format.html{redirect_to project_quality_analysis_path(:project_id => @project.id)} + format.html{redirect_to project_repository_path(@project)} end rescue Exception => e puts e @@ -199,9 +199,6 @@ class QualityAnalysisController < ApplicationController # update成功则返回 ‘200’ jenkins_job = @client.job.update("#{job_name}", @doc.to_xml) - get_current_build_status = @client.job.get_current_build_status("Hjqreturn-1280") - logger.error("Failed to update job: ==> #{jenkins_job}") unless jenkins_job == '200' - # 数据更新到Trustie数据 if jenkins_job == '200' logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}") diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index b364f5f89..7901c6be0 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -34,7 +34,7 @@

      代码重复度

      <%= @ha["duplicated_lines_density"].to_i == 0 ? 0 : @ha["duplicated_lines_density"] %> borderRadius"> - <%= @ha["duplicated_lines_density"].nil? ? 0 : duplicated_lines_density_status(@ha["duplicated_lines_density"].to_i)[0] %> + <%= @ha["duplicated_lines_density"].nil? ? "良好" : duplicated_lines_density_status(@ha["duplicated_lines_density"].to_i)[0] %>

    @@ -43,7 +43,7 @@

    注释率

    <%= @ha["comment_lines_density"].to_i == 0 ? 0 : @ha["comment_lines_density"] %> borderRadius"> - <%= @ha["comment_lines_density"].nil? ? 0 : comment_lines_density_status(@ha["comment_lines_density"].to_i)[0] %> + <%= @ha["comment_lines_density"].nil? ? "较低" : comment_lines_density_status(@ha["comment_lines_density"].to_i)[0] %>

    From 3a43b7beb58b069ddb6727cbb5e10a028ec2a8a0 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 20 Jul 2016 11:20:48 +0800 Subject: [PATCH 20/52] redirect to repository when delete jenkins job --- app/controllers/quality_analysis_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index cff255fe6..80c5a2468 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -165,7 +165,7 @@ class QualityAnalysisController < ApplicationController logger.info("result: delete job ###################==>#{d_job}") qa.delete respond_to do |format| - format.html{redirect_to project_repository_path(@project)} + format.html{redirect_to :controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).identifier} end rescue Exception => e puts e From 67e87df4d51f37bd9ca8a28dd57c424f36dfe913 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Jul 2016 13:34:58 +0800 Subject: [PATCH 21/52] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=9B=9E=E5=A4=8D=E6=98=BE=E7=A4=BA=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/blog_comments.rb | 4 +++- app/api/mobile/apis/issues.rb | 10 ++++++-- app/api/mobile/apis/journal_for_messages.rb | 11 +++++++-- app/api/mobile/apis/messages.rb | 10 ++++++-- app/api/mobile/apis/newss.rb | 10 ++++++-- app/api/mobile/apis/whomeworks.rb | 10 ++++++-- app/api/mobile/entities/activity.rb | 22 ++++++++--------- public/javascripts/wechat/controllers/blog.js | 18 +++++++++++--- public/javascripts/wechat/others/factory.js | 24 +++++++++++++++---- 9 files changed, 90 insertions(+), 29 deletions(-) diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb index 5b970e0ba..39b6a486a 100644 --- a/app/api/mobile/apis/blog_comments.rb +++ b/app/api/mobile/apis/blog_comments.rb @@ -6,7 +6,7 @@ module Mobile resources :blog_comments do desc "get special topic" - get ':id' do + post ':id' do user = current_user #0一级回复的更多 1 二级回复的更多 @@ -15,6 +15,8 @@ module Mobile blog = BlogComment.find params[:id] present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index 4a6417cb4..36b558652 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -7,11 +7,17 @@ module Mobile include IssuesHelper desc "get special issuse" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 issue = Issue.find params[:id] - present :data, issue, with: Mobile::Entities::Issue,user: user + present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb index 5f2d01185..6ac484513 100644 --- a/app/api/mobile/apis/journal_for_messages.rb +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -6,11 +6,18 @@ module Mobile resources :journal_for_messages do desc "get special journal" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 + jour = JournalsForMessage.find params[:id] - present :data, jour, with: Mobile::Entities::Jours,user: user + present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb index bab82de8d..ceda5058f 100644 --- a/app/api/mobile/apis/messages.rb +++ b/app/api/mobile/apis/messages.rb @@ -6,11 +6,17 @@ module Mobile resources :messages do desc "get special topic" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 message = Message.find params[:id] - present :data, message, with: Mobile::Entities::Message,user: user + present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb index d42177783..6e012ca4b 100644 --- a/app/api/mobile/apis/newss.rb +++ b/app/api/mobile/apis/newss.rb @@ -6,11 +6,17 @@ module Mobile resources :newss do desc "get special news" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 news = News.find params[:id] - present :data, news, with: Mobile::Entities::News,user: user + present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index c8377aa0d..db1e7e269 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -6,11 +6,17 @@ module Mobile resources :whomeworks do desc "get one homework" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 homework = HomeworkCommon.find params[:id] - present :data, homework, with: Mobile::Entities::Whomework,user: user + present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index bdeff7ae9..2856354a1 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -20,17 +20,17 @@ module Mobile ac.act unless ac.nil? || ac.act.nil? end when :reply_count - # if ac.act_type == "HomeworkCommon" - # ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count - # elsif ac.act_type == "News" - # ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count - # elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" - # ac.nil? || ac.act.nil? ? 0 : ac.act.children.count - # elsif ac.act_type == "Issue" - # ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count - # end - all_comments = [] - ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count + if ac.act_type == "HomeworkCommon" + ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count + elsif ac.act_type == "News" + ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count + elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" + all_comments = [] + ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count + elsif ac.act_type == "Issue" + ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count + end + when :subject if ac.act_type == "HomeworkCommon" ac.act.name unless ac.nil? || ac.act.nil? diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js index 48bd2863a..dc9f4bf39 100644 --- a/public/javascripts/wechat/controllers/blog.js +++ b/public/javascripts/wechat/controllers/blog.js @@ -7,17 +7,29 @@ app.controller('BlogController', scope: $scope, type: 'blog_comments', replyType: 'BlogComment', - loadCallback: function(data,replytype,page){ + loadCallback: function(data){ console.log(data.data); + replytype = data.type; + page = data.page; - if (replytype == 0 && page == 0 ) { - $scope.blog = data.data; + if (replytype == 0){ + if (page == 0){ + $scope.blog = data.data; + } + else{ + $scope.blog.blog_comment_children = $scope.blog.blog_comment_children.concat(data.data.blog_comment_children); + } + $scope.has_more = $scope.blog.blog_comment_children.length < $scope.blog.comment_count; + console.log($scope.has_more); } else{ + + + } }, replyCallback: function(){ diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 3e5b4c4f3..dcd78740f 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -121,10 +121,18 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au }); }; - var loadCommonData = function(id, type){ +// var loadCommonData = function(id, type,replytype,page){ +// return $http({ +// method: 'GET', +// url: apiUrl+ type + "/" + id+"?token="+auth.token(), +// }) +// }; + + var loadCommonData = function(id, type,replytype,page){ return $http({ - method: 'GET', - url: apiUrl+ type + "/" + id+"?token="+auth.token() + method: 'POST', + url: apiUrl+ type + "/" + id, + data:{token:auth.token(),type:replytype,page:page} }) }; @@ -160,7 +168,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au args.scope.formData = {comment: ''}; var loadData = function(id,replytype,page){ loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { - args.loadCallback(response.data,replytype,page); + args.loadCallback(response.data); }, function errorCallback(response) { }); }; @@ -245,6 +253,14 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au act.has_praise = false; decreaseCommonPraise(act); }; + + args.scope.morereply = function(data,replytype,page){ + loadCommonData(data.id, args.type,replytype,page).then(function successCallback(response) { + args.loadCallback(response.data); + }, function errorCallback(response) { + }); + }; + } return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise}; From c56f7732a1c401b6a86d2f63d802bcd17b126fa6 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 20 Jul 2016 14:05:17 +0800 Subject: [PATCH 22/52] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E6=96=B0=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/weui/weixin.css | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 8a755b323..ed3af75ae 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -222,4 +222,10 @@ a.underline {text-decoration:underline;} .login-box.checked{background:#63c360; border:1px solid #63c360;} .login-box.checked:after{content:url(/images/wechat/checked.png);} .forget-psw-wrap {width:60px; margin:0 auto;} -.forget-psw {position:fixed; bottom:10px;} \ No newline at end of file +.forget-psw {position:fixed; bottom:10px;} + +/*二级回复*/ +.mult-reply-container{ border:solid 1px #f3ddb3; background:#fffef4; padding:4px;color:#999; margin-top:-1px;} +.mult-reply-content{ color:#707070; font-size:13px;} +.mult-reply-hide{ text-align:center; display:block; font-size:14px; color:#aaa; border-bottom:1px solid #F3DDB3; padding:8px 0;} +.mult-reply-arrow{ color:#aaa; margin-right:10px; font-size:14px; font-weight:bold;} \ No newline at end of file From f979e80f24a73c3850e1db2b8c2518c83ae12c93 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 20 Jul 2016 17:05:55 +0800 Subject: [PATCH 23/52] =?UTF-8?q?Gitlab=E6=95=B0=E6=8D=AE=E6=B8=85?= =?UTF-8?q?=E7=90=86=E5=8F=8A=E8=BF=81=E7=A7=BB=EF=BC=8C=E4=B8=BB=E8=A6=81?= =?UTF-8?q?=E6=98=AF=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/changeset.rb | 4 +--- lib/tasks/gitlab_act_project.rake | 15 ++++++++------- lib/tasks/gitlab_unused.rake | 11 +++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 lib/tasks/gitlab_unused.rake diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 3a772eb6b..a9c3687a1 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -57,9 +57,7 @@ class Changeset < ActiveRecord::Base validates :committed_on, presence: true validates :commit_date, presence: true validates :scmid, uniqueness: {scope: :repository_id, allow_nil: true} - attr_accessible :product, :project_id, :repository_id, :revision, :committer, :comments, :committed_on - attr_accessible :type - + attr_accessible :type, :project_id, :repository_id, :revision, :committer, :comments, :committed_on scope :visible, lambda {|*args| includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args)) } diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 962dac221..142d5bf89 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -1,11 +1,11 @@ namespace :gitlab do desc "sync gitlab's commit acts to trustie" task :forge_acts => :environment do - begin - g = Gitlab.client - # projects = Project.find_by_sql("select * from projects where gpid is not null") - projects = Project.find_by_sql("select * from projects where gpid is not null and id != 2") - projects.each do |project| + g = Gitlab.client + # projects = Project.find_by_sql("select * from projects where gpid is not null") + projects = Project.find_by_sql("select * from projects where gpid is not null and id > 265") + projects.each do |project| + begin g_project = g.project(project.gpid) # 获取默认分支 g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch @@ -13,15 +13,16 @@ namespace :gitlab do commit_count = g.user_static(project.gpid, :rev => g_default_branch).count pages = commit_count / 20 + 1 puts "#{pages}" + puts "project id is #{project.id}" (0..pages).each do |page| commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at, :type => true) end end + rescue Exception => e + puts e end - rescue Exception => e - puts e end end end diff --git a/lib/tasks/gitlab_unused.rake b/lib/tasks/gitlab_unused.rake new file mode 100644 index 000000000..0b90d9352 --- /dev/null +++ b/lib/tasks/gitlab_unused.rake @@ -0,0 +1,11 @@ +namespace :gitlab do + desc "sync gitlab's commit acts to trustie" + task :unused => :environment do + begin + Project.where("id in (161,236,266)").update_all(:gpid => nil) + Repository.where("project_id in (161,236,266)").destroy_all + rescue Exception => e + puts e + end + end +end From 6357f5be2a2dc6a2c442b04e22f20fd2c11668e0 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 09:27:14 +0800 Subject: [PATCH 24/52] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96=E5=8D=95=E4=BD=8D=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 5 +++++ app/views/admin/users.html.erb | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 603084cd1..42a3491fb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -38,6 +38,11 @@ module ApplicationHelper # super # end + # 获取用户单位 + # 优先获取高校信息,如果改信息不存在则获取occupation + def get_occupation_from_user user + School.where("id=?",user.user_extensions.school_id).first.try(:name).nil? ? user.user_extensions.occupation : School.where("id=?",user.user_extensions.school_id).first.try(:name) + end def update_visiti_count container container.update_column(:visits, container.visits + 1) diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index 2a757fdee..9215782bb 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -56,8 +56,7 @@ <%= checked_image user.admin? %> <%= format_time(user.created_on) %> <%= format_time(user.last_login_on) unless user.last_login_on.nil? %> - <% occupation = user.user_extensions.identity == 0 ? School.where("id=?",user.user_extensions.school_id).first.try(:name) : user.user_extensions.occupation %> - <%= truncate( occupation, :length => 12 ) %> + <%= truncate(get_occupation_from_user(user), :length => 12 ) %> <%= change_status_link(user) %> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> From 541440135f1332cc090e4ce39b0547868ce3d8e0 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 21 Jul 2016 10:11:02 +0800 Subject: [PATCH 25/52] =?UTF-8?q?css=E4=B8=AD=E5=BC=95=E7=94=A8=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/css/common.css | 4 +- public/stylesheets/css/courses.css | 28 ++++++------ public/stylesheets/css/org.css | 2 +- public/stylesheets/css/popup.css | 12 +++--- public/stylesheets/css/project.css | 64 ++++++++++++++-------------- public/stylesheets/css/public.css | 4 +- public/stylesheets/css/structure.css | 50 +++++++++++----------- 7 files changed, 82 insertions(+), 82 deletions(-) diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css index 1ec98b1cf..b72a8ef56 100644 --- a/public/stylesheets/css/common.css +++ b/public/stylesheets/css/common.css @@ -43,7 +43,7 @@ table{ background:#fff;} .no_line{ border-bottom:none;} .line{border-bottom:1px dashed #d4d4d4; padding-bottom:10px; margin-bottom:10px;} .no_border{ border:none;} -.min_search{ width:150px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 135px -193px no-repeat; cursor:pointer;} +.min_search{ width:150px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(/images/public_icon.png) 135px -193px no-repeat; cursor:pointer;} a.btn_message_free{ background:#ff5722; display:block; text-align:center; color:#fff; padding:3px 0; width:80px; margin-bottom:10px;} .db {display:block;} @@ -530,7 +530,7 @@ a:hover.bgreen_n_btn{background:#08a384;} .blue_btn_cir{ background:#3498db; padding:1px 10px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;white-space:nowrap;} .orange_btn_cir{ background:#e67e22; padding:1px 10px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal; font-size:12px;white-space:nowrap;} .sticky_btn_cir{ background:#269ac9; padding:1px 10px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal; font-size:12px;white-space:nowrap;} -.locked_btn_cir{background: url(../images/locked.png) 0 0 no-repeat; cursor: default;} +.locked_btn_cir{background: url(/images/locked.png) 0 0 no-repeat; cursor: default;} .bgreen_btn_cir{ background:#1abc9c; padding:1px 10px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal; font-size:12px;white-space:nowrap;} .grey_border{border:1px solid #dddddd !important;} .red-cir-btn{ background:#e74c3c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index 4ee419d7b..0647ebe9a 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -35,8 +35,8 @@ a:hover.DropBtn{background: url(../images/homepage_icon.png) -125px -370px no-re .ProResultTable{ color:#888888;} .SearchIcon{background:url(../images/homepage_icon2.png) 676px -393px no-repeat; } .SearchIcon:hover{background:url(../images/homepage_icon2.png) 676px -419px no-repeat; } -a.link_file{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; } -a:hover.link_file{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} +a.link_file{ background:url(/images/pic_file.png) 0 2px no-repeat; padding-left:20px; } +a:hover.link_file{ background:url(/images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} a.remove-upload {background: url(/images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;margin-left: 5px;} a.FilesName{ max-width:540px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:block;} a.FilesName02{ max-width:665px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:block;} @@ -132,8 +132,8 @@ a:hover.tijiao{ background:#297fb8;} .grey_c{ color:#808181;} .link_file_a{ display:block; max-width:450px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} -.ul_grey li {color:#909090; list-style-position:inside; padding-left:1px;list-style-image:url('../images/news_dot2.png')} -.ul_normal_color li {list-style-position:inside; padding-left:1px; list-style-image:url('../images/news_dot.png')} +.ul_grey li {color:#909090; list-style-position:inside; padding-left:1px;list-style-image:url('/images/news_dot2.png')} +.ul_normal_color li {list-style-position:inside; padding-left:1px; list-style-image:url('/images/news_dot.png')} span.author { font-size: 0.9em; color: #888; } .ReplyToMessageInputContainer {width: 582px;float: left;} .ReplyToMessageContainer {border-bottom:1px solid #e3e3e3; width:632px; margin:0px auto; margin-top:15px; min-height:60px;} @@ -152,8 +152,8 @@ a.select_btn_select{ background:#64bddb; color:#fff;} .courses_list_pic{ border:1px solid #ede7e9; width:64px; height:64px; padding:1px;} .courses_list_pic:hover{border:1px solid #64bdd9;} .courses_list_title{ max-width:500px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} -.pic_eye_blue{display:block; background:url(../images/pic_uersall.png) -372px 3px no-repeat; width:16px; height:15px; } -.pic_eye_grey{display:block; background:url(../images/pic_uersall.png) -372px -10px no-repeat; width:16px; height:15px; } +.pic_eye_blue{display:block; background:url(/images/pic_uersall.png) -372px 3px no-repeat; width:16px; height:15px; } +.pic_eye_grey{display:block; background:url(/images/pic_uersall.png) -372px -10px no-repeat; width:16px; height:15px; } .courses_list{ padding-bottom:10px;} .courses_list_table{ color:#6e6e6e;} @@ -349,7 +349,7 @@ a:hover.icon_remove{background:url(../images/icons.png) -20px -338px no-repeat;} a.hwork_center{ display:block; width:60px; text-align:center; margin-right:5px;} .show_hwork{ border:2px solid #64bdd9; width:646px; padding:10px; color:#666666; padding-bottom:0px; } .show_hwork ul li{ margin-bottom:5px;} -.show_hwork_arrow{ position:relative; top:1px; left:165px;background:url(../images/course/arrow_up.jpg) 0 0 no-repeat; width:20px; height:11px;} +.show_hwork_arrow{ position:relative; top:1px; left:165px;background:url(/images/course/arrow_up.jpg) 0 0 no-repeat; width:20px; height:11px;} .tit_fb{ font-weight:bold; width:66px; text-align:right; display:block; float:left;} .show_hwork_p{ width:630px; float:left;} .hwork_ping_text{ float:left; border:1px solid #e4e4e4; padding:5px; width:615px; height:35px;} @@ -363,7 +363,7 @@ a:hover.ping_pic{border:1px solid #64bdd9;} .ping_back_tit{ float:left; width:578px; margin-left:10px; } a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;} a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;} -.min_search{ width:200px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(../images/public_icon.png) 185px -193px no-repeat; cursor:pointer;} +.min_search{ width:200px; height:20px; border:1px solid #d0d0d0; color:#666; background:url(/images/public_icon.png) 185px -193px no-repeat; cursor:pointer;} .li_min_search{ float:right; margin-right:-10px;} .info_ni{ width:100px; padding:5px;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left;} .hwork_num{ width:90px; text-align:center; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} @@ -428,7 +428,7 @@ a:hover.rside_work_tit{ color:#0781b4;} .bgrey_icon{ color:#9b9b9b; border:1px solid #b6b6b6; background:#f0f0f0; font-size:12px; padding:0px 3px; } .dgrey_icon{ color:#717171; border:1px solid #717171; font-size:12px; padding:0px 3px;} .yellow_icon{ color:#ff5c60; border:1px solid #ff5c60; background:#ffffd5; font-size:12px; padding:0px 3px;} -.arrow_r{background:url(../images/course/icons.png) 0 -450px no-repeat; width:22px; height:13px; } +.arrow_r{background:url(/images/course/icons.png) 0 -450px no-repeat; width:22px; height:13px; } .c_dgreen{ color:#0e9e4f;} .list_more{ text-align:center; margin:10px 0;} .rside_massage_txt{ width:650px; margin-left:10px; } @@ -436,14 +436,14 @@ a.massage_tit{ max-width:530px;overflow:hidden; white-space: nowrap; text-overfl a.rside_name{ display:block; max-width:80px;} .rside_talk_txt{ width:650px; margin-left:10px; color:#333;} .rside_talk_tit{ color:#0781b4; width:490px; display:block; } -.rside_talkWrapArrow{ display:block; float:right; margin-right:10px;background:url(../images/course/arrow.png) 0 0 no-repeat; height:7px; width:13px;} +.rside_talkWrapArrow{ display:block; float:right; margin-right:10px;background:url(/images/course/arrow.png) 0 0 no-repeat; height:7px; width:13px;} .rside_talkWrapBox{ width:650px; margin-left:60px; } .rside_Msg_txt{ float:left; width:580px; margin-left:10px;} .rside_talkWrapMsg{ background:#f2f2f2; padding:10px;} .rside_talkWrapMsg ul li{} .rside_inputFeint{ border:1px solid #d9d9d9; background:#fff; width:623px; height:40px; margin:10px; margin-bottom:5px;color:#666;} -a.icon_face{background:url(../images/public_icon.png) 0px -671px no-repeat; display:block; height:25px; width:40px; padding-left:25px; padding-top:3px; } -a:hover.icon_face{background:url(../images/public_icon.png) -79px -671px no-repeat; } +a.icon_face{background:url(/images/public_icon.png) 0px -671px no-repeat; display:block; height:25px; width:40px; padding-left:25px; padding-top:3px; } +a:hover.icon_face{background:url(/images/public_icon.png) -79px -671px no-repeat; } a.pro_mes_w{ height:20px; display:block; color:#999999;} .info_list{ border-top:1px solid #F2F2F2; padding:5px 0;} .info_list_r li{ height:20px;} @@ -487,8 +487,8 @@ a:hover.btn_cancel{ color:#666;} .questionTitle{ width:644px; height:30px; border:1px solid #cbcbcb; padding-left:5px; background:#fff;} .examTime {width:90px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; } .testStatus{width:698px; border:1px solid #cbcbcb; padding:10px; margin-bottom:10px; background:#ffffff; position:relative; color:#767676;} -.testEdit{ background:url(images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; bottom:10px; right:10px; position:absolute;} -a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;} +.testEdit{ background:url(../images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; bottom:10px; right:10px; position:absolute;} +a:hover.testEdit{ background:url(../images/icons.png) -21px -272px no-repeat;} .testDesEdit {width:670px; overflow:hidden;} .testEditTitle{ padding:10px 0px ; float:left; width:564px; } .questionEditContainer {border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px; margin-top:10px;} diff --git a/public/stylesheets/css/org.css b/public/stylesheets/css/org.css index e4ce6a168..028254e04 100644 --- a/public/stylesheets/css/org.css +++ b/public/stylesheets/css/org.css @@ -105,7 +105,7 @@ div.flash {margin-top :0px !important} /*名师榜20160505*/ .function-row {border-bottom:1px dashed #b2b2b2; padding-bottom:16px;} .teacher-list-search {width:310px; height:23px; border:1px solid #ccc; border-right:none; outline:none;} -.teacher-search-icon {background:url(../images/search.png) 0 3px no-repeat; width:25px; height:25px; border:1px solid #ccc; border-left:none; cursor:pointer;} +.teacher-search-icon {background:url(/images/search.png) 0 3px no-repeat; width:25px; height:25px; border:1px solid #ccc; border-left:none; cursor:pointer;} .teacher-search-type {width:84px; height:23px; border:1px solid #ccc; outline:none;} .teacher-list-row {border-bottom:1px dashed #b2b2b2; padding:18px 0;} .teacher-avatar {float:left;} diff --git a/public/stylesheets/css/popup.css b/public/stylesheets/css/popup.css index 4b3d513cf..ae7a1ddf0 100644 --- a/public/stylesheets/css/popup.css +++ b/public/stylesheets/css/popup.css @@ -9,7 +9,7 @@ color: #333; } .ui-progressbar-value{margin:-1px;height:100%} -.ui-widget-header{border:1px solid #628db6;background:#759fcf url(jquery/images/ui-bg_gloss-wave_35_759fcf_500x100.png) 50% 50% repeat-x;color:#fff;font-weight:bold} +.ui-widget-header{border:1px solid #628db6;background:#759fcf url(../jquery/images/ui-bg_gloss-wave_35_759fcf_500x100.png) 50% 50% repeat-x;color:#fff;font-weight:bold} .ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px} /*发送资源弹窗*/ @@ -164,7 +164,7 @@ a:hover.CloseBtn{background:url(/images/CloseBtn.png) 0px -24px no-repeat; } /****评分弹框****/ /*#popbox{width:488px;height:550px;position:absolute;z-index:100;left:50%;top:40%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; padding:5px; overflow:auto; }*/ -.alert .close{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-502px;background:url(images/close.png) no-repeat;cursor:pointer;} +.alert .close{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-502px;background:url(/images/close.png) no-repeat;cursor:pointer;} .alert .C{width:476px;height:296px;position:absolute;left:5px;top:5px; } .ping_con{ margin:5px; border-bottom:1px dashed #CCC; padding-bottom:5px;} .ping_con ul{ height:30px;} @@ -173,8 +173,8 @@ a:hover.CloseBtn{background:url(/images/CloseBtn.png) 0px -24px no-repeat; } .ping_con p{ color:#777777; font-size:12px; border-bottom:1px dashed #CCC; padding-bottom:5px;} .ping_con p span a{ color:#777777;} .ping_star{ width:160px; color:#333; font-weight:bold; margin-bottom:5px;} -.ping_star span a{ float:right; width:20px; height:20px; background:url(images/star.png) -2px 0 no-repeat; margin-right:3px;} -.ping_star span a:hover{background:url(images/star.png) -24px 0 no-repeat;} +.ping_star span a{ float:right; width:20px; height:20px; background:url(../images/star.png) -2px 0 no-repeat; margin-right:3px;} +.ping_star span a:hover{background:url(../images/star.png) -24px 0 no-repeat;} .ping_con textarea{ width:455px; height:76px; border:1px solid #15bccf; margin-bottom:5px; color:#666; font-size:12px;} a.ping_sub{ float:right; height:22px; width:60px; background:#15bccf; color:#fff; text-align:center;} a:hover.ping_sub{ background:#14a8b9;} @@ -207,7 +207,7 @@ span.author { font-size: 0.9em; color: #888; } /* 匿名评分弹框 */ /*.popbox02{width:480px;height:200px;position:absolute;z-index:100;left:50%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}*/ -.alert .close02{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-490px;background:url(images/close.png) no-repeat;cursor:pointer;} +.alert .close02{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-490px;background:url(/images/close.png) no-repeat;cursor:pointer;} /* 开启匿评弹框 */ .anonymos{width:480px;height:180px;position:fixed !important;z-index:100;left:50%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} @@ -316,7 +316,7 @@ a.contributor_course{float: right; color: #888; font-size: 12px; font-weight: no /*转发样式*/ .shareDP {width:415px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:relative; z-index:1000;} -.shareArrow {background:url(../images/arrowList.png) -90px -108px no-repeat; display:inline-block; width:5px; height:10px; margin-right:3px;} +.shareArrow {background:url(/images/arrowList.png) -90px -108px no-repeat; display:inline-block; width:5px; height:10px; margin-right:3px;} .sectionWrap {float:left; max-height:150px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:205px; min-height:150px; padding-top:5px; border:1px solid #dddddd;} .columnWrap {float:left; max-height:155px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:178px; min-height:155px; border:1px solid #dddddd;} .columnWrap li {padding-left:10px; color:#585858; line-height:20px;} diff --git a/public/stylesheets/css/project.css b/public/stylesheets/css/project.css index 2edab35b5..350141150 100644 --- a/public/stylesheets/css/project.css +++ b/public/stylesheets/css/project.css @@ -159,7 +159,7 @@ div.thumbnails div {background:#fff;display:inline-block;margin-right:2px;} .repos_files ul li{ float:left; padding-left:10px; height:26px;} .repos_files ul:hover{ background:#ffffdd;} .repos_t_c li{ text-align:center;} -.pic_stats{display:block; background:url(../images/public_icon.png) 0px -548px no-repeat; width:20px; height:15px;} +.pic_stats{display:block; background:url(/images/public_icon.png) 0px -548px no-repeat; width:20px; height:15px;} .tree-age{width:10%; text-align:right;} .tree-author{width:10%; text-align:left;} .tree-comments{width:40%; text-align:left;} @@ -260,7 +260,7 @@ p.percent { .label02{ width:110px; text-align:right; font-size:14px; display:block; float:left;} .label03{ width:70px; text-align:right; display:block; float:left; white-space: nowrap;} .collapsible{ border-left:none;border-right:none;border-bottom:none; border-top:1px solid #e4e4e4; padding-top:10px; } -.icon-reload { background-image: url(../images/reload.png); } +.icon-reload { background-image: url(/images/reload.png); } .icon { background-position: 0% 50%; background-repeat: no-repeat; @@ -375,28 +375,28 @@ tr.entry td.age { text-align: right; } tr.entry.file td.filename a { margin-center: 16px; } tr.entry.file td.filename_no_report a { margin-left: 16px; } -tr span.expander {background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;} -tr.open span.expander {background-image: url(../images/bullet_toggle_minus.png);} -.icon-folder { background-image: url(../images/folder.png); } -.open .icon-folder { background-image: url(../images/folder_open.png); } -.icon-file { background-image: url(../images/files/default.png); } -.icon-file.text-plain { background-image: url(../images/files/text.png); } -.icon-file.text-x-c { background-image: url(../images/files/c.png); } -.icon-file.text-x-csharp { background-image: url(../images/files/csharp.png); } -.icon-file.text-x-java { background-image: url(../images/files/java.png); } -.icon-file.text-x-javascript { background-image: url(../images/files/js.png); } -.icon-file.text-x-php { background-image: url(../images/files/php.png); } -.icon-file.text-x-ruby { background-image: url(../images/files/ruby.png); } -.icon-file.text-xml { background-image: url(../images/files/xml.png); } -.icon-file.text-css { background-image: url(../images/files/css.png); } -.icon-file.text-html { background-image: url(../images/files/html.png); } -.icon-file.image-gif { background-image: url(../images/files/image.png); } -.icon-file.image-jpeg { background-image: url(../images/files/image.png); } -.icon-file.image-png { background-image: url(../images/files/image.png); } -.icon-file.image-tiff { background-image: url(../images/files/image.png); } -.icon-file.application-pdf { background-image: url(../images/files/pdf.png); } -.icon-file.application-zip { background-image: url(../images/files/zip.png); } -.icon-file.application-x-gzip { background-image: url(../images/files/zip.png); } +tr span.expander {background-image: url(/images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;} +tr.open span.expander {background-image: url(/images/bullet_toggle_minus.png);} +.icon-folder { background-image: url(/images/folder.png); } +.open .icon-folder { background-image: url(/images/folder_open.png); } +.icon-file { background-image: url(/images/files/default.png); } +.icon-file.text-plain { background-image: url(/images/files/text.png); } +.icon-file.text-x-c { background-image: url(/images/files/c.png); } +.icon-file.text-x-csharp { background-image: url(/images/files/csharp.png); } +.icon-file.text-x-java { background-image: url(/images/files/java.png); } +.icon-file.text-x-javascript { background-image: url(/images/files/js.png); } +.icon-file.text-x-php { background-image: url(/images/files/php.png); } +.icon-file.text-x-ruby { background-image: url(/images/files/ruby.png); } +.icon-file.text-xml { background-image: url(/images/files/xml.png); } +.icon-file.text-css { background-image: url(/images/files/css.png); } +.icon-file.text-html { background-image: url(/images/files/html.png); } +.icon-file.image-gif { background-image: url(/images/files/image.png); } +.icon-file.image-jpeg { background-image: url(/images/files/image.png); } +.icon-file.image-png { background-image: url(/images/files/image.png); } +.icon-file.image-tiff { background-image: url(/images/files/image.png); } +.icon-file.application-pdf { background-image: url(/images/files/pdf.png); } +.icon-file.application-zip { background-image: url(/images/files/zip.png); } +.icon-file.application-x-gzip { background-image: url(/images/files/zip.png); } /*版本库diff*/ .showing-changes-info {width:650px; padding:10px; padding-top: 0px; background-color:#ffffff; line-height:2;} @@ -428,11 +428,11 @@ tr.open span.expander {background-image: url(../images/bullet_toggle_minus.png); /*gcm upload file count and deleteall*/ #upload_file_count #count {color:red; font-size:1.5em;} -span.add_attachment .remove_all {background:none;background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;right:10%;text-decoration:none;} -span.add_attachment a {padding-left:16px; background: url(../images/bullet_add.png) no-repeat 0 50%; } +span.add_attachment .remove_all {background:none;background: url(/images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;right:10%;text-decoration:none;} +span.add_attachment a {padding-left:16px; background: url(/images/bullet_add.png) no-repeat 0 50%; } /*导出*/ -a.atom { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; } +a.atom { background: url(/images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; } p.other-formats { text-align: right; font-size:0.9em; color: #666; } .other-formats span + span:before { content: "| "; } @@ -488,11 +488,11 @@ a:hover.upload_btn_grey{background:#8a8a8a;} .analysis-block {padding:15px; border:1px solid #d9d9d9;} .flex {display:flex;} .analysis-genral {flex:1; display:block; text-align:center;} -.analysis-block-icon {background:url(../images/code-analysis-icon.png) -2px -8px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} -.analysis-serious-icon {background:url(../images/code-analysis-icon.png) -2px -34px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} -.analysis-main-icon {background:url(../images/code-analysis-icon.png) -2px -59px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} -.analysis-secondary-icon {background:url(../images/code-analysis-icon.png) -2px -85px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} -.analysis-info-icon {background:url(../images/code-analysis-icon.png) -2px -111px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-block-icon {background:url(/images/code-analysis-icon.png) -2px -8px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-serious-icon {background:url(/images/code-analysis-icon.png) -2px -34px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-main-icon {background:url(/images/code-analysis-icon.png) -2px -59px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-secondary-icon {background:url(/images/code-analysis-icon.png) -2px -85px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-info-icon {background:url(/images/code-analysis-icon.png) -2px -111px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} .quality-percentage {width:320px; height:14px; display:inline-block;} .quality-percentage-rate {width:50%; height:14px; background-color:#0a6c99; display:inline-block;} .image-cir {border-radius:50%;} diff --git a/public/stylesheets/css/public.css b/public/stylesheets/css/public.css index c3a85418d..a4820b273 100644 --- a/public/stylesheets/css/public.css +++ b/public/stylesheets/css/public.css @@ -131,7 +131,7 @@ html{ overflow-x:hidden;} .close_btn span { display:none;} .side_center .custom_service p { text-align:center; padding:6px 0; margin:0; vertical-align:middle;} .msgserver { margin:10px 0 0px 5px;} -.msgserver a { background:url(../images/sidebar_bg.png) no-repeat -119px -110px; padding-left:22px; display:block; height:24px; } +.msgserver a { background:url(/images/sidebar_bg.png) no-repeat -119px -110px; padding-left:22px; display:block; height:24px; } .opnionText{box-shadow:none; width:122px; height:180px; border-color: #DFDFDF; background:#fff; color:#999; padding:3px; font-size:12px;overflow:auto; background-attachment:fixed;border-style:solid;} a.opnionButton{ display:block; background:#269ac9; width:130px; height:26px; margin-top:5px; text-align:center; padding-top:0px; color:#fff;} a.opnionButton:hover{background: #297fb8; } @@ -796,7 +796,7 @@ a.talkmain_name{ color:#ff5722;} a:hover.talkmain_name{ color:#d33503;} .talkmain_tit{ color:#0781b4; width:450px; display:block; } .talklist_main{ } -.talkWrapArrow{ display:block; float:right; margin-right:10px;background:url(../images/arrow.png) 0 0 no-repeat; height:7px; width:13px;} +.talkWrapArrow{ display:block; float:right; margin-right:10px;background:url(/images/arrow.png) 0 0 no-repeat; height:7px; width:13px;} .talkConIpt{ background:#f2f2f2; } .talkWrapBox{ width:610px; margin-left:60px; } .inputFeint{ border:1px solid #d9d9d9; background:#fff; width:583px; height:50px; margin:10px; margin-bottom:5px;color:#666;} diff --git a/public/stylesheets/css/structure.css b/public/stylesheets/css/structure.css index b2cba2483..2c0a7a9a1 100644 --- a/public/stylesheets/css/structure.css +++ b/public/stylesheets/css/structure.css @@ -31,8 +31,8 @@ a:hover.search_btn{ background: #0fa9bb;} #userInfo {float:right; display:inline-block; width:130px; padding-top:5px;} .userInfoRow2 {margin-top:-5px;} .myPractice {display:inline-block;} -a.parent {background: url(../images/arrowList.png) -30px 3px no-repeat; width:95px; padding-right:50px;} -a.parent:hover {background: url(../images/arrowList.png) -30px -14px no-repeat; width:95px; padding-right:50px; color:#fe7d68;} +a.parent {background: url(/images/arrowList.png) -30px 3px no-repeat; width:95px; padding-right:50px;} +a.parent:hover {background: url(/images/arrowList.png) -30px -14px no-repeat; width:95px; padding-right:50px; color:#fe7d68;} a.linkToOrange:hover {color:#fe7d68;} #userInfo ul li {positon: relative;} #userInfo ul li ul {display:none;} @@ -62,10 +62,10 @@ div#menu a:hover, div#menu a:hover span { color: #a1ebff; } div#menu li.current a {} div#menu {display: block; cursor: pointer; background-repeat: no-repeat;background-position: 95% 0;padding-right: 15px; _padding-right: 20px;} div#menu ul a.user_name { width:170px; text-align:right; margin:0; } -.pic_triangle{background: url(../images/item.png) -90px -48px no-repeat; float:right; display:block; width:10px; height:10px; margin-top:12px; margin-left:7px;} -.pic_triangle:hover{background: url(../images/item.png) -90px -78px no-repeat; } -div#menu ul ul a.parent {background: url(../images/item.png) -20px 6px no-repeat;width:60px;} -div#menu ul ul a.parent:hover {background: url(../images/item.png) -20px -11px no-repeat;} +.pic_triangle{background: url(/images/item.png) -90px -48px no-repeat; float:right; display:block; width:10px; height:10px; margin-top:12px; margin-left:7px;} +.pic_triangle:hover{background: url(/images/item.png) -90px -78px no-repeat; } +div#menu ul ul a.parent {background: url(/images/item.png) -20px 6px no-repeat;width:60px;} +div#menu ul ul a.parent:hover {background: url(/images/item.png) -20px -11px no-repeat;} /* menu::level1 */ div#menu a { padding: 5px 12px 0 10px;line-height: 30px; color: #fff;} /*div#menu li { background: url(images/main-delimiter.png) 98% 4px no-repeat; }*/ @@ -153,10 +153,10 @@ a.more{ float:right; font-size:12px; font-weight:normal; color:#a9a9a9; margin-t a:hover.more{ color:#64bdd9;} .project_box_ul{ padding:0 10px;} .project_box_list{ padding:10px 0; border-bottom:1px dashed #e2e1e1; padding-left:30px; color:#6f6c6c;} -.img_problem{ background:url(../images/img_project.png) 0 -20px no-repeat;} -.img_talk{ background:url(../images/img_project.png) 0 -62px no-repeat;} -.img_ziyuan{ background:url(../images/img_project.png) 0 -115px no-repeat;} -.img_edition{ background:url(../images/img_project.png) 0 -167px no-repeat;} +.img_problem{ background:url(/images/img_project.png) 0 -20px no-repeat;} +.img_talk{ background:url(/images/img_project.png) 0 -62px no-repeat;} +.img_ziyuan{ background:url(/images/img_project.png) 0 -115px no-repeat;} +.img_edition{ background:url(/images/img_project.png) 0 -167px no-repeat;} a.project_name{ color:#058c42;} a:hover.project_name{ color:#016f33;} a.project_txt{ color:#0781b4; width:445px; display:block; float:left; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} @@ -254,7 +254,7 @@ a.postOptionLink2:hover {color:#ffffff; background-color:#269ac9;} .table_maxWidth table {max-width: 642px;} .homepagePostProjectState {width:52px; height:20px; line-height:20px; border-radius:1px; background-color:#28be6c; color:#ffffff; text-align:center; vertical-align:middle; font-size:12px; display:inline-block; margin-left:5px;} .homepagePostAssignTo {float:left; font-size:14px; color:#269ac9;} -.homepagePostFileAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/public_icon.png) -27px -577px no-repeat; padding-left:25px; font-size:14px;} +.homepagePostFileAtt {height:22px; line-height:22px; vertical-align:middle; background:url(/images/public_icon.png) -27px -577px no-repeat; padding-left:25px; font-size:14px;} .homepagePostImageAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/homepage_icon.png) -86px -195px no-repeat; padding-left:35px; font-size:14px; margin-right:25px;} .postAttSize {color:#888888; font-size:12px; margin-left: 5px;} .homepageSearchIcon {width:30px; height:32px; background:url(/images/nav_icon.png) -8px 3px no-repeat; float:left; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} @@ -267,9 +267,9 @@ a.replyGrey {color:#888888; display:inline-block;} a.replyGrey:hover {color:#4b4b4b;} /*个人主页右部分*/ -a.gz_btn{display:block; background:url(../images/pic_uersall.png) -318px -25px no-repeat; width:53px; height:18px; border:1px solid #cdcdcd; color:#333333; padding:0px 0 0 18px;} +a.gz_btn{display:block; background:url(/images/pic_uersall.png) -318px -25px no-repeat; width:53px; height:18px; border:1px solid #cdcdcd; color:#333333; padding:0px 0 0 18px;} a:hover.gz_btn{ color:#ff5722;} -a.qx_btn{display:block; background:url(../images/pic_uersall.png) -318px -47px no-repeat; width:53px; height:18px; border:1px solid #cdcdcd; color:#333333; padding:0px 0 0 18px;} +a.qx_btn{display:block; background:url(/images/pic_uersall.png) -318px -47px no-repeat; width:53px; height:18px; border:1px solid #cdcdcd; color:#333333; padding:0px 0 0 18px;} a:hover.qx_btn{color:#64bdd9;} .courseMenu {width:30px; display:block; float:right;height: 50px;} @@ -338,7 +338,7 @@ a.homepageMenuControl {float:left; width:180px;} .project_Label_New {width:218px; padding-left:10px; background:#fff; margin-top:15px; margin-bottom:10px;} .homepageLabelText {color:#484848; font-size:16px; margin-left:10px; margin-bottom:12px; display:block;} .homepageRightBanner {width:718px; margin:0px auto; float:right; background-color: #ffffff; padding:10px 15px; border:1px solid #dddddd;} -.homepageRightBannerImg{width:1000px; margin:0px auto; height: 60px; margin-top: 10px; background:url(../images/TeachersDay.jpg)} +.homepageRightBannerImg{width:1000px; margin:0px auto; height: 60px; margin-top: 10px; background:url(/images/TeachersDay.jpg)} a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} a.newsGrey {color:#4b4b4b;} @@ -358,12 +358,12 @@ a.menuGrey:hover {color:#fe7d68;} #navSearchAlert {display:none;} /*151228侧导航样式更新*/ -.menuSetting {background:url(../images/hwork_icon.png) -5px -303px no-repeat; display:inline-block; width:20px; height:20px;} -.praviteC {background:url(../images/hwork_icon.png) -79px -255px no-repeat;} +.menuSetting {background:url(/images/hwork_icon.png) -5px -303px no-repeat; display:inline-block; width:20px; height:20px;} +.praviteC {background:url(/images/hwork_icon.png) -79px -255px no-repeat;} .praviteCP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; left:25px;} -.publicC {background:url(../images/hwork_icon.png) -79px -125px no-repeat;} +.publicC {background:url(/images/hwork_icon.png) -79px -125px no-repeat;} .publicCP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; left:25px;} -.shild {background:url(../images/hwork_icon.png) -6px -354px no-repeat;} +.shild {background:url(/images/hwork_icon.png) -6px -354px no-repeat;} .shildP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; right:0px;} ul.shild:hover li ul {display:block;} .subNavArrow {background:url(/images/hwork_icon.png) -82px -399px no-repeat; display:inline-block; width:20px; height:20px; position:absolute; top:10px; right:0px;} @@ -374,7 +374,7 @@ ul.subNavArrow:hover li ul {display:block;} /*左侧导航*/ .subNavBox{width:240px; background:#fff;margin:10px 10px 0 0;} .subNav{border-bottom:solid 1px #e5e3da;cursor:pointer;font-weight:bold;font-size:14px;color:#3ca5c6; height:26px;padding-left:10px;background-color:#fff; padding-top:2px;} -.subNav_jiantou{background:url(../images/jiantou1.jpg) no-repeat;background-position:95% 50%; background-color:#fff;} +.subNav_jiantou{background:url(/images/jiantou1.jpg) no-repeat;background-position:95% 50%; background-color:#fff;} .subNav_jiantou:hover{color:#0781b4; } .currentDd{color:#0781b4;} .currentDt{background-color:#fff;} @@ -402,8 +402,8 @@ a.greyBtn2 {float:right; text-align:center; font-size:12px; color:#ffffff; backg .users_r_h2{background:#64bdd9; color:#fff; height:33px; width:90px; text-align:center; font-weight:normal; padding-top:7px; font-size:16px;} /*留言*/ -a.icon_face{background:url(../images/public_icon.png) 0px -671px no-repeat; display:block; height:25px; width:40px; padding-left:25px; padding-top:3px; } -a:hover.icon_face{background:url(../images/public_icon.png) -79px -671px no-repeat; } +a.icon_face{background:url(/images/public_icon.png) 0px -671px no-repeat; display:block; height:25px; width:40px; padding-left:25px; padding-top:3px; } +a:hover.icon_face{background:url(/images/public_icon.png) -79px -671px no-repeat; } .inputUsers_message{ border:1px solid #d2d2d2; width:718px; height:48px; color:#666; padding:5px; margin-bottom:5px;} .inputUsers_message02{ border:1px solid #d2d2d2; width:618px; height:26px; color:#666; padding:5px; margin-bottom:5px; } .message_list_box{ background:#f5f5f5; margin-top: 10px;} @@ -435,14 +435,14 @@ a.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;} .uppic_btn:hover {background-color: #329cbd;} /*myctrip*/ -.userImage{position:absolute; right:140px; top:5px; width:30px;height:30px; background: url(../images/item.png) 2px 4px no-repeat; line-height:1.4;} +.userImage{position:absolute; right:140px; top:5px; width:30px;height:30px; background: url(/images/item.png) 2px 4px no-repeat; line-height:1.4;} a.topnav_login_a{color:#fff; display:inline-block;} a.topnav_login_a:hover {color:#a1ebff;} -a.topnav_login_mes{color:#fff; width:10px;height:20px; padding-left:15px; background: url(../images/item.png) -84px -145px no-repeat; display:inline-block; vertical-align:top;} +a.topnav_login_mes{color:#fff; width:10px;height:20px; padding-left:15px; background: url(/images/item.png) -84px -145px no-repeat; display:inline-block; vertical-align:top;} a.topnav_login_mes:hover {color:#a1ebff;} a.topnav_login_box{ color:#fff; font-size:14px; font-weight:bold; width:90px; display:inline-block;} -.menuArrow {background:url(../images/item.png) -20px -40px no-repeat;} -li.menuArrow:hover {background:url(../images/item.png) -20px -70px no-repeat;} +.menuArrow {background:url(/images/item.png) -20px -40px no-repeat;} +li.menuArrow:hover {background:url(/images/item.png) -20px -70px no-repeat;} a.topnav_login_box:hover {color:#a1ebff;} .navRow1 {margin:0; padding:0;} .navRow2 {margin:0; padding:0;} From fe105c84ad55b2b78b82213b44e78d22210b9874 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 21 Jul 2016 10:18:58 +0800 Subject: [PATCH 26/52] =?UTF-8?q?=E5=BC=B9=E6=A1=86=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E6=94=B9=E4=B8=BAfixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/images/arrow.png | Bin 0 -> 281 bytes public/stylesheets/css/popup.css | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 public/images/arrow.png diff --git a/public/images/arrow.png b/public/images/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..2081ddf8d951636a3ab2ab67faed8328935f4858 GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngf!3HGX_Lqf&I0YV&#S9GG!XV7ZFl&wkP*5S+ zBgmJ5p-Pp3p`n?9;pcxK{gQ#9)PRBERRRNp)eHs(@%%~gN8NyG=X<(1hE&|@xv1#J zoG8%tFg^1Ui{Z*!Elb3@T@|Vu6)s@Tkrj$=ReH%-5TUdDhQE2V_o4k8)=Piv znep;i;T5fuQmYQX#*ZF&Y->SF;(rpWm3u=G1dc1MfzFjNr&%ZQc YkchS5p6_T6^acZir>mdKI;Vst0K!par~m)} literal 0 HcmV?d00001 diff --git a/public/stylesheets/css/popup.css b/public/stylesheets/css/popup.css index ae7a1ddf0..ea2034a5e 100644 --- a/public/stylesheets/css/popup.css +++ b/public/stylesheets/css/popup.css @@ -44,7 +44,7 @@ input.sendSourceText:hover {background-color:#297fb8;} .popbox{/* width:300px; *//* height:100px; */position:fixed !important;/* z-index:100; */left:50%;top:50%;margin:-100px 0 0 -150px; /* background:#fff; */ -moz-border-radius:5px; /* -webkit-border-radius:5px; */ /* border-radius:5px; */ /* box-shadow:0px 0px 8px #194a81; */ /* overflow:auto; */} /*上传资源弹窗*/ -.resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} +.resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:fixed; top:50%; left:50%; margin-left:-200px; z-index:1000;} .uploadText {font-size:16px; color:#269ac9; line-height:16px; padding-top:15px; width:140px; display:inline-block;} .uploadDialogText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; width:140px; display:inline-block; font-weight: bold;} .uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;} From 53c515b8d1ac71d5e62b39e3e740cf75b056c781 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 21 Jul 2016 10:28:50 +0800 Subject: [PATCH 27/52] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=A4=A7=E7=BA=B2?= =?UTF-8?q?=E4=BE=A7=E5=AF=BC=E8=88=AAjs=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_syllabus.html.erb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/views/layouts/base_syllabus.html.erb b/app/views/layouts/base_syllabus.html.erb index 45e77dbad..5d26c2ffa 100644 --- a/app/views/layouts/base_syllabus.html.erb +++ b/app/views/layouts/base_syllabus.html.erb @@ -146,6 +146,24 @@ function show_edit_base_info() { $("#syllabus_base_info").html("<%=escape_javascript(render :partial => 'layouts/syllabus_edit_info', :locals => {:syllabus => @syllabus}) %>"); } + + //侧导航栏配置设置 + $(".homepageLeftMenuCoursesLine").mouseover(function(){ + $(this).children(".shild").css("background","url(/images/hwork_icon.png) -82px -399px no-repeat"); + $(this).children().css("color","#ffffff"); + }); + $(".homepageLeftMenuCoursesLine").mouseout(function(){ + $(this).children(".shild").css("background","url(/images/hwork_icon.png) -6px -354px no-repeat"); + $(this).children().css("color","#808080"); + }); + $(".subNavRow").mouseover(function(){ + $(this).css("background-color","#269ac9"); + $(this).children().css("color","#ffffff"); + }); + $(".subNavRow").mouseout(function(){ + $(this).css("background-color","#ffffff"); + $(this).children().css("color","#888888"); + }); From 24ee25e095d162dd451914672a0330803a4ab735 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Jul 2016 13:54:03 +0800 Subject: [PATCH 28/52] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E7=AE=A1=E7=90=86=E8=AF=BE=E7=A8=8B=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=EF=BC=8C=E5=88=97=E8=A1=A8=E5=B1=95=E5=BC=80bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/class_list.html | 10 ++++++---- public/stylesheets/weui/weixin.css | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html index 063e92861..2c3b3b7b9 100644 --- a/public/assets/wechat/class_list.html +++ b/public/assets/wechat/class_list.html @@ -3,8 +3,9 @@
    课程列表
    我创建的课程
    -
    -
    +
    +
    +
    • @@ -17,8 +18,9 @@
    我参与的课程
    -
    -
    +
    +
    +
    • diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index ed3af75ae..364c8a001 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -212,6 +212,7 @@ a.underline {text-decoration:underline;} .new-class-btn {font-size:15px; color:#fff; background-color:#3b94d6; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} .join-class-btn {font-size:15px; color:#444; background-color:#ccc; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} .new-class-input {width:60%; color:#555; height:16px; line-height:16px; vertical-align:middle; border:none; outline:none; padding:10px 0;} +.class-list-setting {position:absolute; top:10px; right:10px;} /*20160616登录注册*/ .login-wrap {padding:0 10px;} From 7cd505ea4bed9102f42fd9563d601591f8167b1f Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Jul 2016 14:03:04 +0800 Subject: [PATCH 29/52] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=8A=A0=E5=85=A5=E4=BA=8C=E7=BA=A7=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E7=9A=84=E5=B1=95=E5=BC=80=E5=8A=9F=E8=83=BD=E4=B8=80?= =?UTF-8?q?=E7=BA=A7=E4=B8=80=E7=BA=A7=E5=9B=9E=E5=A4=8D=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/blog_comment.rb | 61 ++++++++++----- app/controllers/wechats_controller.rb | 4 +- app/services/syllabuses_service.rb | 4 +- public/assets/wechat/blog_detail.html | 74 ++++++++++++++++++- public/assets/wechat/edit_class.html | 4 +- public/assets/wechat/new_class.html | 4 +- public/assets/wechat/send_class_list.html | 2 +- public/javascripts/wechat/controllers/blog.js | 18 +++-- public/javascripts/wechat/others/factory.js | 11 ++- public/stylesheets/weui/weixin.css | 2 +- 10 files changed, 141 insertions(+), 43 deletions(-) diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index cd7902097..3f58e901f 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -75,14 +75,27 @@ module Mobile has_praise end + expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options| + parents_reply = [] + parents_reply = get_reply_parents_no_root(parents_reply, instance) + parents_reply.count + end + expose :parents_reply_bottom, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) #取二级回复的底楼层 - if (opt[:type] == 1 && !opt[:bottom]) - opt[:bottom] = true - parents_reply = [] - parents_reply = c.parent.nil? ? [] : parents_reply << c.parent #get_reply_parents_no_root(parents_reply, c)[0] - parents_reply + parents_reply = [] + parents_reply = get_reply_parents_no_root(parents_reply, c) + if parents_reply.count > 0 && !opt[:bottom] + if opt[:type] == 1 + # opt[:bottom] = true + # parents_reply[opt[:page]..opt[:page]] + else + opt[:bottom] = true + parents_reply[0..0] + end + else + [] end end end @@ -90,26 +103,34 @@ module Mobile expose :parents_reply_top, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) #取二级回复的顶楼层 - if (opt[:type] == 1 && !opt[:top]) - opt[:top] = true + parents_reply = [] + parents_reply = get_reply_parents_no_root(parents_reply, c) + if parents_reply.count > 0 && !opt[:top] + if opt[:type] == 1 + opt[:bottom] = true + tStart = (opt[:page]-1)*5+2 + tEnd = (opt[:page])*5+2 - 1 - parents_reply = [] - parents_reply = get_reply_parents_no_root(parents_reply, c) - - tStart = opt[:page]*2 - tEnd = (opt[:page]+1)*2 - 1 + if tEnd >= parents_reply.count - 1 + tEnd = parents_reply.count - 2 + end - parents_reply = parents_reply.reverse[tStart,tEnd] - parents_reply + if tStart <= parents_reply.count - 2 + parents_reply = parents_reply.reverse[tStart..tEnd] + parents_reply.reverse + else + [] + end + else + opt[:top] = true + parents_reply = parents_reply.reverse[0..1] + parents_reply.reverse + end + else + [] end end end - - expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options| - parents_reply = [] - parents_reply = get_reply_parents_no_root(parents_reply, instance) - parents_reply.count - end end end end \ No newline at end of file diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index c72e04e14..e596042d9 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -221,8 +221,8 @@ class WechatsController < ActionController::Base raise CoursesService::JoinCourseError.message(status[:state]) end - news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!', - content: "课程名称: #{course.name}\n班级名称: #{course.name}\n任课老师: #{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} } + news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!', + content: "课程名称:#{course.name}\n班级名称:#{course.name}\n任课老师:#{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} } return request.reply.news(news) do |article, n, index| # article is return object url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/class?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect" pic_url = "#{ROOT_URL}/images/wechat/class.jpg" diff --git a/app/services/syllabuses_service.rb b/app/services/syllabuses_service.rb index d5dec9f88..fcb70653b 100644 --- a/app/services/syllabuses_service.rb +++ b/app/services/syllabuses_service.rb @@ -71,8 +71,8 @@ class SyllabusesService count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count if count == 0 ws = WechatService.new - title = "恭喜您创建班级成功" - ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情" + title = "恭喜您创建班级成功。" + ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情。" end end diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index aabea2532..d18575b94 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -42,11 +42,61 @@
    {{journal.lasted_comment}}
    -
    -
    + +
    + +
    +
      +
      + +
      {{journal.parents_reply_top[0].lasted_comment}}
      +
      +
      +
      +
      + + + + + + + + + + + + + +
      点击展开更多楼层
      + +
      +
      + +
      {{reply_bottom.lasted_comment}}
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      - +
      +
      更多
      +
      @@ -63,4 +113,20 @@
      -
    \ No newline at end of file +
    + + \ No newline at end of file diff --git a/public/assets/wechat/edit_class.html b/public/assets/wechat/edit_class.html index d6bc7e03c..62022566b 100644 --- a/public/assets/wechat/edit_class.html +++ b/public/assets/wechat/edit_class.html @@ -3,9 +3,9 @@
    管理课程
    -
    课程
    +
    课程
    -
    班级删除
    +
    班级删除
    完成
    diff --git a/public/assets/wechat/new_class.html b/public/assets/wechat/new_class.html index 039d19d75..5ce75d358 100644 --- a/public/assets/wechat/new_class.html +++ b/public/assets/wechat/new_class.html @@ -3,9 +3,9 @@
    新建课程
    -
    课程
    +
    课程
    -
    班级删除
    +
    班级删除
    完成
    diff --git a/public/assets/wechat/send_class_list.html b/public/assets/wechat/send_class_list.html index b66b5008d..68a9d1ae5 100644 --- a/public/assets/wechat/send_class_list.html +++ b/public/assets/wechat/send_class_list.html @@ -19,6 +19,6 @@ -
    发送
    +
    发送
    diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js index dc9f4bf39..40902fa12 100644 --- a/public/javascripts/wechat/controllers/blog.js +++ b/public/javascripts/wechat/controllers/blog.js @@ -9,12 +9,15 @@ app.controller('BlogController', replyType: 'BlogComment', loadCallback: function(data){ console.log(data.data); + + //回复级别 0 一级回复 1 二级回复 replytype = data.type; page = data.page; if (replytype == 0){ if (page == 0){ $scope.blog = data.data; + $scope.page = 0; } else{ $scope.blog.blog_comment_children = $scope.blog.blog_comment_children.concat(data.data.blog_comment_children); @@ -23,13 +26,14 @@ app.controller('BlogController', console.log($scope.has_more); } else{ - - - - - - - + comment_id = data.data.id; + for (var i in $scope.blog.blog_comment_children) { + var comment = $scope.blog.blog_comment_children[i]; + if(comment.id == comment_id){ +// comment.parents_reply_top = comment.parents_reply_top.concat(data.data.parents_reply_top); + comment.parents_reply_top = data.data.parents_reply_top.concat(comment.parents_reply_top); + } + } } }, replyCallback: function(){ diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index dcd78740f..a329c2906 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -254,8 +254,15 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au decreaseCommonPraise(act); }; - args.scope.morereply = function(data,replytype,page){ - loadCommonData(data.id, args.type,replytype,page).then(function successCallback(response) { + args.scope.showMoreReply = function(replytype,data){ + if(!data.page){ + data.page = 1; + } + else{ + data.page = data.page + 1; + } + + loadCommonData(data.id, args.type,replytype,data.page).then(function successCallback(response) { args.loadCallback(response.data); }, function errorCallback(response) { }); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index ed3af75ae..cdac0d1a3 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -225,7 +225,7 @@ a.underline {text-decoration:underline;} .forget-psw {position:fixed; bottom:10px;} /*二级回复*/ -.mult-reply-container{ border:solid 1px #f3ddb3; background:#fffef4; padding:4px;color:#999; margin-top:-1px;} +.mult-reply-container{ border:solid 1px #f3ddb3; background:#fffef4; padding:4px;color:#999;} .mult-reply-content{ color:#707070; font-size:13px;} .mult-reply-hide{ text-align:center; display:block; font-size:14px; color:#aaa; border-bottom:1px solid #F3DDB3; padding:8px 0;} .mult-reply-arrow{ color:#aaa; margin-right:10px; font-size:14px; font-weight:bold;} \ No newline at end of file From 86731c34d5f00f6b810620f252d3d834d2e44e7b Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Jul 2016 15:21:09 +0800 Subject: [PATCH 30/52] =?UTF-8?q?=E5=8D=95=E4=B8=AA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84BUG?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=8A=A0=E5=85=A5=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E6=97=B6=E5=A6=82=E6=9E=9C=E7=8F=AD=E7=BA=A7=E5=B7=B2=E8=A2=AB?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=9C=80=E8=A6=81=E6=8F=90=E7=A4=BA!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/homework.rb | 11 ++++++----- app/controllers/wechats_controller.rb | 2 +- app/services/courses_service.rb | 5 ++++- app/services/wechat_service.rb | 2 +- public/javascripts/wechat/controllers/class_list.js | 5 ++--- .../javascripts/wechat/controllers/send_class_list.js | 10 +++++++++- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index cea15ece9..a5b981c6d 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -99,12 +99,13 @@ module Mobile homework_expose :coursename #所属班级名 expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| - current_user = options[:user] - current_user_is_teacher = false - current_user_is_teacher = is_course_teacher(current_user,instance.course) - current_user_is_teacher + if instance[:current_user_is_teacher].nil? + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end end - end end end \ No newline at end of file diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index e596042d9..6b1e3010d 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -277,7 +277,7 @@ class WechatsController < ActionController::Base user: user ) ws = WechatService.new - ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now)) + ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台!", user.login, format_time(Time.now)) render :json => {status:0, msg: "绑定成功"} rescue Exception=>e render :json => {status: -1, msg: e.message} diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 091e2749e..ab4b65f5c 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -335,6 +335,7 @@ class CoursesService 8, '您已经是该班级的教师了', 9, '您已经是该班级的教辅了', 10, '您已经是该班级的管理员了', + 11, '该班级不存在或已被删除啦', '未知错误,请稍后再试' ] end @@ -348,6 +349,8 @@ class CoursesService if course if course_endTime_timeout? course @state = 2 + elsif course[:is_delete] == 1 + @state = 11 else if current_user.member_of_course?(course) #如果已经是成员 member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0] @@ -632,7 +635,7 @@ class CoursesService :homework_submit_num => bid.student_works.count, :homework_status_student => get_homework_status( bid),:homework_status_teacher => homework_status_desc( bid), :student_evaluation_part => get_evaluation_part( bid ,3), - :ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?} + :ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?,:current_user_is_teacher => is_course_teacher} end diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb index 2da942ea6..7ac4e99d3 100644 --- a/app/services/wechat_service.rb +++ b/app/services/wechat_service.rb @@ -229,7 +229,7 @@ class WechatService color:"#707070" }, remark:{ - value:"绑定成功后可使用微信查看Trustie平台最新动态", + value:"绑定成功后可使用微信查看Trustie平台最新动态。", color:"#707070" } } diff --git a/public/javascripts/wechat/controllers/class_list.js b/public/javascripts/wechat/controllers/class_list.js index 9e0087135..488d1913c 100644 --- a/public/javascripts/wechat/controllers/class_list.js +++ b/public/javascripts/wechat/controllers/class_list.js @@ -59,7 +59,7 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo }).then(function (response) { console.log(response.data); if (response.data.status != 0) { - vm.alertService_1.showMessage('错误', response.data.message); + vm.alertService_1.showMessage('提示', response.data.message); } else { vm.alertService_1.showMessage('提示', '加入课程成功'); vm.alertService_3.invite = ""; @@ -68,9 +68,8 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo }); } else { if(vm.alertService_3.invite){ - vm.alertService_1.showMessage('错误', '邀请码格式不正确'); + vm.alertService_1.showMessage('提示', '邀请码格式不正确'); } - } }); }; diff --git a/public/javascripts/wechat/controllers/send_class_list.js b/public/javascripts/wechat/controllers/send_class_list.js index 1eabfa94c..eee462ee3 100644 --- a/public/javascripts/wechat/controllers/send_class_list.js +++ b/public/javascripts/wechat/controllers/send_class_list.js @@ -46,7 +46,15 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co }).then(function(response){ console.log(response.data); if(response.data.status == 0){ - vm.alertService.showMessage('发送成功', '题目已发送到目标班级的作业列表,但需要您访问Trustie网站设置发布和截止时间,以激活相应作业,谢谢!', function () { + var tip = ""; + if (vm.myresource_sendIndex == 1){ + tip = "课件已发送到目标班级。"; + } + else if(vm.myresource_sendIndex == 2){ + tip = "题目已发送到目标班级的作业列表,但需要您访问Trustie网站设置发布和截止时间,以激活相应作业,谢谢。"; + } + + vm.alertService.showMessage('发送成功', tip, function () { window.history.back(); }); } else { From 0a0f8aefac6bf138e4411ba19a88e928d7b1ca2e Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Jul 2016 15:56:27 +0800 Subject: [PATCH 31/52] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E5=BC=B9=E6=A1=86css=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=EF=BC=9Bapp=E9=A1=B5=E9=9D=A2meta=E6=A0=87=E7=AD=BE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/app.html | 4 ++-- public/stylesheets/weui/weixin.css | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index a3977ec5c..726755c3d 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -6,9 +6,9 @@ - + - + diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 364c8a001..2172911ce 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -155,7 +155,7 @@ a.underline {text-decoration:underline;} .locked_btn_cir {background: url("/images/wechat/locked.png") 0 0 no-repeat; cursor: default;} /*20150612加入班级样式*/ -.add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%);} +.add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%); -ms-transform: translate(-50%,-50%); -moz-transform: translate(-50%,-50%); -webkit-transform: translate(-50%,-50%); -o-transform: translate(-50%,-50%);} .add-class-tip {padding-top:1.2em; padding-bottom:.5em; font-weight:400;} .class-number-input {width:80%; max-width:240px; height:28px; border:1px solid #ccc; padding-left:5px; margin:0 auto; display:block;} .cancel-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} From 3fb5322b0318025bfebf0a985390ad1ccb0ff4ee Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 16:08:13 +0800 Subject: [PATCH 32/52] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/gitlab_act_project.rake | 11 ++++++++--- lib/tasks/gitlab_unused.rake | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 142d5bf89..7ef336689 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -2,8 +2,7 @@ namespace :gitlab do desc "sync gitlab's commit acts to trustie" task :forge_acts => :environment do g = Gitlab.client - # projects = Project.find_by_sql("select * from projects where gpid is not null") - projects = Project.find_by_sql("select * from projects where gpid is not null and id > 265") + projects = Project.find_by_sql("select * from projects where gpid is not null and id not in (2,847,931,942)") projects.each do |project| begin g_project = g.project(project.gpid) @@ -14,13 +13,19 @@ namespace :gitlab do pages = commit_count / 20 + 1 puts "#{pages}" puts "project id is #{project.id}" + # api获取每次只能获取20次提交,所以需要通过取得page值来获取每页的提交动态 (0..pages).each do |page| commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| - Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at, :type => true) + result = Commit.create(:project_id => project.id, :repository_id => project.gpid, :version => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) + puts "result is #{result}" end end rescue Exception => e + # puts "Some wrong with project #{project.id}" + # Project.where(:id => project.id).first.update_column(:gpid, nil) + # Repository.where(:project_id => project.id).first.destroy + # try puts e end end diff --git a/lib/tasks/gitlab_unused.rake b/lib/tasks/gitlab_unused.rake index 0b90d9352..4b81acbff 100644 --- a/lib/tasks/gitlab_unused.rake +++ b/lib/tasks/gitlab_unused.rake @@ -3,7 +3,14 @@ namespace :gitlab do task :unused => :environment do begin Project.where("id in (161,236,266)").update_all(:gpid => nil) - Repository.where("project_id in (161,236,266)").destroy_all + repositories = Repository.find_by_sql("select * from repositories where project_id in (select project_id from repositories group by project_id having count(project_id) > 1);") + repositories.each do |rep| + puts "#{rep.id}" + if rep.type == "Repository::Git" + rep.destroy + end + end + # Repository.where("project_id in (161,236,266)").destroy_all rescue Exception => e puts e end From 246923a335dac8163d2085dc6cd7576dbb809828 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 16:09:07 +0800 Subject: [PATCH 33/52] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=8F=90=E4=BA=A4=E6=AC=A1=E6=95=B0=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=B3=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/commit.rb | 10 ++++++++++ db/migrate/20160721075236_create_commits.rb | 14 ++++++++++++++ spec/factories/commits.rb | 11 +++++++++++ spec/models/commit_spec.rb | 5 +++++ 4 files changed, 40 insertions(+) create mode 100644 app/models/commit.rb create mode 100644 db/migrate/20160721075236_create_commits.rb create mode 100644 spec/factories/commits.rb create mode 100644 spec/models/commit_spec.rb diff --git a/app/models/commit.rb b/app/models/commit.rb new file mode 100644 index 000000000..246b8be0c --- /dev/null +++ b/app/models/commit.rb @@ -0,0 +1,10 @@ +class Commit < ActiveRecord::Base + attr_accessible :comments, :committed_on, :committer, :project_id, :repository_id, :version + has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + after_create :act_as_forge_activity + + # 项目中提交动态 + def act_as_forge_activity + self.forge_acts << ForgeActivity.new(:user_id => 2, :project_id => self.project_id) + end +end diff --git a/db/migrate/20160721075236_create_commits.rb b/db/migrate/20160721075236_create_commits.rb new file mode 100644 index 000000000..5482c10c5 --- /dev/null +++ b/db/migrate/20160721075236_create_commits.rb @@ -0,0 +1,14 @@ +class CreateCommits < ActiveRecord::Migration + def change + create_table :commits do |t| + t.integer :repository_id + t.string :version + t.string :committer + t.text :comments + t.date :committed_on + t.integer :project_id + + t.timestamps + end + end +end diff --git a/spec/factories/commits.rb b/spec/factories/commits.rb new file mode 100644 index 000000000..c520e8b64 --- /dev/null +++ b/spec/factories/commits.rb @@ -0,0 +1,11 @@ +FactoryGirl.define do + factory :commit do + repository_id 1 +version "MyString" +committer "MyString" +comments "MyText" +committed_on "2016-07-21" +project_id 1 + end + +end diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb new file mode 100644 index 000000000..546996270 --- /dev/null +++ b/spec/models/commit_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Commit, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 472eb4736ef897a7f0ab036397a71f1594a8d2ec Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 16:17:40 +0800 Subject: [PATCH 34/52] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20160721075236_create_commits.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20160721075236_create_commits.rb b/db/migrate/20160721075236_create_commits.rb index 5482c10c5..555bf72f1 100644 --- a/db/migrate/20160721075236_create_commits.rb +++ b/db/migrate/20160721075236_create_commits.rb @@ -5,7 +5,7 @@ class CreateCommits < ActiveRecord::Migration t.string :version t.string :committer t.text :comments - t.date :committed_on + t.datetime :committed_on t.integer :project_id t.timestamps From 00c3e880e635f87a83f819c6aff660049c0f0ee8 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Jul 2016 16:21:00 +0800 Subject: [PATCH 35/52] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=BF=94=E5=9B=9E=E5=AE=9A=E4=BD=8Djs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/controllers/activity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/controllers/activity.js b/public/javascripts/wechat/controllers/activity.js index 1ad4b9c1e..8847e8e10 100644 --- a/public/javascripts/wechat/controllers/activity.js +++ b/public/javascripts/wechat/controllers/activity.js @@ -136,7 +136,7 @@ app.controller('ActivityController', //跳到详情页 $scope.goDetail = function(type, act_id,id){ - rms.save("yoffset", window.document.body.scrollTop); + rms.save("yoffset", document.documentElement.scrollTop); rms.save("activities",$scope.activities); rms.save("course_activities",$scope.course_activities); rms.save("project_activities",$scope.project_activities); From 5a8f1b3d835d136cc9eb100cbeb73aed900194fc Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Jul 2016 16:50:15 +0800 Subject: [PATCH 36/52] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E5=90=8E=E8=BF=94=E5=9B=9E=E5=85=AC=E4=BC=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/controllers/login.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/javascripts/wechat/controllers/login.js b/public/javascripts/wechat/controllers/login.js index 1dbf804ed..f31dd629f 100644 --- a/public/javascripts/wechat/controllers/login.js +++ b/public/javascripts/wechat/controllers/login.js @@ -33,7 +33,8 @@ app.controller('LoginController', ['$scope', '$http', '$location', '$routeParams vm.loginFailed = (response.data.status != 0); if (!$scope.loginFailed) { //绑定成功 vm.alertService.showMessage('提示', response.data.message, function(){ - $location.path("/activities"); +// $location.path("/activities"); + window.WeixinJSBridge.call('closeWindow'); }); } else { vm.alertService.showMessage('出错了', response.data.message); From 0622978920191d956ddffacf01728af0c2b7940d Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Jul 2016 16:59:47 +0800 Subject: [PATCH 37/52] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=B3=A8=E5=86=8C=E5=90=8E=E8=BF=94=E5=9B=9E=E5=85=AC?= =?UTF-8?q?=E4=BC=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/controllers/reg.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/javascripts/wechat/controllers/reg.js b/public/javascripts/wechat/controllers/reg.js index 44c2e098b..9600e9dbf 100644 --- a/public/javascripts/wechat/controllers/reg.js +++ b/public/javascripts/wechat/controllers/reg.js @@ -34,7 +34,8 @@ app.controller('RegController', ['$scope', '$http', '$location', 'alertService', vm.errDialog.showMessage('出错了',response.data.message); } else { vm.successDialog.showMessage("提示","注册且绑定微信成功", function(){ - $location.path("/activities"); +// $location.path("/activities"); + window.WeixinJSBridge.call('closeWindow'); }); } }, function (response) { From 466a25c1215a09e587d2eff40d08883e38148ccd Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 17:02:50 +0800 Subject: [PATCH 38/52] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=90=8E=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81=E8=A1=A8update?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/forge_activity.rb | 9 +++++++-- lib/tasks/gitlab_act_project.rake | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 47ebf4d0f..5fe953f66 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -25,8 +25,11 @@ class ForgeActivity < ActiveRecord::Base # 在个人动态里面增加当前动态 # 版本库提交动态不显示在用户动态中 + # Commit为版本库提交类型,因为是从gitlab获取,不能实时更新 def add_user_activity - if self.forge_act_type != "Changeset" + if self.forge_act_type == "Commit" + self.update_column(:updated_at, self.forge_act.committed_on) + else user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'").first if user_activity user_activity.save @@ -50,7 +53,9 @@ class ForgeActivity < ActiveRecord::Base # 项目提交动态不显示在组织动态中 def add_org_activity - if self.forge_act_type != "Changeset" + if self.forge_act_type == "Commit" + self.update_column(:updated_at, self.forge_act.committed_on) + else org_activity = OrgActivity.where("org_act_type = '#{self.forge_act_type.to_s}' and org_act_id = #{self.forge_act_id}").first if org_activity org_activity.updated_at = self.updated_at diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 7ef336689..4ef4c4117 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -18,7 +18,6 @@ namespace :gitlab do commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| result = Commit.create(:project_id => project.id, :repository_id => project.gpid, :version => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) - puts "result is #{result}" end end rescue Exception => e From 8fd915bf1a7e73ea9bd06373cc8fa741ad1fb020 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Jul 2016 17:18:09 +0800 Subject: [PATCH 39/52] =?UTF-8?q?issue=E6=A0=87=E9=A2=98=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index cb1696dbf..154355ebd 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -160,7 +160,7 @@
    {{act.latest_update}}
    - +
    状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
    From 4e4ff4958f135ce1e11d09196e28988a560e836f Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 17:19:45 +0800 Subject: [PATCH 40/52] =?UTF-8?q?=E4=BF=AE=E6=94=B9changeset=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/changeset.rb | 3 +-- db/migrate/20160718064146_add_type_to_changeset.rb | 6 ------ lib/tasks/gitlab_act_project.rake | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 db/migrate/20160718064146_add_type_to_changeset.rb diff --git a/app/models/changeset.rb b/app/models/changeset.rb index a9c3687a1..149f4b163 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -57,7 +57,6 @@ class Changeset < ActiveRecord::Base validates :committed_on, presence: true validates :commit_date, presence: true validates :scmid, uniqueness: {scope: :repository_id, allow_nil: true} - attr_accessible :type, :project_id, :repository_id, :revision, :committer, :comments, :committed_on scope :visible, lambda {|*args| includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args)) } @@ -66,7 +65,7 @@ class Changeset < ActiveRecord::Base # after_update :be_user_score after_destroy :down_user_score # before_create :before_create_cs - after_create :act_as_forge_activity + # after_create :act_as_forge_activity def revision=(r) diff --git a/db/migrate/20160718064146_add_type_to_changeset.rb b/db/migrate/20160718064146_add_type_to_changeset.rb deleted file mode 100644 index 4d51883a1..000000000 --- a/db/migrate/20160718064146_add_type_to_changeset.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTypeToChangeset < ActiveRecord::Migration - def change - add_column :changesets, :project_id, :integer - add_column :changesets, :type, :integer, :default => false - end -end diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 4ef4c4117..c4854db58 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -17,7 +17,7 @@ namespace :gitlab do (0..pages).each do |page| commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| - result = Commit.create(:project_id => project.id, :repository_id => project.gpid, :version => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) + Commit.create(:project_id => project.id, :repository_id => project.gpid, :version => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) end end rescue Exception => e From 080b2ac2fa5903f9744ddbd016d986973aec81ff Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 21 Jul 2016 17:21:02 +0800 Subject: [PATCH 41/52] =?UTF-8?q?=E5=85=BC=E5=AE=B9ruby2.3.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb index 06d661478..a26980c40 100644 --- a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb +++ b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb @@ -10,7 +10,11 @@ module Redmine def acts_as_watchable(options = {}) return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods) class_eval do - has_many :watchers, :as => :watchable, :dependent => :delete_all + if self.name == 'User' + has_many :watchers, :dependent => :delete_all + else + has_many :watchers, :as => :watchable, :dependent => :delete_all + end has_many :watcher_users, :through => :watchers, :source => :user, :validate => false scope :watched_by, lambda { |user_id| From 19781ded4e6e3909af03a83ef7f56ec083211abd Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Jul 2016 17:22:03 +0800 Subject: [PATCH 42/52] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86padding?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/weui/weixin.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index b59b00b58..c3a38415a 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -211,7 +211,7 @@ a.underline {text-decoration:underline;} .students-amount {height:14px; line-height:14px; vertical-align:middle; padding:2px 5px; background-color:#e6e6e6; border-radius:10px;} .new-class-btn {font-size:15px; color:#fff; background-color:#3b94d6; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} .join-class-btn {font-size:15px; color:#444; background-color:#ccc; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} -.new-class-input {width:60%; color:#555; height:16px; line-height:16px; vertical-align:middle; border:none; outline:none; padding:10px 0;} +.new-class-input {width:60%; color:#555; height:16px; line-height:16px; vertical-align:middle; border:none; outline:none; padding:8px 0;} .class-list-setting {position:absolute; top:10px; right:10px;} /*20160616登录注册*/ From b638f9aea6549c25a3e3b5391960c1686eb5cdad Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Jul 2016 17:33:20 +0800 Subject: [PATCH 43/52] =?UTF-8?q?tab=E9=A1=B5issue=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 154355ebd..c2df0c8e7 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -467,7 +467,7 @@
    {{act.latest_update}}
    - +
    状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
    From 16fef58885070c352efdeecb8fe14425bd82b89a Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Jul 2016 17:37:03 +0800 Subject: [PATCH 44/52] =?UTF-8?q?=E5=8F=91=E9=80=81=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=B2=A1=E7=8F=AD?= =?UTF-8?q?=E7=BA=A7=E7=9A=84=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/send_class_list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/wechat/send_class_list.html b/public/assets/wechat/send_class_list.html index 68a9d1ae5..72a52fc3f 100644 --- a/public/assets/wechat/send_class_list.html +++ b/public/assets/wechat/send_class_list.html @@ -5,7 +5,7 @@
    请选择要发送的班级
    -
    +
    {{syllabus.title}}
    • From d975067e13d2e1b69cef66b2d8e35d84983102e6 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Jul 2016 17:52:52 +0800 Subject: [PATCH 45/52] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=AD=A3=E5=BC=8F?= =?UTF-8?q?=E7=89=88=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 6 +++--- config/wechat.yml | 40 ++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/config/menu.yml b/config/menu.yml index 0acb58b96..cc799b531 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,14 +2,14 @@ button: - type: "view" name: "我的动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" - name: "我的群组" sub_button: - type: "view" name: "我的课程" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" - type: "click" name: "我的项目" @@ -17,7 +17,7 @@ button: - type: "view" name: "我的宝库" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" - name: "更多" diff --git a/config/wechat.yml b/config/wechat.yml index 8b2caffc8..b8bf670a1 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -8,38 +8,38 @@ default: &default #secret: "743e038392f1d89540e95f8f7645849a" #production -# appid: "wx8e1ab05163a28e37" -# secret: "beb4d3bc4b32b3557811680835357841" + appid: "wx8e1ab05163a28e37" + secret: "beb4d3bc4b32b3557811680835357841" #test - appid: "wxc09454f171153c2d" - secret: "dff5b606e34dcafe24163ec82c2715f8" +# appid: "wxc09454f171153c2d" +# secret: "dff5b606e34dcafe24163ec82c2715f8" token: "123456" access_token: "1234567" encrypt_mode: false # if true must fill encoding_aes_key #production -# encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw" -# jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" + encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw" + jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" # # #template -# binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc" -# journal_notice: "uC1zAw4F2q6HTA3Pcj8VUO6wKKKiYFwnPJB4iXxpdoM" -# homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps" -# class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA" -# create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw" + binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc" + journal_notice: "uC1zAw4F2q6HTA3Pcj8VUO6wKKKiYFwnPJB4iXxpdoM" + homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps" + class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA" + create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw" #test - encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" - jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" - - #template - binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU" - journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE" - homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" - class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" - create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I" +# encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" +# jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" +# +# #template +# binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU" +# journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE" +# homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" +# class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" +# create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I" production: <<: *default From ff8cad5cf20dfbf5c6133cdad06961abb8577943 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 18:08:13 +0800 Subject: [PATCH 46/52] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E6=8F=90=E4=BA=A4=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 4 +-- app/helpers/application_helper.rb | 6 ++++ .../projects/_project_activities.html.erb | 19 ++----------- app/views/projects/_project_commit.html.erb | 28 +++++++++++++++++++ 4 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 app/views/projects/_project_commit.html.erb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f3ba6f76c..d8c174bc3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -306,7 +306,7 @@ class ProjectsController < ApplicationController if User.current.member_of?(@project) || User.current.admin? case params[:type] when nil - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'Project', 'Attachment')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'Project', 'Attachment','Commit')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) when 'issue' @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) when 'news' @@ -320,7 +320,7 @@ class ProjectsController < ApplicationController @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10); end - # g = Gitlab.client + # 版本库统计图 unless @project.gpid.nil? || @project.project_score.changeset_num == 0 # rep_statics_commit = @project.rep_statics.order("commits_num desc") rep_statics_commit = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by commits_num desc limit 10") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 42a3491fb..8a871e2ea 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -38,6 +38,12 @@ module ApplicationHelper # super # end + # 通过系统外部邮箱查找用户,如果用户不存在则用邮箱替换 + def get_user_by_mail mail + user = User.find_by_mail(mail) + user.nil? ? User.find(2) : user + end + # 获取用户单位 # 优先获取高校信息,如果改信息不存在则获取occupation def get_occupation_from_user user diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index 6322a532a..658f9f4f0 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -72,23 +72,8 @@ <% when "Attachment" %> <%= render :partial => 'users/project_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> - - - - - - - - - <%#= link_to format_activity_title("#{l(:label_attachment)}: #{act.filename}"), {:controller => 'attachments', :action => 'show', :id => act.id}, :class => "problem_tit fl fb" %> - - - - - - - - + <% when "Commit" %> + <%= render :partial => 'projects/project_commit', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> <% end %> <% end %> <% end %> diff --git a/app/views/projects/_project_commit.html.erb b/app/views/projects/_project_commit.html.erb new file mode 100644 index 000000000..99998e6e1 --- /dev/null +++ b/app/views/projects/_project_commit.html.erb @@ -0,0 +1,28 @@ +<% project = Project.find(activity.project_id) %> +<% user = get_user_by_mail(activity.committer) %> +
      +
      +
      + <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_path(user), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => user} %> +
      +
      +
      + <% if user.try(:realname) == ' ' %> + <%= link_to user, user_path(user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to user.try(:realname), user_path(user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to project.to_s+" | 项目代码提交", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> +
      +
      + <%= link_to activity.comments, {:controller => 'repositories', :action => 'commit_diff', :id => project.id, :changeset => activity.version}, :class => "postGrey" %> +
      +
      + 提交时间:<%= format_time(activity.committed_on) %> +
      +
      +
      +
      +
      From 2381a78e1bca53cb48d764545d539c5bba185233 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Jul 2016 10:23:12 +0800 Subject: [PATCH 47/52] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E6=AF=94=E8=BE=83=E5=A4=9A=E7=9A=84=E9=A1=B9=E7=9B=AE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/gitlab_forge_acts_update.rake | 32 +++++++++++++++++++ lib/tasks/gitlab_trustie_acts.rake | 41 +++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 lib/tasks/gitlab_forge_acts_update.rake create mode 100644 lib/tasks/gitlab_trustie_acts.rake diff --git a/lib/tasks/gitlab_forge_acts_update.rake b/lib/tasks/gitlab_forge_acts_update.rake new file mode 100644 index 000000000..2248f3b87 --- /dev/null +++ b/lib/tasks/gitlab_forge_acts_update.rake @@ -0,0 +1,32 @@ +namespace :gitlab do + desc "sync gitlab's commit acts to trustie" + task :forge_acts_update => :environment do + g = Gitlab.client + ids = [2,847,931,942] + projects = Project.find(ids) + projects.each do |project| + c = Commit.where(:project_id => project.id) + if c.blank? + begin + g_project = g.project(project.gpid) + # 获取默认分支 + g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch + # 总的提交次数 + commit_count = g.user_static(project.gpid, :rev => g_default_branch).count + pages = commit_count / 20 + 1 + puts "#{pages}" + puts "project id is #{project.id}" + # api获取每次只能获取20次提交,所以需要通过取得page值来获取每页的提交动态 + (0..pages).each do |page| + commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) + commits.each do |commit| + Commit.create(:project_id => project.id, :repository_id => project.gpid, :version => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) + end + end + rescue Exception => e + puts e + end + end + end + end +end diff --git a/lib/tasks/gitlab_trustie_acts.rake b/lib/tasks/gitlab_trustie_acts.rake new file mode 100644 index 000000000..8c3568397 --- /dev/null +++ b/lib/tasks/gitlab_trustie_acts.rake @@ -0,0 +1,41 @@ +namespace :gitlab do + desc "sync gitlab's commit acts to trustie" + task :acts_to_trustie => :environment do + begin + projects = Project.where(:status => 1) + projects.each do |project| + c = Commit.find_by_sql("SELECT * FROM `commits` where project_id = #{project.id} order by committed_on limit 1;") + g_project = g.project(project.gpid) + end + rescue Exception => e + puts e + end + g = Gitlab.client + ids = [2,847,931,942] + projects = Project.find(ids) + projects.each do |project| + c = Commit.where(:project_id => project.id) + if c.blank? + begin + g_project = g.project(project.gpid) + # 获取默认分支 + g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch + # 总的提交次数 + commit_count = g.user_static(project.gpid, :rev => g_default_branch).count + pages = commit_count / 20 + 1 + puts "#{pages}" + puts "project id is #{project.id}" + # api获取每次只能获取20次提交,所以需要通过取得page值来获取每页的提交动态 + (0..pages).each do |page| + commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) + commits.each do |commit| + Commit.create(:project_id => project.id, :repository_id => project.gpid, :version => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) + end + end + rescue Exception => e + puts e + end + end + end + end +end From 537cc20e06754a7e04196de3674c53a72629009b Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Jul 2016 10:34:59 +0800 Subject: [PATCH 48/52] =?UTF-8?q?=E5=B7=B2repository=5Fid=E4=B8=BA?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=EF=BC=8Cversion=E5=94=AF=E4=B8=80=E6=80=A7?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/commit.rb | 3 +++ lib/tasks/gitlab_forge_acts_update.rake | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/commit.rb b/app/models/commit.rb index 246b8be0c..a6633206a 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -1,5 +1,8 @@ class Commit < ActiveRecord::Base attr_accessible :comments, :committed_on, :committer, :project_id, :repository_id, :version + validates :repository_id, presence: true + validates :version, presence: true, uniqueness: {scope: :repository_id} + validates :committed_on, presence: true has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy after_create :act_as_forge_activity diff --git a/lib/tasks/gitlab_forge_acts_update.rake b/lib/tasks/gitlab_forge_acts_update.rake index 2248f3b87..4d8e9b2fb 100644 --- a/lib/tasks/gitlab_forge_acts_update.rake +++ b/lib/tasks/gitlab_forge_acts_update.rake @@ -5,8 +5,8 @@ namespace :gitlab do ids = [2,847,931,942] projects = Project.find(ids) projects.each do |project| - c = Commit.where(:project_id => project.id) - if c.blank? + # c = Commit.where(:project_id => project.id) + # if c.blank? begin g_project = g.project(project.gpid) # 获取默认分支 @@ -26,7 +26,7 @@ namespace :gitlab do rescue Exception => e puts e end - end + # end end end end From 19734c1aa4361f4b1cc5fa0f2d3ea4f660f8fe5c Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Jul 2016 15:39:15 +0800 Subject: [PATCH 49/52] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=8C=BF=E5=90=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_document_comments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 924be596e..a8a294d4d 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -1,6 +1,6 @@ class OrgDocumentCommentsController < ApplicationController before_filter :find_organization, :only => [:new, :create, :show, :index] - before_filter :authorize_allowed, :only => [:create, :add_reply] + before_filter :authorize_allowed, :only => [:create, :add_reply, :add_reply_in_doc] helper :attachments,:organizations layout 'base_org' From 160b05ae8986151ff959b1ca0924c7d377f6d95f Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Jul 2016 16:03:33 +0800 Subject: [PATCH 50/52] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=8C=BF=E5=90=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20160722074421_delete_org_anonymous.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20160722074421_delete_org_anonymous.rb diff --git a/db/migrate/20160722074421_delete_org_anonymous.rb b/db/migrate/20160722074421_delete_org_anonymous.rb new file mode 100644 index 000000000..fe796f3c5 --- /dev/null +++ b/db/migrate/20160722074421_delete_org_anonymous.rb @@ -0,0 +1,11 @@ +class DeleteOrgAnonymous < ActiveRecord::Migration + def up + anonymous_replys = OrgDocumentComment.where("organization_id = 23 AND creator_id = 2") + if anonymous_replys + anonymous_replys.destroy_all + end + end + + def down + end +end From 8dbdebe02e488b046b1a200dab3d3d41d44ab458 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Jul 2016 16:35:03 +0800 Subject: [PATCH 51/52] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 7 +++++++ app/views/projects/_project_activities.html.erb | 2 +- app/views/projects/_project_commit.html.erb | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8a871e2ea..089333160 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -44,6 +44,13 @@ module ApplicationHelper user.nil? ? User.find(2) : user end + # 历史数据(老版本库数据)处理完则可以修改该放放 + def get_rep_identifier_by_project project + identifier = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier) + result = identifier.nil? ? Repository.where(:project_id => project.id).first.try(:identifier) : identifier + result + end + # 获取用户单位 # 优先获取高校信息,如果改信息不存在则获取occupation def get_occupation_from_user user diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index 658f9f4f0..2e119ed7c 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -73,7 +73,7 @@ <% when "Attachment" %> <%= render :partial => 'users/project_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> <% when "Commit" %> - <%= render :partial => 'projects/project_commit', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> + <%= render :partial => 'projects/project_commit', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :identifier => get_rep_identifier_by_project(@project) } %> <% end %> <% end %> <% end %> diff --git a/app/views/projects/_project_commit.html.erb b/app/views/projects/_project_commit.html.erb index 99998e6e1..eea981a9d 100644 --- a/app/views/projects/_project_commit.html.erb +++ b/app/views/projects/_project_commit.html.erb @@ -17,7 +17,7 @@ <%= link_to project.to_s+" | 项目代码提交", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %>
    - <%= link_to activity.comments, {:controller => 'repositories', :action => 'commit_diff', :id => project.id, :changeset => activity.version}, :class => "postGrey" %> + <%= link_to activity.comments, {:controller => 'repositories', :action => 'commit_diff', :id => project.id, :repository_id => identifier, :changeset => activity.version}, :class => "postGrey" %>
    提交时间:<%= format_time(activity.committed_on) %> From b71a19d53eb119275bb2a684e2342913da142e58 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Jul 2016 16:55:10 +0800 Subject: [PATCH 52/52] =?UTF-8?q?Gemfile=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a94f1b33b..03dbb5785 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'elasticsearch-rails' ### profile -# gem 'oneapm_rpm' +gem 'oneapm_rpm' group :development do gem 'grape-swagger'