diff --git a/Gemfile b/Gemfile index 2b43cade3..01671daf9 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end +gem 'grack', path:'./lib/grack' gem 'rest-client' gem "mysql2", "= 0.3.18" gem 'redis-rails' diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index e0aea0c2e..6dec9a82f 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -127,19 +127,18 @@ update end else # 原逻辑 ##xianbo + params[:repository_scm] = "Git" @root_path=RepositoriesHelper::ROOT_PATH @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @project_path=@root_path+"htdocs/"+@repository_name - @repository_tag=params[:repository][:upassword] || params[:repository][:password] + @repository_tag=params[:repository][:upassword] || params[:repository][:password] || '1234' @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name attrs = pickup_extra_info - if((@repository_tag!="")&¶ms[:repository_scm]=="Git") - params[:repository][:url]=@project_path - end + params[:repository][:url]=@project_path ###xianbo - @repository = Repository.factory(params[:repository_scm]) + @repository = Repository.factory(params[:repository_scm]||"Git") @repository.safe_attributes = params[:repository] if attrs[:attrs_extra].keys.any? @repository.merge_extra_info(attrs[:attrs_extra]) @@ -278,7 +277,8 @@ update @course_tag = params[:course] project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT ip = RepositoriesHelper::REPO_IP_ADDRESS - @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ + # @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ + @repos_url = "http://#{Setting.host_name}/#{@repository.login.to_s}/#{@repository.identifier.to_s}.git" @repository.url.slice(project_path_cut, @repository.url.length).to_s if @course_tag == 1 render :action => 'show', :layout => 'base_courses' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6c8c89bc8..d48c9c85a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -52,7 +52,7 @@ class UsersController < ApplicationController :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages] + :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -177,7 +177,7 @@ class UsersController < ApplicationController return end respond_to do |format| - format.html{render :layout=>'base_users_new'} + format.html{render :layout=>'new_base_user'} end end @@ -584,7 +584,7 @@ class UsersController < ApplicationController end def show - render :layout=>'base_users_new' + render :layout=>'new_base_user' end def show_old @@ -933,13 +933,13 @@ class UsersController < ApplicationController end end @type = params[:type] || 1 - @limit = 10 + @limit = 15 @is_remote = true - @obj_count = @attachments.count - @obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1 - @offset ||= @obj_pages.offset + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,10 + @attachments = paginateHelper @attachments,15 respond_to do |format| format.js end @@ -989,13 +989,13 @@ class UsersController < ApplicationController end end @type = params[:type] - @limit = 10 + @limit = 15 @is_remote = true - @obj_count = @attachments.count - @obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1 - @offset ||= @obj_pages.offset + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,10 + @attachments = paginateHelper @attachments,15 respond_to do |format| format.js end @@ -1362,6 +1362,16 @@ class UsersController < ApplicationController @user = User.find(params[:id]) end + #修改个人简介 + def edit_brief_introduction + if @user && @user.extensions + @user.extensions.update_column("brief_introduction",params[:brief_introduction]) + end + respond_to do |format| + format.js + end + end + # 资源库 分为全部 课程资源 项目资源 附件 def user_resource #确定container_type @@ -1405,13 +1415,13 @@ class UsersController < ApplicationController end end @type = params[:type] - @limit = 10 + @limit = 15 @is_remote = true - @obj_count = @attachments.count - @obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1 - @offset ||= @obj_pages.offset + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,10 + @attachments = paginateHelper @attachments,15 respond_to do |format| format.js format.html {render :layout => 'base_users_new'} @@ -1436,7 +1446,7 @@ class UsersController < ApplicationController elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc") + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ @@ -1457,13 +1467,13 @@ class UsersController < ApplicationController end end @type = params[:type] - @limit = 10 + @limit = 15 @is_remote = true - @obj_count = @attachments.count - @obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1 - @offset ||= @obj_pages.offset + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,10 + @attachments = paginateHelper @attachments,15 respond_to do |format| format.js end diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index c77eba0c5..710b7488f 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -19,7 +19,7 @@ module RepositoriesHelper if Rails.env.development? - ROOT_PATH="/tmp/" if Rails.env.development? + ROOT_PATH="/private/tmp/" else ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/" end diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 02b6dacf1..cf356dc05 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -4,4 +4,27 @@ class CourseActivity < ActiveRecord::Base belongs_to :course_act ,:polymorphic => true belongs_to :course belongs_to :user + has_many :user_acts, :class_name => 'UserAcivity',:as =>:act + after_save :add_user_activity + before_destroy :destroy_user_activity + + #在个人动态里面增加当前动态 + def add_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first + if user_activity + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.id + user_activity.act_type = self.class.to_s + user_activity.container_type = "Course" + user_activity.container_id = self.course_id + user_activity.save + end + end + + def destroy_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'") + user_activity.destroy_all + end end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 6b75552c0..5d8de8e3a 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -19,5 +19,27 @@ class ForgeActivity < ActiveRecord::Base validates :project_id,presence: true validates :forge_act_id,presence: true validates :forge_act_type, presence: true + has_many :user_acts, :class_name => 'UserAcivity',:as =>:act + after_save :add_user_activity + before_destroy :destroy_user_activity + #在个人动态里面增加当前动态 + def add_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first + if user_activity + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.id + user_activity.act_type = self.class.to_s + user_activity.container_type = "Project" + user_activity.container_id = self.project_id + user_activity.save + end + end + + def destroy_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'") + user_activity.destroy_all + end end diff --git a/app/models/user_activity.rb b/app/models/user_activity.rb new file mode 100644 index 000000000..1af1dc017 --- /dev/null +++ b/app/models/user_activity.rb @@ -0,0 +1,7 @@ +class UserActivity < ActiveRecord::Base + attr_accessible :act_type,:act_id,:container_type,:container_id + # 虚拟关联---项目动态表/课程动态表 + belongs_to :act ,:polymorphic => true + # 虚拟关联---项目/课程 + belongs_to :container ,:polymorphic => true +end diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb new file mode 100644 index 000000000..94597eff3 --- /dev/null +++ b/app/views/layouts/_logined_header.html.erb @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/app/views/layouts/_new_feedback.html.erb b/app/views/layouts/_new_feedback.html.erb index 3b8098ed5..db0a3c3ee 100644 --- a/app/views/layouts/_new_feedback.html.erb +++ b/app/views/layouts/_new_feedback.html.erb @@ -21,14 +21,15 @@ <% end %> -
+
<%= l(:label_technical_support) %>白   羽 -
-
在线客服
+
+ 在线客服 +
diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb new file mode 100644 index 000000000..ac322f07f --- /dev/null +++ b/app/views/layouts/_unlogin_header.html.erb @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/app/views/layouts/_user_brief_introduction.html.erb b/app/views/layouts/_user_brief_introduction.html.erb new file mode 100644 index 000000000..58a7bad83 --- /dev/null +++ b/app/views/layouts/_user_brief_introduction.html.erb @@ -0,0 +1,10 @@ +<% if user.user_extensions && user.user_extensions.brief_introduction && !user.user_extensions.brief_introduction.empty? %> + <%= user.user_extensions.brief_introduction %>  +<% else%> + 这位童鞋很懒,什么也没有留下~  +<% end %> +<% if User.current == user%> + + + +<% end%> \ No newline at end of file diff --git a/app/views/layouts/_user_watch_btn.html.erb b/app/views/layouts/_user_watch_btn.html.erb index 578319b68..5f9c550b7 100644 --- a/app/views/layouts/_user_watch_btn.html.erb +++ b/app/views/layouts/_user_watch_btn.html.erb @@ -1,11 +1,7 @@ <% if User.current.logged?%> - <% if User.current == target%> - 编辑资料 - <%else%> - <%if(target.watched_by?(User.current))%> - 取消关注 - <% else %> - 添加关注 - <% end %> - <% end%> + <%if(target.watched_by?(User.current))%> + <%= link_to "",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "homepageFollow", :method => "delete",:remote => "true", :title => "取消关注"%> + <% else %> + <%= link_to "",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "homepageFollowCancel", :method => "post",:remote => "true", :title => "添加关注"%> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb new file mode 100644 index 000000000..419fa70ce --- /dev/null +++ b/app/views/layouts/new_base_user.html.erb @@ -0,0 +1,212 @@ + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_public', 'user_leftside', :media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= javascript_heads %> + <%= javascript_include_tag "bootstrap","avatars","new_user"%> + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + <%= yield :header_tags -%> + + + + + +
+
+
+
+
+ <%= image_tag(url_to_avatar(@user),width:"206", height: "206", :id=>'nh_user_tx') %> + <% if User.current.logged?%> + <% if is_current_user%> +
+
+ +
+
+ <% else %> +
+ <%= render :partial => 'layouts/user_watch_btn', :locals => {:target => @user} %> +
+ <% end %> + <% end%> +
+
+ + <% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %> +
+ <% end %> + <%= link_to("编辑资料", my_account_path, :class => "fr gz_btn mr10") if is_current_user%> +
+
+
+
+

+ <%= render :partial => 'layouts/user_brief_introduction', :locals => {:user => @user} %> +

+
+ +
+
+
+
+ <%= link_to User.watched_by(@user.id).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>@user.id},:class=>"homepageImageNumber" %> +
+
关注
+
+
+
+
+ <%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber", :id => "user_fans_number"%> +
+
粉丝
+
+
+
+
+ <%= link_to(format("%.2f" ,get_option_number(@user,1).total_score ).to_i, + {:controller => 'users', :action => 'show_new_score', :remote => true, :id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %> +
+
积分
+
+
+
+
+
+
+ <%= link_to "动态",user_activities_path(@user.id),:class => "homepageMenuText"%> +
+ +
+ +
+ +
+ +
+
+ 留言 +
+
+
+
+ 标签 +
+ <%= render :partial => 'tags/user_tag', :locals => {:obj => @user,:object_flag => "1"}%> +
+
+
+
+
+
+ <%= yield %> +
+
+ <%= render :partial => 'layouts/new_feedback' %> +
+ + + + + + diff --git a/app/views/my/save_user_avatar.js.erb b/app/views/my/save_user_avatar.js.erb index 54cb3de48..fb3d94231 100644 --- a/app/views/my/save_user_avatar.js.erb +++ b/app/views/my/save_user_avatar.js.erb @@ -1,2 +1,3 @@ $("#nh_user_tx").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:214px;height:214px;overflow:hidden",:alt=>"头像") %>'); +$("#nh_user_logo").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_logo',:width =>"40",:height => "40",:alt=>"头像") %>'); hideModal(); \ No newline at end of file diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index ca771a487..b626b4089 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -62,15 +62,6 @@ <%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post"} do |f| %>
<%=l(:button_save)%> <%=l(:button_cancel)%>
-<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 474ac638f..5f279f2c2 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -33,8 +33,9 @@

+

git 克隆和提交的用户名和密码为登录用户名和密码

项目代码请设置好正确的编码方式(utf-8),否则中文会出现乱码。

-

通过cmd命令提示符进入代码对应文件夹的根目录,假设当前用户的登录名为user,版本库名称为demo,需要操作的版本库分支为branch。 +

通过cmd命令提示符进入代码对应文件夹的根目录, 如果是首次提交代码,执行如下命令:

@@ -45,19 +46,19 @@

git commit -m "first commit"

git remote add origin - http://user_demo@repository.trustie.net/user/demo.git + <%= @repos_url %>

git config http.postBuffer 524288000 #设置本地post缓存为500MB

-

git push -u origin branch:branch

+

git push -u origin master

已经有本地库,还没有配置远程地址,打开命令行执行如下:

-

git remote add origin http://user_demo@repository.trustie.net/user/demo.git

+

git remote add origin <%= @repos_url %>

git add .

@@ -65,14 +66,14 @@

git config http.postBuffer 524288000 #设置本地post缓存为500MB

-

git push -u origin branch:branch

+

git push -u origin master

已有远程地址,创建一个远程分支,并切换到该分支,打开命令行执行如下:

-

git clone http://user_demo@repository.trustie.net/user/demo.git

+

git clone <%= @repos_url %>

git push

@@ -86,7 +87,7 @@

git remote add trustie - http://user_demo@repository.trustie.net/user/demo.git + <%= @repos_url %>

git add .

diff --git a/app/views/users/edit_brief_introduction.js.erb b/app/views/users/edit_brief_introduction.js.erb new file mode 100644 index 000000000..c64482715 --- /dev/null +++ b/app/views/users/edit_brief_introduction.js.erb @@ -0,0 +1,3 @@ +$("#user_brief_introduction_show").html("<%= escape_javascript render(:partial => "layouts/user_brief_introduction", :locals => {:user => @user}) %>"); +$("#user_brief_introduction_show").show(); +$("#user_brief_introduction_edit").hide(); \ No newline at end of file diff --git a/app/views/users/resource_search.js.erb b/app/views/users/resource_search.js.erb index 1a7469f25..a956ed212 100644 --- a/app/views/users/resource_search.js.erb +++ b/app/views/users/resource_search.js.erb @@ -1,2 +1,2 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); -$("#pages").html('<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index b2e6258ee..02791d02d 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,40 +1,221 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"user" %> -<% @center_flag = (User.current == @user) %> -
- - <% if @user.allowed_to?(:add_project, nil, :global => true) %> - 新建项目 - <% else %> - 加入项目 - <% end %> - - <% if @user.user_extensions.identity == 0 && @user.allowed_to?(:add_course, nil, :global => true) %> - 新建课程 - <% else %> - - 加入课程 - <% end %> -
+
+
+
最新动态
+ +
+
+
用户头像
+
+ + +
+ +
截止时间:2015-08-20
+
+
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
+
+ +
+
+
+
+
+
+
回复(5)
+
2015-07-28
+ +
+
+ +
+
+ + + +
+
+
+
用户头像
+
+ +
请大家说下软件工程是什么!
+
+
+
+
+
用户头像
+
+ +
软件工程是一门研究用工程化方法构建和维护有效的、实用的和高质量的软件的学科。它涉及程序设计语言、数据库、软件开发工具、系统平台、标准、设计模式等方面。
+
+ +
+
+ + + +
+
+
+
+
+
+
用户头像
+
+ +
回答非常好!
+
+
+
+
- -
- -