Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
653e07d71b
4
Gemfile
4
Gemfile
|
@ -1,10 +1,10 @@
|
|||
source 'http://gems.ruby-china.org/'
|
||||
source 'https://gems.ruby-china.com/'
|
||||
|
||||
unless RUBY_PLATFORM =~ /w32/
|
||||
# unix-like only
|
||||
gem 'iconv'
|
||||
if RUBY_PLATFORM =~ /darwin/
|
||||
gem "rmagick", "= 2.15.4" ## osx must be this version
|
||||
# gem "rmagick", "= 2.15.4" ## osx must be this version
|
||||
elsif RUBY_PLATFORM =~ /linux/
|
||||
gem "rmagick", "~> 2.13.1" ## centos yum install ImageMagick-devel
|
||||
gem 'simple_xlsx_reader'
|
||||
|
|
|
@ -21,6 +21,16 @@ module Mobile
|
|||
present :status, 0
|
||||
end
|
||||
|
||||
desc "获取课程动态"
|
||||
get 'get_course_activity' do
|
||||
CoursesService.new.get_course_activity params
|
||||
end
|
||||
|
||||
desc "获取课堂数据"
|
||||
get 'get_course_data' do
|
||||
CoursesService.new.get_course_data params
|
||||
end
|
||||
|
||||
desc "新建课程"
|
||||
#current_user当前用户对象(不是id)
|
||||
# params[:course][:name]:课程名称
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
|
||||
class AccountController < ApplicationController
|
||||
helper :custom_fields
|
||||
include AccountHelper
|
||||
include CustomFieldsHelper
|
||||
|
||||
require 'net/https'
|
||||
require 'uri'
|
||||
# prevents login action to be filtered by check_if_login_required application scope filter
|
||||
skip_before_filter :check_if_login_required
|
||||
skip_before_filter :verify_authenticity_token, :only =>[:codepedia_login]
|
||||
# Login request and validation
|
||||
#
|
||||
def login
|
||||
if params[:type] == "activated"
|
||||
@message = l(:notice_account_activated)
|
||||
|
@ -264,6 +267,66 @@ class AccountController < ApplicationController
|
|||
render :json => req
|
||||
end
|
||||
|
||||
def get_email_info
|
||||
user = User.find(params[:user_id])
|
||||
if user.present? && user.mail.present?
|
||||
begin
|
||||
email_path = Redmine::Configuration['email_path']
|
||||
email_secret = Redmine::Configuration['email_secret']
|
||||
email_Corp_ID = Redmine::Configuration['email_Corp_ID']
|
||||
uri = "#{email_path}/gettoken?corpid=#{email_Corp_ID}&corpsecret=#{email_secret}"
|
||||
uri = URI.parse(uri)
|
||||
Rails.logger.info("get_access_token_uri: #{uri}")
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
http.use_ssl = true
|
||||
Rails.logger.info("get_access_token_uri_path: #{uri.request_uri}")
|
||||
request = Net::HTTP::Get.new(uri.request_uri)
|
||||
|
||||
res = http.request(request)
|
||||
|
||||
res = JSON.parse(res.body)
|
||||
Rails.logger.info("get_access_token: #{res}")
|
||||
if res['access_token'].present?
|
||||
Rails.logger.info("access_token: #{res['access_token']}")
|
||||
uri_params = {:begin_date => "#{Time.now.strftime('%Y-%m-%d')}", :end_date => "#{Time.now.strftime('%Y-%m-%d')}",
|
||||
:mailtype => 1, :userid => "notification@trustie.org", :subject => params[:subject]}
|
||||
uri_params = uri_params.to_json
|
||||
Rails.logger.info("get_uri_params: #{uri_params}")
|
||||
log_uri = "#{email_path}/log/mail?access_token=#{res['access_token']}"
|
||||
log_uri = URI.parse(log_uri)
|
||||
Rails.logger.info("get_log_uri: #{log_uri}")
|
||||
|
||||
http = Net::HTTP.new(log_uri.host, log_uri.port)
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
http.use_ssl = true
|
||||
request = Net::HTTP::Post.new(log_uri.request_uri, initheader = {'Content-Type' =>'application/json'})
|
||||
request['foo'] = 'bar'
|
||||
request.body = "#{uri_params}"
|
||||
|
||||
Rails.logger.info("request: #{request.body}")
|
||||
response = http.start { |http| http.request(request) }
|
||||
res = JSON.parse(response.body)
|
||||
Rails.logger.info("get_log: #{res}")
|
||||
|
||||
if res['errcode'] == 0
|
||||
status = -1
|
||||
res['list'].each do |list|
|
||||
if list['receiver'] == user.mail
|
||||
status = list['status']
|
||||
end
|
||||
end
|
||||
render :json => {:result => "succuss", :message => email_status(status)}
|
||||
end
|
||||
else
|
||||
render :json => {:result => "fail"}
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error("failed to get email info! #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def email_valid
|
||||
begin
|
||||
@mail_type = params[:mail].split("@")[1]
|
||||
|
@ -388,6 +451,8 @@ class AccountController < ApplicationController
|
|||
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
|
||||
if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && last_login_on != ''
|
||||
redirect_to user_activities_path(user,host: Setting.host_user)
|
||||
elsif params[:back_url64]
|
||||
redirect_to Base64.urlsafe_decode64(params[:back_url64])
|
||||
else
|
||||
if last_login_on == ''
|
||||
redirect_to my_account_url
|
||||
|
|
|
@ -68,12 +68,6 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def readData(xlsx)
|
||||
doc = SimpleXlsxReader.open(xlsx)
|
||||
sheet = doc.sheets.first
|
||||
sheet.rows
|
||||
end
|
||||
|
||||
# 邀请码停用/启用
|
||||
def set_invite_code_halt
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
|
|
|
@ -147,13 +147,21 @@ class MyController < ApplicationController
|
|||
end
|
||||
|
||||
# 基本资料不完善 @force为false, 完善 @force为true
|
||||
@force = false
|
||||
@force = false
|
||||
if params[:tip]
|
||||
@force = true
|
||||
end
|
||||
|
||||
@user = User.current
|
||||
|
||||
#是否是Oschina过来的
|
||||
@is_oauth = !!Oschina.find_by_user_id(@user.id)
|
||||
|
||||
#是否没设置过密码
|
||||
@is_set_password = @user.hashed_password.present?
|
||||
|
||||
|
||||
|
||||
lg = @user.login
|
||||
@pref = @user.pref
|
||||
diskfile = disk_filename('User', @user.id)
|
||||
|
@ -168,6 +176,16 @@ class MyController < ApplicationController
|
|||
@user.pref.attributes = params[:pref]
|
||||
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
||||
@user.login = params[:login].strip
|
||||
|
||||
if @is_oauth && !@user.mail.present?
|
||||
@user.mail = params[:user][:mail]
|
||||
end
|
||||
|
||||
if @is_oauth && !@is_set_password
|
||||
@user.password = params[:new_password]
|
||||
@user.password_confirmation = params[:new_password_confirmation]
|
||||
end
|
||||
|
||||
unless @user.user_extensions.nil?
|
||||
# 如果用户是从业者,将单位名称保存至学校id字段
|
||||
if @user.user_extensions.identity == 3
|
||||
|
@ -202,7 +220,8 @@ class MyController < ApplicationController
|
|||
if gid.nil?
|
||||
gid = s.sync_user(@user).id
|
||||
end
|
||||
g.edit_user(gid, :email => params[:user][:mail], :username => @user.login)
|
||||
g.edit_user(gid, :username => @user.login)
|
||||
g.edit_user_mail(gid, :email => params[:user][:mail])
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
#encoding: utf-8
|
||||
class OauthController < ApplicationController
|
||||
|
||||
include ApplicationHelper
|
||||
|
||||
before_filter :user_setup
|
||||
before_filter :require_login, only: [:authorize]
|
||||
|
||||
|
||||
skip_before_filter :verify_authenticity_token, only: [:token]
|
||||
|
||||
|
||||
def index
|
||||
render 'oauth/index', layout: false
|
||||
end
|
||||
|
||||
|
||||
# 客户端申请认证的URI,包含以下参数:
|
||||
#
|
||||
# response_type:表示授权类型,必选项,此处的值固定为”code”
|
||||
# client_id:表示客户端的ID,必选项
|
||||
# redirect_uri:表示重定向URI,可选项
|
||||
# scope:表示申请的权限范围,可选项
|
||||
# state:表示客户端的当前状态,可以指定任意值(最好是随机字符串),认证服务器会原封不动地返回这个值,可防止CSRF攻击
|
||||
#
|
||||
# 这个页显示授权页,如果授权成功,返回redirect_uri+code
|
||||
#
|
||||
#
|
||||
# 服务器回应客户端的URI,包含以下参数:
|
||||
#
|
||||
# code:表示授权码,必选项。该码的有效期应该很短,通常设为10分钟,客户端只能使用该码一次, 否则会被授权服务器拒绝。该码与客户端ID和重定向URI,是一一对应关系。
|
||||
# state:如果客户端的请求中包含这个参数,认证服务器的回应也必须一模一样包含这个参数。
|
||||
def authorize
|
||||
begin
|
||||
|
||||
#参数检查
|
||||
raise "response_type只能为code" unless params["response_type"] == "code"
|
||||
raise "client_id为必传项" unless params["client_id"].present?
|
||||
raise "redirect_uri为必传项" unless params["redirect_uri"].present?
|
||||
|
||||
|
||||
config = OauthConfig.where(client_id: params["client_id"], redirect_uri: params["redirect_uri"]).first
|
||||
raise "client_id或redirect_uri不正确" unless config
|
||||
|
||||
|
||||
@data = params
|
||||
|
||||
if params[:gen_code]
|
||||
## 检查通过,生成code
|
||||
oauth = Oauth.create!(client_id: config.client_id,
|
||||
client_secret: config.client_secret,
|
||||
redirect_uri: config.redirect_uri,
|
||||
user_id: User.current.id
|
||||
)
|
||||
code = oauth.gen_code
|
||||
|
||||
redirect_to params["redirect_uri"] + "?code=#{code}&state=#{params[:state]}"
|
||||
end
|
||||
|
||||
#render 'oauth/authorize', :layout => 'base_authorize_oschina'
|
||||
rescue => e
|
||||
logger.error e
|
||||
render :text => e.message
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_callback
|
||||
# 申请 token
|
||||
#
|
||||
client_id = "88d893c5a345313e7b8c6fcf23d3d024ee08d5e41ce120c3448b6eea77d8de30"
|
||||
client_secret = "e9240cc5fc913741db5aea93f2986a8ea0631bb67f7c00e41e491b95d9619e64"
|
||||
redirect_uri = "http://localhost:3000/oauth/cb"
|
||||
url = "http://127.0.0.1:3000/oauth/token?grant_type=authorization_code&code=#{params['code']}&redirect_uri=#{redirect_uri}&client_id=#{client_id}&client_secret=#{client_secret}"
|
||||
|
||||
render text: url
|
||||
end
|
||||
|
||||
|
||||
# 客户端向认证服务器申请令牌的HTTP请求,包含以下参数:
|
||||
#
|
||||
# grant_type:表示使用的授权模式,必选项,此处的值固定为”authorization_code”。
|
||||
# code:表示上一步获得的授权码,必选项。
|
||||
# redirect_uri:表示重定向URI,必选项,且必须与A步骤中的该参数值保持一致。
|
||||
# client_id:表示客户端ID,必选项。
|
||||
# client_secret: 表示客户端密钥,必选项。
|
||||
#
|
||||
#
|
||||
# 认证服务器核对了授权码和”重定向URI”,确认无误后,向客户端发送访问令牌(access token)和更新令牌(refresh token)。
|
||||
#
|
||||
# 认证服务器发送的HTTP回复,包含以下内容:
|
||||
#
|
||||
# access_token:表示访问令牌,必选项。
|
||||
# token_type:表示令牌类型,该值大小写不敏感,必选项,可以是bearer类型或mac类型。
|
||||
# expires_in:表示过期时间,单位为秒。如果省略该参数,必须其他方式设置过期时间。
|
||||
# refresh_token:表示更新令牌,用来获取下一次的访问令牌,可选项。
|
||||
# scope:表示权限范围,如果与客户端申请的范围一致,此项可省略。
|
||||
def token
|
||||
begin
|
||||
res = {}
|
||||
if params[:grant_type] == 'authorization_code'
|
||||
|
||||
raise "code必传" unless params["code"]
|
||||
raise "client_id必传" unless params["client_id"]
|
||||
raise "client_secret必传" unless params["client_secret"]
|
||||
|
||||
raise "code错误或已超时" unless Oauth.code_valid?(params["code"])
|
||||
|
||||
oauth = Oauth.auth_code(params["code"], params["client_id"], params["client_secret"])
|
||||
raise "认证不通过" unless oauth
|
||||
|
||||
## 生成 token
|
||||
#
|
||||
oauth.gen_token
|
||||
|
||||
oauth.reload
|
||||
|
||||
res = {
|
||||
access_token: oauth.access_token,
|
||||
token_type: 'bearer',
|
||||
expires_in: oauth.token_expires_in,
|
||||
refresh_token: oauth.refresh_token
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
render json: res.to_json
|
||||
|
||||
rescue => e
|
||||
logger.error e
|
||||
render text: e.message
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_userinfo
|
||||
user = Oauth.auth(params["access_token"])
|
||||
|
||||
user_info = {}
|
||||
if user
|
||||
user_info = {
|
||||
token: user.id,
|
||||
login: user.login,
|
||||
avatar_url: "https://www.trustie.net/images/" + url_to_avatar(user),
|
||||
name: user.show_name,
|
||||
email: user.mail
|
||||
}
|
||||
end
|
||||
|
||||
render json: user_info.to_json
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def require_login
|
||||
require "base64"
|
||||
if !User.current.logged?
|
||||
redirect_to '/login?back_url64=' + Base64.urlsafe_encode64(request.original_url)
|
||||
end
|
||||
end
|
||||
|
||||
include Trustie::Http
|
||||
|
||||
end
|
|
@ -0,0 +1,64 @@
|
|||
#coding=utf-8
|
||||
#
|
||||
class OschinaController < ApplicationController
|
||||
|
||||
CLIENT_ID = 'e5da9855f89bc724a335d100cb63cf02a03a592bd3151bbc84acf7b2e222ddb8'
|
||||
CLIENT_SECRET = '4f2f291fac1d3dae338c18a3e3544814be5a1c4ade9e72d62f45ceab914c89f5'
|
||||
ROOT_URl = Redmine::Configuration['oschina_oauth_cburl'] || 'https://www.trustie.net'
|
||||
OSCHINA_URL = 'https://gitee.com'
|
||||
|
||||
def login
|
||||
# 根据session,看看有没有存access_token,去刷新下。
|
||||
# 1. 如果过期,则跳转
|
||||
# 2. 未过期,直接用
|
||||
|
||||
redirect_to "#{OSCHINA_URL}/oauth/authorize?client_id=#{CLIENT_ID}&redirect_uri=#{ROOT_URl}/oschina/login_cb&response_type=code"
|
||||
end
|
||||
|
||||
def login_callback
|
||||
#获取code
|
||||
#
|
||||
#
|
||||
logger.debug params
|
||||
url = "#{OSCHINA_URL}/oauth/token?grant_type=authorization_code"+
|
||||
"&code=#{params[:code]}&client_id=#{CLIENT_ID}&redirect_uri=#{ROOT_URl}/oschina/login_cb&client_secret=#{CLIENT_SECRET}"
|
||||
|
||||
res = post(url)
|
||||
logger.debug res
|
||||
|
||||
body = decode(res)
|
||||
#{"access_token":"21a80f20ff736b54aecd002b60210943","token_type":"bearer","expires_in":86400,"refresh_token":"be92e2c137a8c6dd22f0d8c4a622b3aeceb054087a95d293130f04ec60fd3e3f","scope":"user_info","created_at":1542684088}
|
||||
raise '登录失败' unless body["access_token"]
|
||||
|
||||
#获取此用户信息
|
||||
res = get("#{OSCHINA_URL}/api/v5/user?access_token=#{body["access_token"]}")
|
||||
logger.debug res
|
||||
info = decode(res)
|
||||
|
||||
oschina = Oschina.find_by_oschina_id(info["id"])
|
||||
unless oschina
|
||||
#新建用户
|
||||
ActiveRecord::Base.transaction do
|
||||
user = User.create_with_oschina!(info)
|
||||
oschina = Oschina.create_with_info!(info, user)
|
||||
end
|
||||
end
|
||||
|
||||
self.logged_user = oschina.user
|
||||
|
||||
user = UserExtensions.where(:user_id => User.current.id).first
|
||||
if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil?
|
||||
redirect_to my_account_path
|
||||
elsif user.identity == 3 && user.school_id.nil?
|
||||
redirect_to my_account_path
|
||||
else
|
||||
redirect_to User.current
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
include Trustie::Http
|
||||
|
||||
end
|
|
@ -433,10 +433,8 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
# for:设置默认分支
|
||||
@gitlab_repository = Repository.where(:project_id => @project, :type => "Repository::Gitlab").first
|
||||
unless @gitlab_repository.nil?
|
||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||
creator = @project.owner.try(:login)
|
||||
@repos_url = gitlab_address+"/" + creator + "/" + @gitlab_repository.identifier+"."+"git"
|
||||
if @gitlab_repository.present? && @project.gpid.present?
|
||||
@repos_url = Gitlab.client.project(@project.gpid).try(:http_url_to_repo)
|
||||
end
|
||||
|
||||
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
|
||||
|
@ -743,6 +741,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def update
|
||||
@project.safe_attributes = params[:project]
|
||||
@project.language = params[:language].try(:strip)
|
||||
@project.organization_id = params[:organization_id]
|
||||
params[:project][:is_public] == "on" ? @project.is_public = 1 : @project.is_public = 0
|
||||
params[:project][:hidden_repo] == "on" ? @project.hidden_repo = 1 : @project.hidden_repo = 0
|
||||
|
|
|
@ -13,6 +13,10 @@ class PullRequestsController < ApplicationController
|
|||
include ApplicationHelper
|
||||
|
||||
require 'ostruct'
|
||||
require 'nokogiri'
|
||||
require 'json'
|
||||
require 'open-uri'
|
||||
require 'uri'
|
||||
|
||||
# 返回json格式
|
||||
def index
|
||||
|
@ -91,9 +95,24 @@ class PullRequestsController < ApplicationController
|
|||
source_branch = params[:source_branch]
|
||||
target_branch = params[:target_branch]
|
||||
target_project_id = params[:target_project_id]
|
||||
begin
|
||||
# begin
|
||||
@gitlab_address = Redmine::Configuration['gitlab_address']
|
||||
identifier = @project.repository.try(:identifier)
|
||||
logger.info("1111111111111111#{identifier}")
|
||||
git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git"
|
||||
job_name = "pr-" + "#{Time.now.to_i}"
|
||||
# 如果分支有改动
|
||||
if compare_pull_request(source_branch, target_project_id, target_branch)
|
||||
logger.info("2222222222222222222222")
|
||||
# 自动生成配置Jenkinsjob,在merge事件的时候触发jenkins、sonar
|
||||
# merge发送的时候还没有接收,所以分析对象应该源项目
|
||||
language = swith_language_type(@project.language)
|
||||
exec_jenkins(source_branch, @project.gpid, git_url, job_name, language)
|
||||
logger.info("33333333333333333333")
|
||||
qa = QualityAnalysis.create(:project_id => @project.id, :author_login => User.current.login, :sonar_version => 1, :path => "./",
|
||||
:branch => source_branch, :language => "java", :sonar_name => "#{job_name}")
|
||||
logger.info("4444444444444444444444444")
|
||||
|
||||
# 如果传送了目标项目ID即向fork源项目发送请求
|
||||
# if params[:forked_project_id] && params[:source_project] == "forked_project_name"
|
||||
if !params[:target_project_id].blank? && params[:target_project_id].to_i != @project.id
|
||||
|
@ -103,33 +122,76 @@ class PullRequestsController < ApplicationController
|
|||
@fork_pr_message = true if @fork_project_name
|
||||
# 向管理员发送消息
|
||||
send_message_to_manager(params[:target_project_id].to_i, request.id, 1)
|
||||
PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id, :title => title)
|
||||
pr = PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id, :title => title)
|
||||
else
|
||||
@project_member = Member.where(:project_id => @project.id)
|
||||
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
|
||||
# 发送消息
|
||||
send_message_to_manager(@project.id, request.id, 1)
|
||||
# 创建Trustie数据
|
||||
PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id, :title => title)
|
||||
pr = PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id, :title => title)
|
||||
respond_to do |format|
|
||||
format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)}
|
||||
end
|
||||
end
|
||||
# 关联pr和qa
|
||||
qa.update_attribute(:pull_request_id, request.try(:id))
|
||||
|
||||
else
|
||||
tip = 1
|
||||
respond_to do |format|
|
||||
format.js{redirect_to new_project_pull_request_path(:show_tip => tip)}
|
||||
end
|
||||
end
|
||||
rescue Gitlab::Error::Forbidden => e
|
||||
@message = l(:label_pull_request_forbidden)
|
||||
rescue Gitlab::Error::Conflict => e
|
||||
@message = l(:label_pull_request_conflic)
|
||||
rescue Gitlab::Error::NotFound => e
|
||||
@message = l(:label_pull_request_notfound)
|
||||
rescue Exception => e
|
||||
puts e
|
||||
# rescue Exception => e
|
||||
# logger.info("create PR failed ####{e}")
|
||||
# end
|
||||
end
|
||||
|
||||
def exec_jenkins branch, gpid, git_url, job_name, language
|
||||
# 发送PR之前先发送创建Jenkins Job、gitlab hook,调用sonar自动分析代码
|
||||
logger.info("5555555555555555#{branch}, git_url#{git_url}, job_name #{job_name}")
|
||||
|
||||
@jenkins_address = Redmine::Configuration['jenkins_address']
|
||||
jenkins_username = Redmine::Configuration['jenkins_username']
|
||||
jenkins_password = Redmine::Configuration['jenkins_password']
|
||||
# connect jenkins
|
||||
@client_jenkins = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => jenkins_username, :password => jenkins_password)
|
||||
@g = Gitlab.client
|
||||
language = language.present? ? language : "java"
|
||||
path = "./"
|
||||
# qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first
|
||||
version = 1
|
||||
if language == "java"
|
||||
properties = "sonar.projectKey=#{job_name}
|
||||
sonar.projectName=#{job_name}
|
||||
sonar.projectVersion=#{version}
|
||||
sonar.sources=#{path}
|
||||
sonar.language=#{language.downcase}
|
||||
sonar.sourceEncoding=utf-8
|
||||
sonar.java.binaries=./"
|
||||
else
|
||||
properties = "sonar.projectKey=#{job_name}
|
||||
sonar.projectName=#{job_name}
|
||||
sonar.projectVersion=#{version}
|
||||
sonar.sources=#{path}
|
||||
sonar.language=#{language.downcase}
|
||||
sonar.sourceEncoding=utf-8"
|
||||
end
|
||||
|
||||
# 替换配置文件
|
||||
@doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml')))
|
||||
@doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url
|
||||
@doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}"
|
||||
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
|
||||
logger.info("6666666666666666666666666")
|
||||
# jenkins job创建
|
||||
jenkins_job = @client_jenkins.job.create("#{job_name}", @doc.to_xml)
|
||||
logger.info("777777777777777777")
|
||||
# 将地址作为hook值添加到gitlab
|
||||
# @g.add_project_hook(@project.gpid, (@jenkins_address + "/project/#{job_name}"), merge_requests_events: true)
|
||||
# job创建完成后自动运行job,如果运行成功则返回‘200’
|
||||
code = @client_jenkins.job.build("#{job_name}")
|
||||
end
|
||||
|
||||
# Compare branch for MR
|
||||
|
@ -143,15 +205,35 @@ class PullRequestsController < ApplicationController
|
|||
forked_source_project = Project.find(target_project)
|
||||
user_name_target = forked_source_project.owner.try(:login)
|
||||
git_target_tree = '--git-dir=/home/git/repositories/' + user_name_target + '/' + identifier + '.git'
|
||||
git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch)
|
||||
git_target_commit_id = @g.get_branch_commit_id(forked_source_project.gpid, git_target_tree, target_branch)
|
||||
# git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch)
|
||||
git_sourse_commit_id = @g.commits(@project.gpid, :ref_name => source_branch).first.try(:id)
|
||||
# git_target_commit_id = @g.get_branch_commit_id(forked_source_project.gpid, git_target_tree, target_branch)
|
||||
git_target_commit_id = @g.commits(forked_source_project.gpid, :ref_name => target_branch).first.try(:id)
|
||||
else
|
||||
git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch)
|
||||
git_target_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, target_branch)
|
||||
git_sourse_commit_id = @g.commits(@project.gpid, :ref_name => source_branch).first.try(:id)
|
||||
git_target_commit_id = @g.commits(@project.gpid, :ref_name => target_branch).first.try(:id)
|
||||
end
|
||||
status = (git_sourse_commit_id.try(:commit_id) == git_target_commit_id.try(:commit_id) ? false : true)
|
||||
logger.info("compare source_branch################{source_branch}")
|
||||
logger.info("compare target_project################{target_project}")
|
||||
logger.info("compare git_sourse_commit_id################{git_sourse_commit_id}")
|
||||
logger.info("compare git_target_commit_id################{git_target_commit_id}")
|
||||
status = (git_sourse_commit_id == git_target_commit_id ? false : true)
|
||||
end
|
||||
|
||||
# 获取jenkins输出结果
|
||||
def pr_console
|
||||
job_name = params[:job_name]
|
||||
pr = PullRequest.where(:pull_request_id => params[:pr_id]).first
|
||||
jenkins_address = Redmine::Configuration['jenkins_address']
|
||||
jenkins_username = Redmine::Configuration['jenkins_username']
|
||||
jenkins_password = Redmine::Configuration['jenkins_password']
|
||||
# connect jenkins
|
||||
client_jenkins = JenkinsApi::Client.new(:server_url => jenkins_address, :username => jenkins_username, :password => jenkins_password)
|
||||
@output = client_jenkins.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'html')["output"]
|
||||
@output = @output.force_encoding("UTF-8") if @output.present?
|
||||
end
|
||||
|
||||
|
||||
# @project_menu_type 为了控制base顶部导航
|
||||
# merge_when_succeeds
|
||||
def show
|
||||
|
|
|
@ -51,12 +51,23 @@ class QualityAnalysisController < ApplicationController
|
|||
path = params[:path].blank? ? "./" : params[:path]
|
||||
# qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first
|
||||
version = 1
|
||||
properties = "sonar.projectKey=#{sonar_name}
|
||||
if language == "java"
|
||||
properties = "sonar.projectKey=#{sonar_name}
|
||||
sonar.projectName=#{sonar_name}
|
||||
sonar.projectVersion=#{version}
|
||||
sonar.sources=#{path}
|
||||
sonar.language=#{language.downcase}
|
||||
sonar.sourceEncoding=utf-8
|
||||
sonar.java.binaries=./"
|
||||
else
|
||||
properties = "sonar.projectKey=#{sonar_name}
|
||||
sonar.projectName=#{sonar_name}
|
||||
sonar.projectVersion=#{version}
|
||||
sonar.sources=#{path}
|
||||
sonar.language=#{language.downcase}
|
||||
sonar.sourceEncoding=utf-8"
|
||||
end
|
||||
|
||||
git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git"
|
||||
|
||||
# 替换配置文件
|
||||
|
@ -144,19 +155,6 @@ class QualityAnalysisController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# get language type
|
||||
def swith_language_type language
|
||||
if language == "c#"
|
||||
"cs"
|
||||
elsif language == "python"
|
||||
"py"
|
||||
elsif language == "c"
|
||||
"c++"
|
||||
else
|
||||
language
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@g = Gitlab.client
|
||||
gitlab_branches = @g.branches(@project.gpid)
|
||||
|
@ -238,43 +236,43 @@ class QualityAnalysisController < ApplicationController
|
|||
@branch = params[:branch]
|
||||
@resource_id = params[:resource_id]
|
||||
@sonar_address = Redmine::Configuration['sonar_address']
|
||||
if params[:resource_id].nil?
|
||||
@name_flag = true
|
||||
projects_date = open(@sonar_address + "/api/projects/index").read
|
||||
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
|
||||
@quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)}
|
||||
else
|
||||
filter = "sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,files,functions,classes,directories,blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations"
|
||||
complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read
|
||||
@complexity =JSON.parse(complexity_date).first
|
||||
logger.info("######################################complexity is #{@complexity}")
|
||||
# 获取排名结果
|
||||
# @g = Gitlab.client
|
||||
# @author_infos = @g.rep_user_stats(@project.gpid, :rev => @branch)
|
||||
# @user_quality_infos = []
|
||||
# @author_infos.each do |author_info|
|
||||
# email = author_info.email
|
||||
# changes = author_info.changes.to_i
|
||||
# unresolved_issues = open(URI::escape(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}&resolved=false")).read
|
||||
# unresolved_issue_count = JSON.parse(unresolved_issues)["total"].to_i
|
||||
# all_issues = open(URI::escape(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}")).read
|
||||
# all_issue_count = JSON.parse(all_issues)["total"].to_i
|
||||
# ratio = ((changes == 0 || all_issue_count == 0) ? 0 : format("%0.4f",all_issue_count.to_f/changes.to_f))
|
||||
# @user_quality_infos << {:email => email, :changes => changes, :unresolved_issue_count => unresolved_issue_count, :ratio => ratio, :all_issue_count => all_issue_count}
|
||||
# end
|
||||
|
||||
# 按名称转换成hash键值对
|
||||
@ha = {}
|
||||
@complexity["msr"].each do |com|
|
||||
key = com["key"]
|
||||
if key == "sqale_index"
|
||||
value = com["frmt_val"]
|
||||
else
|
||||
value = com["val"]
|
||||
end
|
||||
@ha.store(key,value)
|
||||
end
|
||||
end
|
||||
# if params[:resource_id].nil?
|
||||
@name_flag = true
|
||||
projects_date = open(@sonar_address + "/api/projects/index").read
|
||||
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
|
||||
@quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)}
|
||||
# else
|
||||
# # filter = "sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,files,functions,classes,directories,blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations"
|
||||
# # complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read
|
||||
# # @complexity =JSON.parse(complexity_date).first
|
||||
# # logger.info("######################################complexity is #{@complexity}")
|
||||
# # 获取排名结果
|
||||
# # @g = Gitlab.client
|
||||
# # @author_infos = @g.rep_user_stats(@project.gpid, :rev => @branch)
|
||||
# # @user_quality_infos = []
|
||||
# # @author_infos.each do |author_info|
|
||||
# # email = author_info.email
|
||||
# # changes = author_info.changes.to_i
|
||||
# # unresolved_issues = open(URI::escape(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}&resolved=false")).read
|
||||
# # unresolved_issue_count = JSON.parse(unresolved_issues)["total"].to_i
|
||||
# # all_issues = open(URI::escape(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}")).read
|
||||
# # all_issue_count = JSON.parse(all_issues)["total"].to_i
|
||||
# # ratio = ((changes == 0 || all_issue_count == 0) ? 0 : format("%0.4f",all_issue_count.to_f/changes.to_f))
|
||||
# # @user_quality_infos << {:email => email, :changes => changes, :unresolved_issue_count => unresolved_issue_count, :ratio => ratio, :all_issue_count => all_issue_count}
|
||||
# # end
|
||||
#
|
||||
# # 按名称转换成hash键值对
|
||||
# # @ha = {}
|
||||
# # @complexity["msr"].each do |com|
|
||||
# # key = com["key"]
|
||||
# # if key == "sqale_index"
|
||||
# # value = com["frmt_val"]
|
||||
# # else
|
||||
# # value = com["val"]
|
||||
# # end
|
||||
# # @ha.store(key,value)
|
||||
# # end
|
||||
# end
|
||||
rescue Exception => e
|
||||
logger.error("fatal################# #{e}")
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# encoding=utf-8
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
|
@ -363,7 +364,7 @@ update
|
|||
@repository.url = @repository.identifier
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
if request.post? && @repository.save
|
||||
if request.post? && @repository.save!
|
||||
s = Trustie::Gitlab::Sync.new
|
||||
s.create_project(@project, @repository)
|
||||
raise "sync failed" if @project.gpid.blank?
|
||||
|
@ -371,12 +372,11 @@ update
|
|||
else
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages)
|
||||
end
|
||||
rescue Gitlab::Error::Forbidden => e
|
||||
@message = l(:label_pull_request_forbidden)
|
||||
rescue Gitlab::Error::NotFound => e
|
||||
@message = l(:label_pull_request_notfound)
|
||||
rescue Exception => e
|
||||
puts e
|
||||
logger.info("create repository #{e.message}")
|
||||
@repo_error= "666"
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories', :create_error => "版本库创建失败,用户名或版本库名中不允许包含特殊字符")
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -501,12 +501,13 @@ update
|
|||
if request.xhr?
|
||||
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
|
||||
else
|
||||
@changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
|
||||
# @changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
|
||||
@changesets_latest_coimmit = @g.commits(@project.gpid, :rev => @rev, :path => @paht).try(:first)
|
||||
# @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
|
||||
# 总的提交数
|
||||
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
|
||||
# 获取默认分支
|
||||
@g_default_branch = @g_project.default_branch.nil? ? "master" : @g_project.default_branch
|
||||
@g_default_branch = @g_project.try(:default_branch).nil? ? "master" : @g_project.try(:default_branch)
|
||||
|
||||
@creator = @project.owner.to_s
|
||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||
|
@ -518,8 +519,7 @@ update
|
|||
@zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + token
|
||||
|
||||
@creator = @project.owner.to_s
|
||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||
@repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git"
|
||||
@repos_url = @g.project(@project.gpid).try(:http_url_to_repo)
|
||||
|
||||
# 一些数据的异步同步更新
|
||||
# 访问版本庫后更新project_score表数据;changeset_num为提交总数
|
||||
|
@ -592,7 +592,8 @@ update
|
|||
entry_and_raw(false)
|
||||
@content = @repository.cat(@path, @rev)
|
||||
# @changesets_latest_coimmit = @g.commit(@project.gpid, @entry.try(:lastrev))
|
||||
@changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
|
||||
@changesets_latest_coimmit = @g.commits(@project.gpid, :rev => @rev, :path => @paht).try(:first)
|
||||
# @changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
|
||||
# 总的提交数
|
||||
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
|
||||
if is_entry_text_data?(@content, @path)
|
||||
|
@ -604,7 +605,7 @@ update
|
|||
entry_and_raw(false)
|
||||
@content = @repository.cat(@path, @rev)
|
||||
# @changesets_latest_coimmit = @g.commit(@project.gpid, @entry.try(:lastrev))
|
||||
@changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
|
||||
@changesets_latest_coimmit = @g.commits(@project.gpid, :rev => @rev, :path => @paht).try(:first)
|
||||
# 总的提交数
|
||||
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
|
||||
if is_entry_text_data?(@content, @path)
|
||||
|
|
|
@ -4,11 +4,15 @@ class StatisticsController < ApplicationController
|
|||
# GET /statistics.json
|
||||
|
||||
include StatisticsHelper
|
||||
include ApplicationHelper
|
||||
layout 'base_statistic'
|
||||
before_filter :get_date, :only => [:index, :new]
|
||||
before_filter :require_login
|
||||
before_filter :find_statistic, :only => [:show, :edit, :update, :destroy]
|
||||
before_filter :require_manager, :only =>[:edit, :update, :destroy]
|
||||
if RUBY_PLATFORM =~ /linux/
|
||||
require 'simple_xlsx_reader'
|
||||
end
|
||||
|
||||
def index
|
||||
type = (params[:type] == "reorder_popu" ? "file_size" : "created_at")
|
||||
|
@ -38,6 +42,74 @@ class StatisticsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def sync_peking_data
|
||||
attachment = Attachment.where(:container_id => 57, :container_type => "Statistic").first
|
||||
if attachment.present?
|
||||
path = attachment.disk_directory
|
||||
name = attachment.disk_filename
|
||||
if name.split(".").last == "xls" || name.split(".").last == "xlsx"
|
||||
lists = readData("files/#{path}/#{name}")
|
||||
exp_statistic = Statistic.where(:id => 247).first
|
||||
if exp_statistic
|
||||
# @list_count += lists.count
|
||||
lists.each_with_index do |list, index|
|
||||
# logger.info("#{list[0]}---#{list[1]}---#{list[2]}")
|
||||
if index > 0 && list[0]
|
||||
if index == 1
|
||||
description = exp_statistic.description.sub("https://www.trustie.net/statistics", "http://softwareasset.org.cn")
|
||||
Statistic.create(:description => description, :name => list[0], :status => exp_statistic.status, :user_id => 21502, :main_category_id => exp_statistic.main_category_id, :sub_category_id => exp_statistic.sub_category_id, :file_size => exp_statistic.file_size)
|
||||
else
|
||||
file_size = file_size_revert list[2]
|
||||
s_type = list[0][0,list[0].size - 4]
|
||||
description = exp_statistic.description.sub("APR", s_type)
|
||||
description = description.sub("https://www.trustie.net/statistics", "http://softwareasset.org.cn")
|
||||
lindex = list[3].index(":").to_i
|
||||
rindex= list[3].index("其中").to_i - 1
|
||||
description = description.sub("问答数据和API介绍数据。", list[3][lindex..rindex])
|
||||
|
||||
# 数据列表
|
||||
data_list = "| 数据类型 | 数据来源 | 数据格式 | 数据规模 |
|
||||
| ------------ | ------------ | ------------ | ------------ |
|
||||
"
|
||||
if list[4].present?
|
||||
data_list += "| 软件源代码 | http://www-eu.apache.org/dist/ | `.java`文件 | `#{list[4][0, list[4].size - 2]}`#{list[4][-2, 2]} |
|
||||
"
|
||||
end
|
||||
if list[5].present?
|
||||
data_list += "| 软件问答数据 | https://stackoverflow.com/ | `.xml`文件 | `#{list[5][0, list[5].size - 2]}`#{list[5][-2, 2]} |
|
||||
"
|
||||
end
|
||||
if list[6].present?
|
||||
data_list += "| 版本提交历史 | https://git.apache.org/ | `git`库 | `#{list[6][0, list[6].size - 2]}`#{list[6][-2, 2]} |
|
||||
"
|
||||
end
|
||||
if list[7].present?
|
||||
data_list += "| 缺陷报告 | https://issues.apache.org/jira/secure/BrowseProjects.jspa?selectedCategory=all&selectedProjectType=all | `.json`文件 | `#{list[7][0, list[7].size - 2]}`#{list[7][-2, 2]} |
|
||||
"
|
||||
end
|
||||
if list[8].present?
|
||||
data_list += "| 开发邮件 | http://mail-archives.apache.org/mod_mbox/ | `.mbox`文件 | `#{list[8][0, list[8].size - 2]}`#{list[8][-2, 2]} |
|
||||
"
|
||||
end
|
||||
if list[9].present?
|
||||
data_list += "| API使用介绍 | 项目主页 | `网页`文件 | `#{list[9][0, list[9].size - 2]}`#{list[9][-2, 2]} |"
|
||||
end
|
||||
# logger.info("data-list-------------#{data_list}")
|
||||
|
||||
l_index = description.index("|").to_i
|
||||
r_index= description.rindex("|").to_i
|
||||
description = description.sub(description[l_index..r_index], data_list)
|
||||
|
||||
Statistic.create(:description => description, :name => list[0], :status => exp_statistic.status, :user_id => 21502, :main_category_id => exp_statistic.main_category_id, :sub_category_id => exp_statistic.sub_category_id, :file_size => file_size)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to statistics_path
|
||||
end
|
||||
|
||||
def search
|
||||
|
||||
end
|
||||
|
|
|
@ -906,7 +906,6 @@ class StudentWorkController < ApplicationController
|
|||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
|
||||
render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2
|
||||
@score = student_work_score @work,User.current
|
||||
#@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
#@score.score = params[:score] if params[:score]
|
||||
#if User.current.admin?
|
||||
|
@ -918,16 +917,19 @@ class StudentWorkController < ApplicationController
|
|||
#@is_new = false
|
||||
@is_last_a = @work.student_works_scores.empty?
|
||||
@new_score = StudentWorksScore.new
|
||||
if @score && params[:score]
|
||||
@new_score.score = params[:score].to_i == -1 ? @score.score : params[:score]
|
||||
elsif @score.nil? && params[:score]
|
||||
@new_score.score = params[:score].to_i == -1 ? nil : params[:score]
|
||||
if params[:score] == -1
|
||||
score = student_work_score @work,User.current
|
||||
@new_score.score = @score.try(:score)
|
||||
else
|
||||
@new_score.score = params[:score]
|
||||
end
|
||||
|
||||
@new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
@new_score.user_id = User.current.id
|
||||
@new_score.student_work_id = @work.id
|
||||
if @is_teacher && !@new_score.score.nil? && @work.work_status == 0
|
||||
@work.update_attributes(:work_status => 1, :commit_time => Time.now)
|
||||
@work.work_status = 1
|
||||
@work.commit_time = Time.now
|
||||
#更新CourseHomeworkStatistics中学生的已交作品数、未交作品数
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
|
||||
course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
|
||||
|
@ -939,16 +941,6 @@ class StudentWorkController < ApplicationController
|
|||
role = User.current.members.where("course_id = ?",@course.id).first.roles.where("is_current = 1").first.name
|
||||
@new_score.reviewer_role = get_role_by_name(role)
|
||||
end
|
||||
if @score
|
||||
if @is_teacher
|
||||
@is_new = true
|
||||
@is_last_a = false
|
||||
else
|
||||
@is_new = false
|
||||
end
|
||||
else
|
||||
@is_new = true
|
||||
end
|
||||
|
||||
@new_score.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@new_score)
|
||||
|
@ -994,7 +986,7 @@ class StudentWorkController < ApplicationController
|
|||
@homework.update_column('updated_at', Time.now)
|
||||
update_course_activity(@homework.class,@homework.id)
|
||||
update_user_activity(@homework.class,@homework.id)
|
||||
update_org_activity(@homework.class,@homework.id)
|
||||
# update_org_activity(@homework.class,@homework.id)
|
||||
if @work.save
|
||||
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
|
||||
@count = @homework.student_works.has_committed.count
|
||||
|
|
|
@ -2377,6 +2377,7 @@ class UsersController < ApplicationController
|
|||
act_type = 'all'
|
||||
end
|
||||
end
|
||||
logger.info("####################{container_type}")
|
||||
if container_type != '' && container_type != 'all'
|
||||
if container_type == 'Course'
|
||||
sql = "container_type = '#{container_type}' and container_id in #{user_course_ids} and act_type = '#{act_type}'"
|
||||
|
|
|
@ -19,6 +19,33 @@
|
|||
|
||||
module AccountHelper
|
||||
|
||||
def email_status status
|
||||
message = ""
|
||||
case status
|
||||
when -1
|
||||
message = " 未查询到相关数据"
|
||||
when 0
|
||||
message = "其他状态"
|
||||
when 1
|
||||
message = "发信中"
|
||||
when 2
|
||||
message = "被退信"
|
||||
when 3
|
||||
message = "发信成功"
|
||||
when 4
|
||||
message = "发信失败"
|
||||
when 11
|
||||
message = "收信被拦截"
|
||||
when 12
|
||||
message = "收信,邮件进入垃圾箱"
|
||||
when 13
|
||||
message = "收信成功,邮件在收件箱"
|
||||
when 14
|
||||
message = "收信成功,邮件在个人文件夹"
|
||||
end
|
||||
message
|
||||
end
|
||||
|
||||
def email_activation_register(user, &block)
|
||||
token = Token.new(:user => user, :action => "register")
|
||||
if user.save and token.save
|
||||
|
|
|
@ -37,6 +37,26 @@ module ApplicationHelper
|
|||
# super
|
||||
# end
|
||||
|
||||
# get language type
|
||||
def swith_language_type language
|
||||
if language == "c#"
|
||||
"cs"
|
||||
elsif language == "python"
|
||||
"py"
|
||||
elsif language == "c"
|
||||
"c++"
|
||||
else
|
||||
language
|
||||
end
|
||||
end
|
||||
|
||||
# 读取excel数据
|
||||
def readData(xlsx)
|
||||
doc = SimpleXlsxReader.open(xlsx)
|
||||
sheet = doc.sheets.first
|
||||
sheet.rows
|
||||
end
|
||||
|
||||
# 公共分页
|
||||
def paginator_list objs, objs_count, limit, is_remote
|
||||
@is_remote = is_remote
|
||||
|
@ -2151,6 +2171,12 @@ module ApplicationHelper
|
|||
hidden_field_tag('back_url', url, :id => nil) unless url.blank?
|
||||
end
|
||||
|
||||
|
||||
def back_url64_hidden_field_tag
|
||||
url = params[:back_url64]
|
||||
hidden_field_tag('back_url64', url, :id => nil) unless url.blank?
|
||||
end
|
||||
|
||||
def check_all_links(form_name)
|
||||
link_to_function_none(l(:button_check_all), "checkAll('#{form_name}', true)") + " ".html_safe + " | "+ " ".html_safe +
|
||||
link_to_function_none(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
|
||||
|
|
|
@ -16,4 +16,18 @@ module StatisticsHelper
|
|||
source[0] = source[0].gsub(/(\d)(?=(\d{3})+(?!\d))/, "\\1,")
|
||||
return source.join(".")
|
||||
end
|
||||
|
||||
# excel中的数据大小转换成MB
|
||||
def file_size_revert size_str
|
||||
result = 0
|
||||
unit = size_str[-2, 2]
|
||||
if unit == "GB"
|
||||
result = size_str.to_f * 1024
|
||||
elsif unit == "KB"
|
||||
result = (size_str.to_f / 1024).round(3)
|
||||
else
|
||||
result = size_str.to_f
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
|
|
@ -160,24 +160,25 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
|
||||
def delay_homework_send
|
||||
if self.course
|
||||
if self.homework_detail_manual.comment_status != 0
|
||||
vs = []
|
||||
self.course.members.each do | m|
|
||||
if m.user_id != self.user_id
|
||||
vs << {course_message_type:'HomeworkCommon',course_message_id:self.id, :user_id => m.user_id,
|
||||
:course_id => self.course_id, :viewed => false}
|
||||
|
||||
vs = []
|
||||
self.course.members.each do | m|
|
||||
if m.user_id != self.user_id
|
||||
vs << {course_message_type:'HomeworkCommon',course_message_id:self.id, :user_id => m.user_id,
|
||||
:course_id => self.course_id, :viewed => false}
|
||||
|
||||
#delayed_job卡住的原因是一次执行的条数太多,导致超时。
|
||||
#现在把每次只执行不超过30条,就不会超了。
|
||||
if vs.size >= 30
|
||||
self.delay.contain_homework_message(vs)
|
||||
vs.clear
|
||||
#delayed_job卡住的原因是一次执行的条数太多,导致超时。
|
||||
#现在把每次只执行不超过30条,就不会超了。
|
||||
if vs.size >= 30
|
||||
self.delay.contain_homework_message(vs)
|
||||
vs.clear
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless vs.empty?
|
||||
self.delay.contain_homework_message(vs)
|
||||
unless vs.empty?
|
||||
self.delay.contain_homework_message(vs)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
require 'base64'
|
||||
|
||||
class Oauth < ActiveRecord::Base
|
||||
attr_accessible :client_id, :client_secret, :redirect_uri, :access_token,
|
||||
:refresh_token, :token_created_at,:token_expires_in, :user_id
|
||||
|
||||
belongs_to :user
|
||||
|
||||
|
||||
|
||||
def gen_code
|
||||
code = Base64.urlsafe_encode64 Digest::MD5.hexdigest "#{Time.now}-#{Random.new_seed}"
|
||||
update_column(:code, code)
|
||||
code
|
||||
end
|
||||
|
||||
def gen_token
|
||||
access_token = Digest::MD5.hexdigest "#{Time.now}-#{Random.new_seed}"
|
||||
refresh_token = Digest::MD5.hexdigest "#{Random.new_seed}-#{Time.now}-#{Random.new_seed}"
|
||||
|
||||
self.update_attributes(access_token: access_token,
|
||||
refresh_token: refresh_token,
|
||||
token_created_at: Time.now.to_i,
|
||||
token_expires_in: Time.now.to_i + 24*60*60,
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
def self.code_valid?(code)
|
||||
# 1. 是否存在
|
||||
oauth = Oauth.where(code: code).order("ID desc").first
|
||||
return false unless oauth
|
||||
|
||||
# 2. 是否超过10分钟
|
||||
return false if Time.now.to_i - oauth.created_at.to_i > 10*60
|
||||
|
||||
# 3. 是否有使用过
|
||||
return false if oauth.access_token.present?
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
def self.auth_code(code, client_id, client_secret)
|
||||
Oauth.where(code: code, client_id: client_id, client_secret: client_secret).order('id desc').first
|
||||
end
|
||||
|
||||
def self.auth(access_token)
|
||||
oauth = self.find_by_access_token(access_token)
|
||||
return nil unless oauth
|
||||
oauth.user
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
class OauthConfig < ActiveRecord::Base
|
||||
attr_accessible :client_id, :client_secret, :redirect_uri, :scope
|
||||
end
|
|
@ -0,0 +1,18 @@
|
|||
class Oschina < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
attr_accessible :login, :user, :name, :avatar_url, :email, :phone, :oschina_id
|
||||
|
||||
|
||||
|
||||
def self.create_with_info!(info, user)
|
||||
self.create!(
|
||||
login: info["login"],
|
||||
name: info["name"],
|
||||
avatar_url: info["avatar_url"],
|
||||
email: info["email"],
|
||||
phone: info["phone"],
|
||||
oschina_id: info["id"],
|
||||
user: user
|
||||
)
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class QualityAnalysis < ActiveRecord::Base
|
||||
attr_accessible :author_login, :project_id, :rep_identifier, :sonar_version, :branch, :path, :rep_identifier, :language, :sonar_name
|
||||
attr_accessible :author_login, :project_id, :rep_identifier, :sonar_version, :branch, :path, :rep_identifier, :language, :sonar_name, :pull_request_id
|
||||
|
||||
def user_rep_name
|
||||
self.author_login+":"+self.rep_identifier
|
||||
|
|
|
@ -206,11 +206,9 @@ class StudentWork < ActiveRecord::Base
|
|||
course_homework_statistics = CourseHomeworkStatistics.where(:user_id => self.user_id, :course_id => self.homework_common.course_id).first
|
||||
if course_homework_statistics
|
||||
course = self.homework_common.course
|
||||
homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
|
||||
student_works = StudentWork.where("homework_common_id in #{homework_ids} and work_status !=0")
|
||||
user = self.user
|
||||
average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
|
||||
total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
||||
average_score = user.student_works.where(:homework_common_id => course.homework_commons.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:homework_common_id => course.homework_commons.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
|
||||
total_score = user.student_works.where(:homework_common_id => course.homework_commons.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:homework_common_id => course.homework_commons.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
||||
course_homework_statistics.update_attributes(:average_score => average_score, :total_score => total_score)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1453,6 +1453,34 @@ class User < Principal
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def self.create_with_oschina!(info)
|
||||
user = User.new
|
||||
user.admin = false
|
||||
user.login = info["login"]
|
||||
if User.find_by_login(info["login"])
|
||||
user.login = "oschina_" + info["login"]
|
||||
end
|
||||
|
||||
unless User.find_by_mail(info["email"])
|
||||
user.mail = info["email"]
|
||||
end
|
||||
user.lastname = info["name"]
|
||||
|
||||
user.activate
|
||||
user.last_login_on = Time.now
|
||||
user.save!(:validate => false)
|
||||
|
||||
UserStatus.create!(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
||||
|
||||
ue = user.user_extensions ||= UserExtensions.new
|
||||
ue.user_id = user.id
|
||||
ue.save!
|
||||
|
||||
user
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class AnonymousUser < User
|
||||
|
|
|
@ -44,6 +44,35 @@ class CoursesService
|
|||
}
|
||||
end
|
||||
|
||||
# 获取课程最新动态
|
||||
def get_course_activity params
|
||||
page = params[:page] || 1
|
||||
activities = UserActivity.where(:container_type => 'Course', :act_type => 'HomeworkCommon').order('created_at desc')
|
||||
|
||||
activities_count = activities.count
|
||||
activities_pages = Redmine::Pagination::Paginator.new @activities_count, 4, page
|
||||
activities = activities.offset(activities_pages.offset).limit(activities_pages.per_page)
|
||||
course_activites_data = []
|
||||
activities.each do |a|
|
||||
Rails.logger.info("###############{a.container.to_json}")
|
||||
course_name = a.container.name
|
||||
course_activites_data << {course_name: course_name, content: a.act.name, time: format_time(a.created_at), url: "www.trustie.net/course/#{a.container_id}"}
|
||||
end
|
||||
{course_activites_data: course_activites_data}
|
||||
end
|
||||
|
||||
def get_course_data params
|
||||
page = params[:page] || 1
|
||||
courses = Course.where(:is_delete => false, :is_public => true).order("visits desc")
|
||||
courses_count = courses.count
|
||||
courses_pages = Redmine::Pagination::Paginator.new courses_count, 4, page
|
||||
courses = courses.offset(courses_pages.offset).limit(courses_pages.per_page)
|
||||
course_data = []
|
||||
courses.each do |c|
|
||||
course_data << {name: c.name, time: format_time(c.created_at), url: "www.trustie.net/courses/#{c.id}"}
|
||||
end
|
||||
{course_data: course_data}
|
||||
end
|
||||
|
||||
|
||||
#搜索课程
|
||||
|
|
|
@ -67,7 +67,11 @@
|
|||
$("#user_email_show").html(data.email);
|
||||
// 更改邮箱地址后,直接给用户发送邮件
|
||||
$.ajax({
|
||||
url: "<%= resendmail_path(:user => @user) %>"
|
||||
url: "<%= resendmail_path(:user => @user) %>",
|
||||
type: 'get',
|
||||
success:function(data){
|
||||
task = setInterval(get_email_info(<%= @user.try(:id) %>, "用户注册帐号激活通知"), 1000);
|
||||
}
|
||||
});
|
||||
hideModal();
|
||||
return;
|
||||
|
|
|
@ -3,18 +3,14 @@
|
|||
<p class="email_verify_prompt"><span class="icons_email_prompt"></span>您的账号尚未激活,请先进入您的注册邮箱(<span class="c_red" id="user_email_show"><%= @user.mail %></span>),激活您的账号。</p>
|
||||
<button class="email_verify_btn mt30 ml30" onclick = "resendMail('<%= resendmail_path(@user) %>','<%= @user.id %>');">重新发送激活邮件</button>
|
||||
<%#= link_to l(:label_mail_resend), { :controller => 'account', :action => 'resendmail',:user => @user}, :class=>"email_verify_btn mt30 ml30", :remote => true, :method => 'get' %>
|
||||
<div class="mt10 ml30 mb10 email_info_box none">
|
||||
<span class="f14" id="email_log_detail">邮件概况:</span>
|
||||
</div>
|
||||
<ul class="email_prompt_txt ml30 mt30" style="width:580px;margin-bottom: 20px">
|
||||
<p class="email_prompt_p">如果您尚未收到激活邮件,请按照以下步骤操作:</p>
|
||||
<li>检查邮箱的“订阅邮件”、“垃圾邮件”,可能会发现激活邮件。 </li>
|
||||
<li>如果激活邮件已无效,请点击重新发送激活邮件按钮。</li>
|
||||
<li>如果重发注册验证邮箱邮件仍然没有收到,请<a href="javascript:void(0);" class="link-blue" id="change_email">更换邮箱地址</a>,重新发送激活邮件</li>
|
||||
<li>如果您始终无法收到激活邮件,请直接给我们<a href="javascript:void(0);" class="link-blue" id="leave_message">留言</a></li>
|
||||
<div class="mt10 undis" id="message_box">
|
||||
<textarea style="resize: none;width: 570px;" class="email_prompt_mes" placeholder="<%= l(:label_email_feedback_tips) %>"></textarea>
|
||||
<div class="c1"></div>
|
||||
<button class="email_sub_btn fr" onclick="leave_email_activation_message('<%= leave_email_activation_message_path(1)%>','<%= @user.id %>');">确定</button>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -45,28 +41,10 @@
|
|||
}
|
||||
|
||||
$(".email_verify_btn").replaceWith("<p class='email_verify_p mt30 ml30'>激活邮件已发送至您的注册邮箱("+mail+"),请及时登录邮箱进行验证。</p>");
|
||||
|
||||
get_email_info(<%= @user.try(:id) %>, "用户注册帐号激活通知");
|
||||
}
|
||||
);
|
||||
}
|
||||
function leave_email_activation_message(url,user)
|
||||
{
|
||||
if ($(".email_prompt_mes").val().length == 0){
|
||||
//弹框请他输入文字
|
||||
var htmlvalue = "</br><div style='width:550px;text-align:center'>您的留言不能为空</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
|
||||
pop_up_box(htmlvalue,580,30,50);
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: {user: user, text: $(".email_prompt_mes").val() },
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
var htmlvalue = "<div class='email_tancon'><h2 class='email_tan_title'>您的留言已发送</h2><p class='email_tan_p'>我们将尽快处理好并通知您。感谢您的反馈!</p></div>"
|
||||
pop_up_box(htmlvalue, 580, 30, 45);
|
||||
$(".email_prompt_mes").val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
function regex_mv_name()
|
||||
{
|
||||
|
|
|
@ -5,32 +5,30 @@
|
|||
<div class="email_verify" style="width: 580px;">
|
||||
<p class="fb f18" style="color:green;"><i class="icon-ok mr5 f18"></i>注册成功!
|
||||
<span style=" color:#3b94d6; font-size:12px; font-weight:normal;">请在24小时内点击邮件中的链接来激活您的账号。</span></p>
|
||||
<p class="f14 mt30 mb5">请登录邮箱(<span class="c_red" id="user_email_show"><%= @user.mail %></span>)收取账号激活邮件。<br/>点击邮件中的激活链接,方可使用该账号
|
||||
<p class="f14 mt30 mb5">请登录邮箱(<span class="c_red" id="user_email_show"><%= @user.mail %></span>)收取账号激活邮件。<br/>点击邮件中的激活链接,方可使用该账号
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://mail.<%= email %>" class="btn btn-blue" target="_blank"><%= l(:label_check_email)%></a>
|
||||
<%= link_to "<input class='btn btn-blue' type='button' id='btn' value='重新发送激活邮件' onclick='settime(this)' />".html_safe, { :controller => 'account', :action => 'resendmail', :user => @user}, :remote => true, :method => 'get' %>
|
||||
<a href="javascript:void(0);" onclick="resendMail('<%= resendmail_path(@user) %>','<%= @user.id %>');"><input class='btn btn-blue' type='button' id='btn' value='重新发送激活邮件'/></a>
|
||||
</p>
|
||||
|
||||
<div class="mt10 mb10 email_info_box">
|
||||
<span class="f14" id="email_log_detail">邮件概况:</span>
|
||||
</div>
|
||||
<ul class="email_prompt_txt mt30" style="width: 580px;">
|
||||
<p class="email_prompt_p">如果您一直收不到激活邮件,请按照以下步骤操作:</p>
|
||||
<li>请确认是否填写了正确的邮箱地址 </li>
|
||||
<li>请注意查看邮箱中的“订阅邮件”、“垃圾邮件”,可能Trustie的邮件被误杀了</li>
|
||||
<li>请点击重新发送激活邮件按钮</li>
|
||||
<li>如果重发注册验证邮箱邮件仍然没有收到,请<a href="javascript:void(0);" class="link-blue" id="change_email">更换邮箱地址</a>,重新发送激活邮件</li>
|
||||
<li>如果您始终无法收到激活邮件,请直接给我们<a href="javascript:void(0);" class="link-blue" id="leave_message">留言</a></li>
|
||||
<div class="mt10 undis" id="message_box">
|
||||
<textarea style="resize: none;width: 570px;" class="email_prompt_mes" placeholder="<%= l(:label_email_feedback_tips) %>"></textarea>
|
||||
<div class="c1"></div>
|
||||
<button class="email_sub_btn fr" onclick="leave_email_activation_message('<%= leave_email_activation_message_path(1)%>','<%= @user.id %>');">确定</button>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
get_email_info(<%= @user.try(:id) %>, "用户注册帐号激活通知");
|
||||
|
||||
$("#change_email").click(function(){
|
||||
$.ajax({
|
||||
url: "<%= change_user_email_user_path(@user) %>"
|
||||
|
@ -41,27 +39,26 @@
|
|||
})
|
||||
});
|
||||
|
||||
|
||||
function leave_email_activation_message(url,user)
|
||||
function resendMail(url,id)
|
||||
{
|
||||
if ($(".email_prompt_mes").val().length == 0){
|
||||
//弹框请他输入文字
|
||||
var htmlvalue = "</br><div style='width:550px;text-align:center'>您的留言不能为空</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
|
||||
pop_up_box(htmlvalue,580,30,50);
|
||||
return;
|
||||
}
|
||||
$.get(
|
||||
url,
|
||||
{user: id },
|
||||
function (data) {
|
||||
//邮箱@之前用a**b格式显示
|
||||
var mail = data.email;
|
||||
var pos = mail.indexOf("@");
|
||||
var restr = mail.substring(1,pos-1);
|
||||
if( mail.split("@")[0].length > 2 ){
|
||||
mail = mail.replace(restr,"***");
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: {user: user, text: $(".email_prompt_mes").val() },
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
var htmlvalue = "<div class='email_tancon'><h2 class='email_tan_title'>您的留言已发送</h2><p class='email_tan_p'>我们将尽快处理好并通知您。感谢您的反馈!</p></div>"
|
||||
pop_up_box(htmlvalue, 580, 30, 50);
|
||||
$(".email_prompt_mes").val("");
|
||||
settime(document.getElementById("btn"));
|
||||
get_email_info(<%= @user.try(:id) %>, "用户注册帐号激活通知");
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
function regex_mv_name()
|
||||
{
|
||||
var name = $.trim($("#subject").val());
|
||||
|
@ -121,13 +118,6 @@
|
|||
myTips("反馈成功","success");
|
||||
});
|
||||
|
||||
$("#scrollsidebar").fix({
|
||||
float: 'right', //default.left or right
|
||||
minStatue: cookieget('minStatue'),
|
||||
skin: 'green', //default.gray or blue
|
||||
durationTime: 600
|
||||
});
|
||||
|
||||
$("#subject").keydown(function(){
|
||||
alert("2222");
|
||||
var curLength=$("#subject").val().length;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
$(".navHomepageSearchBoxcontainer").mouseout(function(){
|
||||
$(".navSearchTypeBox").css({display:"none"});
|
||||
});
|
||||
})
|
||||
});
|
||||
$(document).ready(function(){
|
||||
if(<%= @login%>){
|
||||
$("#signUpBox").css({display:"none"});
|
||||
|
@ -37,15 +37,16 @@
|
|||
var $passwd_correct = false;
|
||||
var $passwd_comfirm_correct = false;
|
||||
jQuery(document).ready(function () {
|
||||
var $login = $('#user_login')
|
||||
var $mail = $('#user_mail')
|
||||
var $password = $('#user_password')
|
||||
var $password_confirmation = $('#user_password_confirmation')
|
||||
var $login = $('#user_login');
|
||||
var $mail = $('#user_mail');
|
||||
var $password = $('#user_password');
|
||||
var $password_confirmation = $('#user_password_confirmation');
|
||||
$login.blur(function (event) {
|
||||
if ($(this).is('#user_login')) {
|
||||
if (/^[a-zA-Z][a-zA-Z\d]{3,14}$/.test(this.value) == false){
|
||||
$('#login_req').html('<span style="color: #c00202">只能使用英文字母和数字,必须以字母开头,长度不少于4个字符、不超过15个字符</span>');
|
||||
$('#login_req').show();
|
||||
$login_correct = false;
|
||||
return ;
|
||||
}
|
||||
else{
|
||||
|
@ -91,7 +92,6 @@
|
|||
$('#mail_req').css('display','block');
|
||||
});
|
||||
}
|
||||
;
|
||||
});
|
||||
$password.blur(function () {
|
||||
var pas1 = document.getElementById("user_password").value;
|
||||
|
@ -135,7 +135,7 @@
|
|||
<h3> 欢迎加入Trustie创新实践社区</h3>
|
||||
<p>在这里,您的创新意识和创新潜力将得到充分发挥!目前已有超过200所高校和科研机构在平台中开展在线协同开发、协同学习和协同研究。</p>
|
||||
</div>
|
||||
<div class="new_login_box fr mr45 mt100">
|
||||
<div class="new_login_box fr mr45 mt60">
|
||||
<% if @message %>
|
||||
<p class="f14 mb5" style=" color:#fff;"><i class="icon-ok mr5"></i><%= h @message %></p>
|
||||
<% end %>
|
||||
|
@ -145,6 +145,7 @@
|
|||
<div class="new_login_form">
|
||||
<%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %>
|
||||
<%= back_url_hidden_field_tag %>
|
||||
<%= back_url64_hidden_field_tag %>
|
||||
<ul>
|
||||
<li class="new_loggin_users">
|
||||
<%= text_field_tag 'username', params[:username], :tabindex => '1', :class=>'new_loggin_input',:placeholder=>'请输入邮箱地址或登录名', :onkeypress => "user_name_keypress(event);"%>
|
||||
|
@ -158,6 +159,7 @@
|
|||
<% if Setting.autologin? %>
|
||||
<label><%= check_box_tag 'autologin', 1, true, :tabindex => 4, :class => "new_login_check" %><%= l(:label_stay_logged_in) %></label>
|
||||
<% end %>
|
||||
<%#= link_to 'oschina登录', oschina_login_path %>
|
||||
<a href="<%= lost_password_path %>" class="fr">
|
||||
<% if Setting.lost_password? %>忘记密码<% end %>
|
||||
</a>
|
||||
|
@ -167,7 +169,12 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="text_c">
|
||||
<a href="<%= oschina_login_path %>">
|
||||
<ul style="width: auto;display: inline-block;"><span class="oschinaBox"><i class="iconfont icon-oschina c_white oschinaIcon"></i></span></ul>
|
||||
<p class="c_white f12">使用oschina账号登录</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
@ -180,14 +187,14 @@
|
|||
<p>在这里,您的创新意识和创新潜力将得到充分发挥!目前已有超过200所高校和科研机构在平台中开展在线协同开发、协同学习和协同研究。</p>
|
||||
</div>
|
||||
<div class="new_login_box fr mr45 mt50">
|
||||
<h2 class="new_login_h2">注册<a href="<%= signin_url_without_domain %>" class="fr mt5">已有账号 请登录</a><div class="cl"></div></h2>
|
||||
<h2 class="new_login_h2">注册<a href="<%= signin_url_without_domain %>" class="fr mt5">已有账号 请登录</a><div class="cl"></div></h2>
|
||||
<div class="new_login_form">
|
||||
<%= form_for :user, :url => register_path,:method=>'post', :html => {:id=>'main_reg_form'} do |f| %>
|
||||
<%= error_messages_for 'user' %>
|
||||
<ul>
|
||||
<li class="new_register_li">
|
||||
<%= f.text_field :mail, :size => 25, :class => 'new_register_input' , :placeholder => "请输入邮箱地址"%>
|
||||
<p class="new_login_error" id="mail_req" style="display: none" >请输入正确的邮箱</p>
|
||||
<%= f.text_field :mail, :size => 25, :class => 'new_register_input', :placeholder => "请输入邮箱地址"%>
|
||||
<p class="new_login_error" id="mail_req" style="display: none">请输入正确的邮箱</p>
|
||||
</li>
|
||||
<li class="new_register_li">
|
||||
<%= f.password_field :password, :size => 25, :placeholder => "请输入密码", :class => 'new_register_input' %>
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
:minHeight=>500,
|
||||
:class => 'talk_text fl',
|
||||
:input_html => { :id => 'message_content',
|
||||
:class => 'talk_text fl',
|
||||
:maxlength => 5000 }%>
|
||||
:class => 'talk_text fl'}%>
|
||||
<div class="cl"></div>
|
||||
<p id="message_content_span"></p>
|
||||
<p id="e_tip" class="c_grey"></p>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
}
|
||||
});
|
||||
<% end %>
|
||||
<p class="none c_red ml100" id="issue_subject_notice"></p>
|
||||
<% end %>
|
||||
<span ></span>
|
||||
</li>
|
||||
|
@ -186,17 +187,22 @@
|
|||
}
|
||||
|
||||
function issue_create(){
|
||||
var issue_commit_ids = $("#issue_commit_ids .commit_id_value");
|
||||
var str = "";
|
||||
for(var i=0; i < issue_commit_ids.length; i++){
|
||||
str += $(issue_commit_ids[i]).html();
|
||||
if(i != issue_commit_ids.length -1){
|
||||
str += ",";
|
||||
if($("#issue_subject").val().trim() == ""){
|
||||
$("#issue_subject_notice").html("主题不能为空").show();
|
||||
} else {
|
||||
$("#issue_subject_notice").hide();
|
||||
var issue_commit_ids = $("#issue_commit_ids .commit_id_value");
|
||||
var str = "";
|
||||
for(var i=0; i < issue_commit_ids.length; i++){
|
||||
str += $(issue_commit_ids[i]).html();
|
||||
if(i != issue_commit_ids.length -1){
|
||||
str += ",";
|
||||
}
|
||||
}
|
||||
issue_desc_editor.sync();
|
||||
$('#commit_ids').val(str);
|
||||
$('#issue-form').submit();
|
||||
}
|
||||
issue_desc_editor.sync();
|
||||
$('#commit_ids').val(str);
|
||||
$('#issue-form').submit();
|
||||
}
|
||||
|
||||
function get_issue_commit_ids(id, project_id){
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
</div>
|
||||
<div class=" fl ml5">
|
||||
<div class="issues_list_titlebox clear">
|
||||
<a href="<%= issue_path(activity) %>" class="issues_list_title fl" target="_blank" title="<%= activity.subject.to_s %>"><%= activity.subject.to_s %></a>
|
||||
<a href="<%= issue_path(activity) %>" class="issues_list_title fl" style="max-width: 350px;" target="_blank" title="<%= activity.subject.to_s %>"><%= activity.subject.to_s %></a>
|
||||
<span class='<%= "#{get_issue_priority(activity.priority_id)[0]} fl" %>' style="color: #fff;"><%= get_issue_priority(activity.priority_id)[1] %></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="issues_list_small">
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<% @nav_dispaly_home_path_label = 1
|
||||
@nav_dispaly_main_course_label = 1
|
||||
@nav_dispaly_main_project_label = 1
|
||||
@nav_dispaly_main_contest_label = 1 %>
|
||||
<% @nav_dispaly_forum_label = 1%>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= current_language %>">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title><%=h html_title %></title>
|
||||
<meta name="description" content="<%= Redmine::Info.app_name %>" />
|
||||
<meta name="keywords" content="issue,bug,tracker" />
|
||||
<%= csrf_meta_tag %>
|
||||
<%= favicon %>
|
||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan','prettify','//at.alicdn.com/t/font_930423_4z0tgi8hlb9.css', :media => 'all' %>
|
||||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||||
<%= javascript_heads %>
|
||||
<%= javascript_include_tag "jquery.leanModal.min",'prettify' %>
|
||||
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
|
||||
<%= heads_for_theme %>
|
||||
<%= call_hook :view_layouts_base_html_head %>
|
||||
<!-- page specific tags -->
|
||||
<%= yield :header_tags -%>
|
||||
<%= stylesheet_link_tag 'css/common','css/structure','css/public', :media => 'all'%>
|
||||
<!-- MathJax的配置 -->
|
||||
<script type="text/javascript"
|
||||
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||
</script>
|
||||
<!-- 配置 : 在生成的公式图片上去掉Math定义的右键菜单,$$ $$ \( \) \[ \] 中的公式给予显示-->
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
showMathMenu: false,
|
||||
showMathMenuMSIE: false,
|
||||
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body class="<%=h body_css_classes %>" style="background-color: #fff;">
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<%= yield %>
|
||||
</div>
|
||||
<%= call_hook :view_layouts_base_body_bottom %>
|
||||
</body>
|
||||
</html>
|
|
@ -7,7 +7,7 @@
|
|||
<meta name="keywords" content="issue,bug,tracker" />
|
||||
<%= csrf_meta_tag %>
|
||||
<%= favicon %>
|
||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'css/common', 'css/structure', 'css/font-awesome', :media => 'all' %>
|
||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'css/common', 'css/structure', 'css/font-awesome','//at.alicdn.com/t/font_930423_4z0tgi8hlb9.css', :media => 'all' %>
|
||||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||||
<%= javascript_heads %>
|
||||
<%= javascript_include_tag "bootstrap","avatars","new_user"%>
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
<% end %>
|
||||
<ul class="setting_left">
|
||||
<li><span style="color:red;">*</span> 登录名 : </li>
|
||||
|
||||
<% if @is_oauth && !@is_set_password %>
|
||||
<li>新密码 : </li>
|
||||
<li>确认密码 : </li>
|
||||
<% end %>
|
||||
|
||||
<li><span style="color:red;">*</span> 邮箱 : </li>
|
||||
<li><span style="color:red;">*</span> 职业 : </li>
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" ><span style="color:red;">*</span> 姓名 : </li>
|
||||
|
@ -50,6 +56,12 @@
|
|||
:class => "w210"
|
||||
%>
|
||||
</li>
|
||||
|
||||
<% if @is_oauth && !@is_set_password %>
|
||||
<li><input id="new_password" name="new_password" class="w210" type="password" required="true" nh_required="1"><span class="c_red ml5">请输入8-12个字符</span></li>
|
||||
<li><input id="new_password_confirmation" name="new_password_confirmation" class="w210" type="password" required="true" nh_required="1"></li>
|
||||
<% end %>
|
||||
|
||||
<% if @force %>
|
||||
<li><%= f.text_field :mail,:no_label=>true, :required => true,:nh_required => "1",:class=>"w210",:disabled=>'disabled'%></li>
|
||||
<% else %>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<% if false %>
|
||||
<p>当前用户: <%= current_user.login %></p>
|
||||
|
||||
<p>
|
||||
|
||||
</p>
|
||||
<% end %>
|
||||
<link href="//at.alicdn.com/t/font_930423_4z0tgi8hlb9.css" rel="stylesheet"/>
|
||||
<div class="authmain clearfix">
|
||||
<div class="l-r-trustie">
|
||||
<div class="clearfix" style="width: 100%;">
|
||||
<span class="fl mr20"><i class="iconfont f40 icon-oschina c_grey"></i></span>
|
||||
<div class="fl">
|
||||
<p><span class="c_blue">码云</span>将获得以下权限</p>
|
||||
<p><input type="checkbox" checked="checked" disabled class="checked-choose"/>获得您的昵称、头像、性别</p>
|
||||
<%= form_for oauth_authorize_path do%>
|
||||
<input type="hidden" name="gen_code" value="true">
|
||||
<input type="hidden" name="client_id" value="<%= @data["client_id"] %>">
|
||||
<input type="hidden" name="redirect_uri" value="<%= @data["redirect_uri"] %>">
|
||||
<input type="hidden" name="response_type" value="<%= @data["response_type"] %>">
|
||||
<input type="hidden" name="scope" value="<%= @data["scope"] %>">
|
||||
<input type="hidden" name="state" value="<%= @data["state"] %>">
|
||||
<button class="auth-login-btn mr20" type="submit">授权并登录</button>
|
||||
<% end %>
|
||||
<a href="<%= @data['redirect_uri'] %>?error=access_denied&error_description=用户或服务器拒绝了请求" class="auth-cancel-btn mr20">拒绝</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,300 @@
|
|||
<!DOCTYPE html><html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Trustie oauth2.0帮助</title>
|
||||
<style>
|
||||
html,body{ font-family: "SF UI Display", ".PingFang SC","PingFang SC", "Neue Haas Grotesk Text Pro", "Arial Nova", "Segoe UI", "Microsoft YaHei", "Microsoft JhengHei", "Helvetica Neue", "Source Han Sans SC", "Noto Sans CJK SC", "Source Han Sans CN", "Noto Sans SC", "Source Han Sans TC", "Noto Sans CJK TC", "Hiragino Sans GB", sans-serif;
|
||||
font-size: 16px;
|
||||
color:#222;
|
||||
-webkit-text-size-adjust:none; min-width: 200px;
|
||||
max-width: 760px;
|
||||
margin: 0 auto; padding: 1rem;
|
||||
line-height: 1.5rem;
|
||||
|
||||
}
|
||||
h1,h2,h3,h4,h5,h6{font-family: "PT Sans","SF UI Display", ".PingFang SC","PingFang SC", "Neue Haas Grotesk Text Pro", "Arial Nova", "Segoe UI", "Microsoft YaHei", "Microsoft JhengHei", "Helvetica Neue", "Source Han Sans SC", "Noto Sans CJK SC", "Source Han Sans CN", "Noto Sans SC", "Source Han Sans TC", "Noto Sans CJK TC", "Hiragino Sans GB", sans-serif;
|
||||
text-rendering:optimizelegibility;margin-bottom:1em;font-weight:bold; line-height: 1.8rem;
|
||||
|
||||
}
|
||||
h1,h2{position:relative;padding-top:1rem;padding-bottom:0.2rem;margin-bottom:1rem;
|
||||
border-bottom: solid 1px #eee;
|
||||
}
|
||||
h2{padding-top:0.8rem;padding-bottom:0.2rem;}
|
||||
h1{ font-size: 1.6rem;}
|
||||
h2{ font-size: 1.4rem;}
|
||||
h3{ font-size: 1.2rem;}
|
||||
h4{ font-size: 1.1rem;}
|
||||
h5{ font-size: 1.0rem;}
|
||||
h6{ font-size: 0.9rem;}
|
||||
|
||||
table{border-collapse:collapse;border-spacing:0;
|
||||
margin-top: 0.8rem;
|
||||
margin-bottom: 1.4rem;
|
||||
}
|
||||
tr{ background-color: #fff;
|
||||
border-top: 1px solid #ccc;}
|
||||
th,td{padding: 5px 14px;
|
||||
border: 1px solid #ddd;}
|
||||
|
||||
blockquote{font-style:italic;font-size:1.1em;line-height:1.5em;padding-left:1em; border-left:4px solid #D5D5D5; margin-left: 0;
|
||||
margin-right: 0;
|
||||
margin-bottom: 1.5rem; }
|
||||
|
||||
a{color:#1863a1}
|
||||
a:hover{color: #1b438d;}
|
||||
pre,code,p code,li code{font-family:Menlo,Monaco,"Andale Mono","lucida console","Courier New",monospace}
|
||||
|
||||
pre{-webkit-border-radius:0.4em;-moz-border-radius:0.4em;-ms-border-radius:0.4em;-o-border-radius:0.4em;border-radius:0.4em;border:1px solid #e7dec3;line-height:1.45em;font-size:0.9rem;margin-bottom:2.1em;padding:.8em 1em;color:#586e75;overflow:auto; background-color:#fdf6e3;}
|
||||
|
||||
p code,li code{display:inline-block;white-space:no-wrap;background:#fff;font-size:0.9rem;line-height:1.5em;color:#555;border:1px solid #ddd;-webkit-border-radius:0.4em;-moz-border-radius:0.4em;-ms-border-radius:0.4em;-o-border-radius:0.4em;border-radius:0.4em;padding:0 .3em;margin:-1px 4px;}
|
||||
p pre code,li pre code{font-size:1em !important;background:none;border:none}
|
||||
|
||||
img{max-width:100%;padding: 8px 0px;}
|
||||
|
||||
|
||||
hr {
|
||||
height: 0;
|
||||
margin: 15px 0;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
/* PrismJS 1.14.0
|
||||
https://prismjs.com/download.html#themes=prism-solarizedlight&languages=markup+css+clike+javascript */
|
||||
/*
|
||||
Solarized Color Schemes originally by Ethan Schoonover
|
||||
http://ethanschoonover.com/solarized
|
||||
|
||||
Ported for PrismJS by Hector Matos
|
||||
Website: https://krakendev.io
|
||||
Twitter Handle: https://twitter.com/allonsykraken)
|
||||
*/
|
||||
|
||||
/*
|
||||
SOLARIZED HEX
|
||||
--------- -------
|
||||
base03 #002b36
|
||||
base02 #073642
|
||||
base01 #586e75
|
||||
base00 #657b83
|
||||
base0 #839496
|
||||
base1 #93a1a1
|
||||
base2 #eee8d5
|
||||
base3 #fdf6e3
|
||||
yellow #b58900
|
||||
orange #cb4b16
|
||||
red #dc322f
|
||||
magenta #d33682
|
||||
violet #6c71c4
|
||||
blue #268bd2
|
||||
cyan #2aa198
|
||||
green #859900
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #657b83; /* base00 */
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
||||
background: #073642; /* base02 */
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
||||
background: #073642; /* base02 */
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background-color: #fdf6e3; /* base3 */
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: #93a1a1; /* base1 */
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #586e75; /* base01 */
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #268bd2; /* blue */
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.url,
|
||||
.token.inserted {
|
||||
color: #2aa198; /* cyan */
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
color: #657b83; /* base00 */
|
||||
background: #eee8d5; /* base2 */
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: #859900; /* green */
|
||||
}
|
||||
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: #b58900; /* yellow */
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important,
|
||||
.token.variable {
|
||||
color: #cb4b16; /* orange */
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers {
|
||||
position: relative;
|
||||
padding-left: 3.8em;
|
||||
counter-reset: linenumber;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers > code {
|
||||
position: relative;
|
||||
white-space: inherit;
|
||||
}
|
||||
|
||||
.line-numbers .line-numbers-rows {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
top: 0;
|
||||
font-size: 100%;
|
||||
left: -3.8em;
|
||||
width: 3em; /* works for line-numbers below 1000 lines */
|
||||
letter-spacing: -1px;
|
||||
border-right: 1px solid #999;
|
||||
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
}
|
||||
|
||||
.line-numbers-rows > span {
|
||||
pointer-events: none;
|
||||
display: block;
|
||||
counter-increment: linenumber;
|
||||
}
|
||||
|
||||
.line-numbers-rows > span:before {
|
||||
content: counter(linenumber);
|
||||
color: #999;
|
||||
display: block;
|
||||
padding-right: 0.8em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<style> @media print{ code[class*="language-"],pre[class*="language-"]{overflow: visible; word-wrap: break-word !important;} }</style></head><body><div class="markdown-body">
|
||||
<h1 id="toc_0">Trustie oauth2.0帮助</h1>
|
||||
|
||||
<p>目前提供授权码方式进行认证</p>
|
||||
|
||||
<h2 id="toc_1">步骤</h2>
|
||||
|
||||
<ol>
|
||||
<li><p>应用通过 浏览器 或 Webview 将用户引导到码云三方认证页面上( GET请求 )</p>
|
||||
<p><code>https://server/oauth/authorize?client_id={client_id}&redirect_uri={redirect_uri}&response_type=code</code></p></li>
|
||||
<li><p>用户对应用进行授权</p>
|
||||
<p>认证服务器通过回调地址<code>{redirect_uri}</code>将 用户授权码 传递给 应用服务器 或者直接在 Webview 中跳转到携带 用户授权码的回调地址上,Webview 直接获取code即可({redirect_uri}?code=abc&state=xyz)</p>
|
||||
<p>应用服务器 或 Webview 使用 access_token API 向 认证服务器发送post请求传入 用户授权码 以及 回调地址( POST请求 )</p>
|
||||
<p><code>https://server/oauth/token?grant_type=authorization_code&code={code}&client_id={client_id}&redirect_uri={redirect_uri}&client_secret={client_secret}</code></p></li>
|
||||
<li><p>认证服务器返回 <code>access_token</code></p></li>
|
||||
<li><p>应用通过 <code>access_token</code> 访问 Open API 使用用户数据。</p></li>
|
||||
</ol>
|
||||
|
||||
<h2 id="toc_2">api</h2>
|
||||
|
||||
<ol>
|
||||
<li>获取当前用户资料</li>
|
||||
</ol>
|
||||
|
||||
<p><code>/oauth/userinfo?access_token={access_token}</code></p>
|
||||
|
||||
<pre><code class="language-text">{
|
||||
token: 1,
|
||||
login: 'name',
|
||||
avatar_url: 'url',
|
||||
name: '张三',
|
||||
email: 'trustie@trustie.net'
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
</div></body>
|
||||
|
||||
</html>
|
|
@ -1,4 +1,4 @@
|
|||
//获取登录页面地址
|
||||
var signinPath = '<%= signin_url_without_domain %>';
|
||||
var htmlvalue = "</br><div style='width:550px;text-align:center'>您还没有登录,请登录后再执行此操作,谢谢!</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href="+signinPath+" class='Blue-btn fl' target='_Blank' onclick=' hideModal()' >登录</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>关闭</a></div>";
|
||||
var htmlvalue = "</br><div style='width:550px;text-align:center'>您还没有登录,请登录后再执行此操作,谢谢!</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='"+signinPath+"' class='Blue-btn fl' target='_Blank' onclick='hideModal()' >登录</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>关闭</a></div>";
|
||||
pop_up_box(htmlvalue,580,30,50);
|
|
@ -32,11 +32,15 @@
|
|||
<!--<textarea class="fl ml5 w690" style="height:192px; padding-top:5px;" id="project_description" name="project[description]" rows="8" placeholder="项目描述作为项目的简介,将始终显示在动态页的顶部 最多3000个汉字(或6000个英文字符)"><%= @project.description%></textarea>-->
|
||||
</li>
|
||||
<% if !@project.gpid.nil? && !@gitlab_branches.blank? %>
|
||||
<li class="clear">
|
||||
<li class="clear mb10">
|
||||
<label class="fl"> 默认分支 :</label>
|
||||
<%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch', :class => "ml5", :style => "height: 28px;" %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="clear">
|
||||
<label class="fl"> 语言 :</label>
|
||||
<%= select_tag :language, options_for_select(["","java","python","c#"], :selected => "#{@project.language}"), :id => 'language', :class => "ml5", :style => "height: 28px;" %>
|
||||
</li>
|
||||
<li class="clear">
|
||||
<label class="fl">公开 :</label>
|
||||
<input class="fl mt8 ml5" id="project_is_public" name="project[is_public]" type="checkbox" <%= @project.is_public ? "checked" : ""%>>
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
<div class="pro_new_prompt ml15 mr15 mb10"><p>温馨提示:每个项目只能创建一个版本库</p></div>
|
||||
<div class="pro_new_prompt ml15 mr15 mb10">
|
||||
<% if params[:create_error].present? %>
|
||||
<p><%= params[:create_error] %></p>
|
||||
<% else %>
|
||||
<p>温馨提示:每个项目只能创建一个版本库</p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if @gitlab_repository.nil? %>
|
||||
<div class="sy_new_tchbox clear">
|
||||
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project), :html => {:id => 'repository-form', :method=>"post", :autocomplete => 'off'} do |f| %>
|
||||
|
@ -38,16 +44,16 @@
|
|||
<tr>
|
||||
<th class="w130 pl10 pr10 hidden fl">版本库名</th>
|
||||
<th class="w90 pr10 hidden fl">管理系统</th>
|
||||
<th class="w490 hidden fl">库路径</th>
|
||||
<th class="w46 hidden fl"> </th>
|
||||
<th class="w450 hidden fl">库路径</th>
|
||||
<th class="w80 hidden fl"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="w130 pl10 pr10 hidden fl"><%= @gitlab_repository.identifier %></th>
|
||||
<th class="w90 pr10 hidden fl">Git</th>
|
||||
<th class="w490 hidden fl"><%=h @repos_url %></th>
|
||||
<th class="w46 hidden fl">
|
||||
<th class="w450 hidden fl"><%=h @repos_url %></th>
|
||||
<th class="w80 hidden fl">
|
||||
<% if is_project_manager?(User.current.id, @project.id) %>
|
||||
<%= link_to "删除", destroy_repository_project_path(@project), :class => "c_blue", :remote => true %>
|
||||
<% else %>
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
<div class="sy_teachers_txt fl ">
|
||||
<p class="clear mb5">
|
||||
<%= link_to_user_login(comment.author.try(:username), "pullreques_reply_name fl") %>
|
||||
<span class="fl ml15 c_grey"><%= time_tag(comment.created_at) %>前</span>
|
||||
</p>
|
||||
<p class="pullreques_reply_txt"><%= comment.note %></p>
|
||||
</div>
|
||||
|
|
|
@ -14,7 +14,13 @@
|
|||
<div class="c_grey clear mt5">
|
||||
<p class="fl">由 <%= link_to_user_login(request.author.try(:username), "linkBlue2") %> 创建于<%= time_tag(request.created_at) %>前</p>
|
||||
<span class="fl ml10"><%= time_tag(request.updated_at) %>前更新</span>
|
||||
<p class="fr"><%#= find_gitlab_project(request.source_project_id)+"/"+request.source_branch %><span class="c_grey02 ml10 mr10">合并到</span><%#= find_gitlab_project(request.target_project_id)+"/"+request.target_branch %></p>
|
||||
<%# 时间紧,待优化 %>
|
||||
<% qa = QualityAnalysis.where(:pull_request_id => request.id).first %>
|
||||
|
||||
<% if qa.present? %>
|
||||
<p class="fr"><%= link_to "执行过程", pr_console_project_pull_requests_path(:job_name => qa.sonar_name, :pr_id => request.id), :class => "linkBlue2 ml10 mr10", :target => "_blank" %></p>
|
||||
<p class="fr"><a class="linkBlue2 ml10 mr10" href="<%= Redmine::Configuration['sonar_address'] %>/dashboard/index/<%= qa.sonar_name %>" target="_blank">质量检测结果</a></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<div class="mt10 mb10">
|
||||
<div class="banner-big">
|
||||
<div class="f16 fontGrey3">执行过程</div>
|
||||
</div>
|
||||
<div class="container-big mt10 autoscroll" style="background: #403b3b; color: #e2e2e2;">
|
||||
<pre><%= @output.html_safe %></pre>
|
||||
</div>
|
||||
</div>
|
|
@ -20,7 +20,11 @@
|
|||
<% if @quality_analyses && @quality_analyses.count > 0 %>
|
||||
<% @quality_analyses.each do |qa| %>
|
||||
<tr>
|
||||
<td style="width:15%;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;padding-left: 5px;" title="<%= qa.sonar_name %>"><%=link_to qa.sonar_name, project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %></td>
|
||||
<td style="width:15%;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;padding-left: 5px;" title="<%= qa.sonar_name %>">
|
||||
<a href="<%= Redmine::Configuration['sonar_address'] + "/dashboard?id=#{qa.sonar_name}" %>" class="analysis-result-name fl fontBlue2 hidden" target="_blank">
|
||||
<%= qa.sonar_name %>
|
||||
</a>
|
||||
<%#=link_to qa.sonar_name, project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %></td>
|
||||
<td style="width:10%;"><%= qa.branch %></td>
|
||||
<td style="width:10%;"><%= qa.language %></td>
|
||||
<td style="width:25%;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" title="<%= qa.path %>"><%= qa.path %></td>
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
</td>
|
||||
<div id="children_tree">
|
||||
<td class="tree-author c_grey">
|
||||
<div class="hidden" id="changes_author_<%= tr_id %>">
|
||||
<%#= (latest_changes.author_name) if latest_changes %>
|
||||
</div>
|
||||
<!--<div class="hidden" id="changes_author_<%= tr_id %>">-->
|
||||
<!--<%#= (latest_changes.author_name) if latest_changes %>-->
|
||||
<!--</div>-->
|
||||
</td>
|
||||
<td class="tree-comments c_grey hidden">
|
||||
<div class="hidden" id="changes_message_<%= tr_id %>">
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<% if @changesets_latest_coimmit && @changesets_latest_coimmit.try(:time) %>
|
||||
<div class="recordBanner mt3">
|
||||
<%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.try(:author_email))), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
|
||||
<%= link_to_user_mail(@changesets_latest_coimmit.try(:author_email), "fb fontGrey3 mr5 fl hidden maxwidth150 ml5") %>
|
||||
<div class="fl">提交于 <%= time_tag(@changesets_latest_coimmit.try(:time)) %> 前:</div>
|
||||
<div class="commit_content_dec fl" title="<%= @changesets_latest_coimmit.message %>"><%= @changesets_latest_coimmit.message %></div>
|
||||
<% if @entry && @entry.kind == 'file' %>
|
||||
<div id="file_action" >
|
||||
<%= render :partial => 'link_to_functions' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @changesets_latest_coimmit.try(:id) %>
|
||||
<div class="edu-back-skyblue padding10-20 clearfix mt10">
|
||||
<div class="fl">
|
||||
<%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.try(:author_email))), :width => "30", :height => "30", :class => "radius fl mr10") %>
|
||||
<%= link_to_user_mail(@changesets_latest_coimmit.try(:author_email), "mr5") %>
|
||||
<span class="color-grey-6">提交于 <%= time_tag(@changesets_latest_coimmit.try(:created_at)) %> 前:<%= @changesets_latest_coimmit.try(:message) %></span>
|
||||
</div>
|
||||
<div id="file_action" class="recordBanner fr">
|
||||
<%= render :partial => 'link_to_functions' %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,6 +1,6 @@
|
|||
<% @statistics.each do |statistic| %>
|
||||
<div class="data_list_item cl pr">
|
||||
<%= image_tag(url_to_avatar(statistic.creator), :width => "50", :height => "50") %>
|
||||
<%=link_to image_tag(url_to_avatar(statistic.creator), :width => "50", :height => "50"), user_path(statistic.creator), :target => "_blank" %>
|
||||
<% if User.current.id == statistic.user_id || User.current.admin? %>
|
||||
<div class="homepagePostSetting" style="top: 10px;right: 12px">
|
||||
<ul>
|
||||
|
@ -19,7 +19,7 @@
|
|||
<%= render :partial => 'attachments',:locals => {:attachments => statistic.try(:attachments)} %>
|
||||
</div>
|
||||
<div class="data_info mt7 c_grey">
|
||||
<span><%= statistic.creator.show_name %></span>
|
||||
<span><%=link_to statistic.creator.show_name, user_path(statistic.creator), :target => "_blank" %></span>
|
||||
<span><%= statistic.main_category.name %></span>
|
||||
<% if statistic.sub_category.present? %>
|
||||
<span><%= statistic.sub_category.try(:name) %></span>
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
</div>
|
||||
<div class="data_showdetail mb20">
|
||||
<div class="detail_part mt15">
|
||||
<%= image_tag(url_to_avatar(@statistic.creator), :width => "50", :height => "50", :class =>"fl" ,:style =>"border-radius: 50%") %>
|
||||
<%=link_to image_tag(url_to_avatar(@statistic.creator), :width => "50", :height => "50", :class =>"fl" ,:style =>"border-radius: 50%"), user_path(@statistic.creator), :target => "_blank" %>
|
||||
<div class="fl color-grey8 ml15">
|
||||
<P class="color-grey3 f16 fb mb5"><%= @statistic.name %></P>
|
||||
<p class="f14">
|
||||
<span class="mr20"><%= @statistic.creator.show_name %></span>
|
||||
<span class="mr20"><%=link_to @statistic.creator.show_name, user_path(@statistic.creator), :target => "_blank" %></span>
|
||||
<span class="mr20"><%= @statistic.main_category.name %></span>
|
||||
<% if @statistic.sub_category.present? %>
|
||||
<span class="mr20"><%= @statistic.sub_category.try(:name) %></span>
|
||||
|
@ -42,7 +42,6 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var taskPassMD = editormd.markdownToHTML("statistic_description", {
|
||||
htmlDecode: "style,script,iframe", // you can filter tags decode
|
||||
taskList: true,
|
||||
|
@ -50,5 +49,4 @@
|
|||
flowChart: true, // 默认不解析
|
||||
sequenceDiagram: true // 默认不解析
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% is_member_work = @homework.homework_type == 3 && @work.student_work_projects.empty? %>
|
||||
<% is_member_work = @homework.homework_type == 3 && !@is_group_leader %>
|
||||
$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @new_score,:is_member_work => is_member_work}) %>");
|
||||
$('#score_<%= @work.id%>').peSlider({range: 'min'});
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
缺评扣分:<%= activity.homework_detail_manual.absence_penalty%>分/作品
|
||||
</div>
|
||||
<div class="homepagePostDeadline" style="float: right; margin-right: 220px;" id="evaluation_end_time_<%=user_activity_id %>">
|
||||
匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end.nil? ? '--' : (activity.homework_detail_manual.evaluation_end.to_s+" 00:00") %>
|
||||
匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end.nil? ? '--' : format_time(Time.parse("#{activity.homework_detail_manual.evaluation_end}") + 1.day - 1) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</li>
|
||||
<li class="mb10 clear">
|
||||
<label class="fl ml5"> 描述 : </label>
|
||||
<%= f.text_field :description, :maxlength => 60, :class=>"w650 fl", :style=>"height:28px;", :no_label => true %>
|
||||
<%= f.text_field :description, :class=>"w650 fl", :style=>"height:28px;", :no_label => true %>
|
||||
</li>
|
||||
<li class="mb10 clear">
|
||||
<label class=" fl"><span class="c_red f12">*</span> 日期 : </label>
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
<th>完成</th>
|
||||
<th>关闭</th>
|
||||
<th>待完成</th>
|
||||
<th>总工时</th>
|
||||
<th>工时债务</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -15,6 +17,8 @@
|
|||
<td><%= Issue.where(:fixed_version_id => @version.id, :status_id => 3).count %></td>
|
||||
<td><%= Issue.where(:fixed_version_id => @version.id, :status_id => 5).count %></td>
|
||||
<td><%= Issue.where(fixed_version_id: @version.id, status_id: [1,2,4]).count %></td>
|
||||
<td><%= l_hours(Issue.where(fixed_version_id: @version.id).sum(:estimated_hours)) %></td>
|
||||
<td><%= l_hours(Issue.where(fixed_version_id: @version.id, status_id: [1,2,4]).sum(:estimated_hours)) %></td>
|
||||
</tr>
|
||||
<% @version_issue_assigned_name.each do | assigned | %>
|
||||
<tr>
|
||||
|
@ -23,7 +27,10 @@
|
|||
<td><%= Issue.where(:fixed_version_id => @version.id, :assigned_to_id => assigned[0], :status_id => 3).count %></td>
|
||||
<td><%= Issue.where(:fixed_version_id => @version.id, :assigned_to_id => assigned[0], :status_id => 5).count %></td>
|
||||
<td><%= Issue.where(fixed_version_id: @version.id, assigned_to_id: assigned[0], status_id: [1,2,4]).count %></td>
|
||||
<td><%= l_hours(Issue.where(fixed_version_id: @version.id, assigned_to_id: assigned[0]).sum(:estimated_hours)) %></td>
|
||||
<td><%= l_hours(Issue.where(fixed_version_id: @version.id, assigned_to_id: assigned[0], status_id: [1,2,4]).sum(:estimated_hours)) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
</tbody>
|
||||
</table>
|
|
@ -58,6 +58,7 @@
|
|||
<tr>
|
||||
<th>ID</th>
|
||||
<th>标题</th>
|
||||
<th>工时</th>
|
||||
<th>类型</th>
|
||||
<th>指派给</th>
|
||||
<th>更新时间</th>
|
||||
|
@ -70,6 +71,7 @@
|
|||
<tr>
|
||||
<td>#<%= issue.id %></td>
|
||||
<td><a href="<%= issue_path(issue) %>" class="new_roadmap_info_title" title="<%= issue.subject %>" target="_blank"><%= issue.subject %></a> </td>
|
||||
<td><%= l_hours(issue.estimated_hours) %></td>
|
||||
<td> <%= issue.tracker %> </td>
|
||||
<td><a href="<%= issue.assigned_to_id.nil? ? "" : user_path(issue.assigned_to) %>" class="new_roadmap_info_name" target="_blank">
|
||||
<%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %></a>
|
||||
|
|
|
@ -1,235 +0,0 @@
|
|||
# = Redmine configuration file
|
||||
#
|
||||
# Each environment has it's own configuration options. If you are only
|
||||
# running in production, only the production block needs to be configured.
|
||||
# Environment specific configuration options override the default ones.
|
||||
#
|
||||
# Note that this file needs to be a valid YAML file.
|
||||
# DO NOT USE TABS! Use 2 spaces instead of tabs for identation.
|
||||
#
|
||||
# == Outgoing email settings (email_delivery setting)
|
||||
#
|
||||
# === Common configurations
|
||||
#
|
||||
# ==== Sendmail command
|
||||
#
|
||||
# production:
|
||||
# email_delivery:
|
||||
# delivery_method: :sendmail
|
||||
#
|
||||
# ==== Simple SMTP server at localhost
|
||||
#
|
||||
# production:
|
||||
# email_delivery:
|
||||
# delivery_method: :smtp
|
||||
# smtp_settings:
|
||||
# address: smtp.163.com
|
||||
# port: 25
|
||||
#
|
||||
# ==== SMTP server at example.com using LOGIN authentication and checking HELO for foo.com
|
||||
#
|
||||
# production:
|
||||
# email_delivery:
|
||||
# delivery_method: :smtp
|
||||
# smtp_settings:
|
||||
# address: smtp.gmail.com
|
||||
# port: 587
|
||||
# authentication: :login
|
||||
# domain: 'foo.com'
|
||||
# user_name: senluowanxiangt@gmail.com
|
||||
# password: 1913TXBja
|
||||
#
|
||||
# ==== SMTP server at example.com using PLAIN authentication
|
||||
#
|
||||
# production:
|
||||
# email_delivery:
|
||||
# delivery_method: :smtp
|
||||
# smtp_settings:
|
||||
# address: smtp.gmail.com
|
||||
# port: 587
|
||||
# authentication: :plain
|
||||
# domain: 'example.com'
|
||||
# user_name: senluowanxiangt@gmail.com
|
||||
# password: 1913TXBja
|
||||
#
|
||||
# ==== SMTP server at using TLS (GMail)
|
||||
#
|
||||
# This might require some additional configuration. See the guides at:
|
||||
# http://www.redmine.org/projects/redmine/wiki/EmailConfiguration
|
||||
#
|
||||
# production:
|
||||
# email_delivery:
|
||||
# delivery_method: :smtp
|
||||
# smtp_settings:
|
||||
# enable_starttls_auto: true
|
||||
# address: smtp.gmail.com
|
||||
# port: 587
|
||||
# domain: "smtp.gmail.com" # 'your.domain.com' for GoogleApps
|
||||
# authentication: :plain
|
||||
# user_name: senluowanxiangt@gmail.com
|
||||
# password: 1913TXBja
|
||||
#
|
||||
#
|
||||
# === More configuration options
|
||||
#
|
||||
# See the "Configuration options" at the following website for a list of the
|
||||
# full options allowed:
|
||||
#
|
||||
# http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer
|
||||
|
||||
|
||||
|
||||
default:
|
||||
email_delivery:
|
||||
delivery_method: :smtp
|
||||
smtp_settings:
|
||||
address: mail.trustie.net
|
||||
port: 25
|
||||
domain: mail.trustie.net
|
||||
authentication: :login
|
||||
user_name: "mail@trustie.net"
|
||||
password: "loong2010"
|
||||
|
||||
# Absolute path to the directory where attachments are stored.
|
||||
# The default is the 'files' directory in your Redmine instance.
|
||||
# Your Redmine instance needs to have write permission on this
|
||||
# directory.
|
||||
# Examples:
|
||||
# attachments_storage_path: /var/redmine/files
|
||||
# attachments_storage_path: D:/redmine/files
|
||||
attachments_storage_path:
|
||||
|
||||
# Configuration of the autologin cookie.
|
||||
# autologin_cookie_name: the name of the cookie (default: autologin)
|
||||
# autologin_cookie_path: the cookie path (default: /)
|
||||
# autologin_cookie_secure: true sets the cookie secure flag (default: false)
|
||||
autologin_cookie_name: "autologin_trustie"
|
||||
autologin_cookie_path:
|
||||
autologin_cookie_secure:
|
||||
|
||||
# Configuration of SCM executable command.
|
||||
#
|
||||
# Absolute path (e.g. /usr/local/bin/hg) or command name (e.g. hg.exe, bzr.exe)
|
||||
# On Windows + CRuby, *.cmd, *.bat (e.g. hg.cmd, bzr.bat) does not work.
|
||||
#
|
||||
# On Windows + JRuby 1.6.2, path which contains spaces does not work.
|
||||
# For example, "C:\Program Files\TortoiseHg\hg.exe".
|
||||
# If you want to this feature, you need to install to the path which does not contains spaces.
|
||||
# For example, "C:\TortoiseHg\hg.exe".
|
||||
#
|
||||
# Examples:
|
||||
# scm_subversion_command: svn # (default: svn)
|
||||
# scm_mercurial_command: C:\Program Files\TortoiseHg\hg.exe # (default: hg)
|
||||
# scm_git_command: /usr/local/bin/git # (default: git)
|
||||
# scm_cvs_command: cvs # (default: cvs)
|
||||
# scm_bazaar_command: bzr.exe # (default: bzr)
|
||||
# scm_darcs_command: darcs-1.0.9-i386-linux # (default: darcs)
|
||||
#
|
||||
scm_subversion_command:
|
||||
scm_mercurial_command:
|
||||
scm_git_command:
|
||||
scm_cvs_command:
|
||||
scm_bazaar_command:
|
||||
scm_darcs_command:
|
||||
|
||||
# Absolute path to the SCM commands errors (stderr) log file.
|
||||
# The default is to log in the 'log' directory of your Redmine instance.
|
||||
# Example:
|
||||
# scm_stderr_log_file: /var/log/redmine_scm_stderr.log
|
||||
scm_stderr_log_file:
|
||||
|
||||
# Key used to encrypt sensitive data in the database (SCM and LDAP passwords).
|
||||
# If you don't want to enable data encryption, just leave it blank.
|
||||
# WARNING: losing/changing this key will make encrypted data unreadable.
|
||||
#
|
||||
# If you want to encrypt existing passwords in your database:
|
||||
# * set the cipher key here in your configuration file
|
||||
# * encrypt data using 'rake db:encrypt RAILS_ENV=production'
|
||||
#
|
||||
# If you have encrypted data and want to change this key, you have to:
|
||||
# * decrypt data using 'rake db:decrypt RAILS_ENV=production' first
|
||||
# * change the cipher key here in your configuration file
|
||||
# * encrypt data using 'rake db:encrypt RAILS_ENV=production'
|
||||
database_cipher_key:
|
||||
|
||||
# Set this to false to disable plugins' assets mirroring on startup.
|
||||
# You can use `rake redmine:plugins:assets` to manually mirror assets
|
||||
# to public/plugin_assets when you install/upgrade a Redmine plugin.
|
||||
#
|
||||
#mirror_plugins_assets_on_startup: false
|
||||
|
||||
# Your secret key for verifying cookie session data integrity. If you
|
||||
# change this key, all old sessions will become invalid! Make sure the
|
||||
# secret is at least 30 characters and all random, no regular words or
|
||||
# you'll be exposed to dictionary attacks.
|
||||
#
|
||||
# If you have a load-balancing Redmine cluster, you have to use the
|
||||
# same secret token on each machine.
|
||||
#secret_token: 'change it to a long random string'
|
||||
|
||||
# Absolute path (e.g. /usr/bin/convert, c:/im/convert.exe) to
|
||||
# the ImageMagick's `convert` binary. Used to generate attachment thumbnails.
|
||||
imagemagick_convert_command: '/home/pdl/redmine-2.3.2-0/common/bin/convert'
|
||||
|
||||
# Configuration of RMagcik font.
|
||||
#
|
||||
# Redmine uses RMagcik in order to export gantt png.
|
||||
# You don't need this setting if you don't install RMagcik.
|
||||
#
|
||||
# In CJK (Chinese, Japanese and Korean),
|
||||
# in order to show CJK characters correctly,
|
||||
# you need to set this configuration.
|
||||
#
|
||||
# Because there is no standard font across platforms in CJK,
|
||||
# you need to set a font installed in your server.
|
||||
#
|
||||
# This setting is not necessary in non CJK.
|
||||
#
|
||||
# Examples for Japanese:
|
||||
# Windows:
|
||||
# rmagick_font_path: C:\windows\fonts\msgothic.ttc
|
||||
# Linux:
|
||||
# rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf
|
||||
#
|
||||
rmagick_font_path:
|
||||
|
||||
# Maximum number of simultaneous AJAX uploads
|
||||
#max_concurrent_ajax_uploads: 2
|
||||
#pic_types: "bmp,jpeg,jpg,png,gif"
|
||||
|
||||
repository_root_path: '/tmp/htdocs'
|
||||
judge_server: 'http://judge.trustie.net/'
|
||||
|
||||
# Git's url
|
||||
gitlab_address: 'http://gitfast.trustie.net'
|
||||
|
||||
# specific configuration options for production environment
|
||||
# that overrides the default ones
|
||||
production:
|
||||
# CJK support
|
||||
rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf
|
||||
judge_server: 'http://192.168.80.21:8080/'
|
||||
repository_root_path: '/home/pdl/redmine-2.3.2-0/apache2/htdocs'
|
||||
cookie_domain: ".trustie.net"
|
||||
email_delivery:
|
||||
delivery_method: :smtp
|
||||
smtp_settings:
|
||||
address: mail.trustie.net
|
||||
port: 25
|
||||
domain: mail.trustie.net
|
||||
authentication: :login
|
||||
user_name: "mail@trustie.net"
|
||||
password: "loong2010"
|
||||
|
||||
# specific configuration options for development environment
|
||||
# that overrides the default ones
|
||||
development:
|
||||
email_delivery:
|
||||
delivery_method: :smtp
|
||||
smtp_settings:
|
||||
address: mail.trustie.net
|
||||
port: 25
|
||||
domain: mail.trustie.net
|
||||
authentication: :login
|
||||
user_name: "mail@trustie.net"
|
||||
password: "loong2010"
|
|
@ -35,6 +35,7 @@ RedmineApp::Application.routes.draw do
|
|||
resources :statistics do
|
||||
collection do
|
||||
get 'get_sub_category'
|
||||
get 'sync_peking_data'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -543,6 +544,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'account/activate', :via => :get
|
||||
match 'account/valid_ajax', :via => :get
|
||||
match 'account/change_email', :via => :get
|
||||
match 'account/get_email_info', :to => 'account#get_email_info', :via => :get
|
||||
match 'account/email_valid', :to => 'account#email_valid', :via => :get
|
||||
match 'account/resendmail', :to => 'account#resendmail', :via=> :get, :as => 'resendmail'
|
||||
match 'account/codepedia_login', :to => 'account#codepedia_login', :via => [:get, :post]
|
||||
|
@ -552,6 +554,17 @@ RedmineApp::Application.routes.draw do
|
|||
#激活邮箱反馈问题
|
||||
match 'users/:id/leave_email_activation_message', :to => 'words#leave_email_activation_message', :via => :post, :as => "leave_email_activation_message"
|
||||
|
||||
## oschina登录相关
|
||||
match 'oschina/login', to: 'oschina#login', :via => :get
|
||||
match 'oschina/login_cb', to: 'oschina#login_callback', :via => [:get, :post]
|
||||
|
||||
## oauth相关
|
||||
match 'oauth', to: 'oauth#index'
|
||||
match 'oauth/authorize', to: 'oauth#authorize', :via => [:get, :post]
|
||||
match 'oauth/token', to: 'oauth#token', :via => :post
|
||||
match 'oauth/cb', to: 'oauth#test_callback', :via => :get
|
||||
match 'oauth/userinfo', to: 'oauth#get_userinfo', :via => :get
|
||||
|
||||
# boards
|
||||
match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
|
||||
match 'boards/:id/join_to_org_subfields', :to => 'boards#join_to_org_subfields'
|
||||
|
@ -1014,6 +1027,7 @@ RedmineApp::Application.routes.draw do
|
|||
|
||||
resources :pull_requests do
|
||||
collection do
|
||||
get 'pr_console'
|
||||
end
|
||||
member do
|
||||
get 'accept_pull_request'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddPullRequestIdToQualityAnalyses < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :quality_analyses, :pull_request_id, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddLanguageToProjects < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :projects, :language, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddJenkinsOutputToPullRequests < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :pull_requests, :jenkins_output, :longtext
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
class AddIndexToMessageAll < ActiveRecord::Migration
|
||||
def change
|
||||
remove_index :message_alls, name: 'index_message_alls_on_user_id_and_message_id_and_created_at'
|
||||
remove_index :message_alls, :message_type
|
||||
add_index :message_alls, [:message_id]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
class CreateOschinas < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :oschinas do |t|
|
||||
t.references :user
|
||||
|
||||
t.string :login
|
||||
t.string :name
|
||||
t.string :avatar_url
|
||||
t.string :email
|
||||
t.string :phone
|
||||
t.integer :oschina_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :oschinas, :user_id
|
||||
end
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
class CreateOauthConfigs < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :oauth_configs do |t|
|
||||
t.string :client_id
|
||||
t.string :client_secret
|
||||
t.string :redirect_uri
|
||||
t.string :scope
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
||||
OauthConfig.create(
|
||||
client_id: '88d893c5a345313e7b8c6fcf23d3d024ee08d5e41ce120c3448b6eea77d8de30',
|
||||
client_secret: 'e9240cc5fc913741db5aea93f2986a8ea0631bb67f7c00e41e491b95d9619e64',
|
||||
redirect_uri: 'http://localhost:3000/oschina/login_cb',
|
||||
scope: ''
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
class AddUserIdToOauths < ActiveRecord::Migration
|
||||
def change
|
||||
|
||||
create_table :oauths do |t|
|
||||
t.string :client_id
|
||||
t.string :client_secret
|
||||
t.string :code
|
||||
t.string :redirect_uri
|
||||
t.string :scope
|
||||
|
||||
t.string :access_token
|
||||
t.string :refresh_token
|
||||
t.integer :token_created_at
|
||||
t.integer :token_expires_in #过期时间
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
||||
add_column :oauths, :user_id, :integer, default: 0
|
||||
|
||||
add_index :oauths, :user_id
|
||||
end
|
||||
end
|
1561
db/schema.rb
1561
db/schema.rb
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Settings><!--This file was automatically generated by Ruby plugin.
|
||||
You are allowed to:
|
||||
1. Remove rake task
|
||||
2. Add existing rake tasks
|
||||
To add existing rake tasks automatically delete this file and reload the project.
|
||||
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
|
@ -1,4 +1,4 @@
|
|||
source 'http://gems.ruby-china.org/'
|
||||
source 'https://gems.ruby-china.com/'
|
||||
|
||||
gemspec
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Settings><!--This file was automatically generated by Ruby plugin.
|
||||
You are allowed to:
|
||||
1. Remove rake task
|
||||
2. Add existing rake tasks
|
||||
To add existing rake tasks automatically delete this file and reload the project.
|
||||
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
|
@ -1,4 +1,4 @@
|
|||
source 'http://gems.ruby-china.org/'
|
||||
source 'https://gems.ruby-china.com/'
|
||||
|
||||
# Specify your gem's dependencies in gitlab.gemspec
|
||||
gemspec
|
||||
|
|
|
@ -60,6 +60,10 @@ class Gitlab::Client
|
|||
put("/users/#{user_id}", :body => options)
|
||||
end
|
||||
|
||||
#
|
||||
def edit_user_mail(user_id, options={})
|
||||
put("/users/#{user_id}/email", :body => options)
|
||||
end
|
||||
|
||||
def delete_user(user_id)
|
||||
delete("/users/#{user_id}")
|
||||
|
|
|
@ -22,6 +22,7 @@ module Gitlab
|
|||
elsif body == true
|
||||
body
|
||||
else
|
||||
Rails.logger.info("11111111111111111################{body}")
|
||||
raise Error::Parsing.new "Couldn't parse a response body"
|
||||
end
|
||||
end
|
||||
|
@ -62,18 +63,18 @@ module Gitlab
|
|||
# Checks the response code for common errors.
|
||||
# Returns parsed response for successful requests.
|
||||
def validate(response)
|
||||
case response.code
|
||||
when 400; raise Error::BadRequest.new error_message(response)
|
||||
when 401; raise Error::Unauthorized.new error_message(response)
|
||||
when 403; raise Error::Forbidden.new error_message(response)
|
||||
when 404; raise Error::NotFound.new error_message(response)
|
||||
when 405; raise Error::MethodNotAllowed.new error_message(response)
|
||||
when 406; raise Error::DataNotAccepted.new error_message(response)
|
||||
when 409; raise Error::Conflict.new error_message(response)
|
||||
when 500; raise Error::InternalServerError.new error_message(response)
|
||||
when 502; raise Error::BadGateway.new error_message(response)
|
||||
when 503; raise Error::ServiceUnavailable.new error_message(response)
|
||||
end
|
||||
# case response.code
|
||||
# when 400; raise Error::BadRequest.new error_message(response)
|
||||
# when 401; raise Error::Unauthorized.new error_message(response)
|
||||
# when 403; raise Error::Forbidden.new error_message(response)
|
||||
# when 404; raise Error::NotFound.new error_message(response)
|
||||
# when 405; raise Error::MethodNotAllowed.new error_message(response)
|
||||
# when 406; raise Error::DataNotAccepted.new error_message(response)
|
||||
# when 409; raise Error::Conflict.new error_message(response)
|
||||
# when 500; raise Error::InternalServerError.new error_message(response)
|
||||
# when 502; raise Error::BadGateway.new error_message(response)
|
||||
# when 503; raise Error::ServiceUnavailable.new error_message(response)
|
||||
# end
|
||||
|
||||
response.parsed_response
|
||||
end
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Settings><!--This file was automatically generated by Ruby plugin.
|
||||
You are allowed to:
|
||||
1. Remove rake task
|
||||
2. Add existing rake tasks
|
||||
To add existing rake tasks automatically delete this file and reload the project.
|
||||
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
|
@ -1,4 +1,4 @@
|
|||
source 'http://gems.ruby-china.org/'
|
||||
source 'https://gems.ruby-china.com/'
|
||||
|
||||
gemspec
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
ref: refs/heads/master
|
|
@ -0,0 +1,6 @@
|
|||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = true
|
||||
ignorecase = true
|
||||
precomposeunicode = true
|
|
@ -0,0 +1 @@
|
|||
Unnamed repository; edit this file 'description' to name the repository.
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message taken by
|
||||
# applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit. The hook is
|
||||
# allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "applypatch-msg".
|
||||
|
||||
. git-sh-setup
|
||||
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
||||
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
||||
:
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message.
|
||||
# Called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero
|
||||
# status after issuing an appropriate message if it wants to stop the
|
||||
# commit. The hook is allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "commit-msg".
|
||||
|
||||
# Uncomment the below to add a Signed-off-by line to the message.
|
||||
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
||||
# hook is more suited to it.
|
||||
#
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||
|
||||
# This example catches duplicate Signed-off-by lines.
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare a packed repository for use over
|
||||
# dumb transports.
|
||||
#
|
||||
# To enable this hook, rename this file to "post-update".
|
||||
|
||||
exec git update-server-info
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed
|
||||
# by applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-applypatch".
|
||||
|
||||
. git-sh-setup
|
||||
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
||||
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
||||
:
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --bool hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/sh
|
||||
|
||||
# An example hook script to verify what is about to be pushed. Called by "git
|
||||
# push" after it has checked the remote status, but before anything has been
|
||||
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||
#
|
||||
# This hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- Name of the remote to which the push is being done
|
||||
# $2 -- URL to which the push is being done
|
||||
#
|
||||
# If pushing without using a named remote those arguments will be equal.
|
||||
#
|
||||
# Information about the commits which are being pushed is supplied as lines to
|
||||
# the standard input in the form:
|
||||
#
|
||||
# <local ref> <local sha1> <remote ref> <remote sha1>
|
||||
#
|
||||
# This sample shows how to prevent push of commits where the log message starts
|
||||
# with "WIP" (work in progress).
|
||||
|
||||
remote="$1"
|
||||
url="$2"
|
||||
|
||||
z40=0000000000000000000000000000000000000000
|
||||
|
||||
while read local_ref local_sha remote_ref remote_sha
|
||||
do
|
||||
if [ "$local_sha" = $z40 ]
|
||||
then
|
||||
# Handle delete
|
||||
:
|
||||
else
|
||||
if [ "$remote_sha" = $z40 ]
|
||||
then
|
||||
# New branch, examine all commits
|
||||
range="$local_sha"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_sha..$local_sha"
|
||||
fi
|
||||
|
||||
# Check for WIP commit
|
||||
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
|
||||
if [ -n "$commit" ]
|
||||
then
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,169 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2006, 2008 Junio C Hamano
|
||||
#
|
||||
# The "pre-rebase" hook is run just before "git rebase" starts doing
|
||||
# its job, and can prevent the command from running by exiting with
|
||||
# non-zero status.
|
||||
#
|
||||
# The hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- the upstream the series was forked from.
|
||||
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
||||
#
|
||||
# This sample shows how to prevent topic branches that are already
|
||||
# merged to 'next' branch from getting rebased, because allowing it
|
||||
# would result in rebasing already published history.
|
||||
|
||||
publish=next
|
||||
basebranch="$1"
|
||||
if test "$#" = 2
|
||||
then
|
||||
topic="refs/heads/$2"
|
||||
else
|
||||
topic=`git symbolic-ref HEAD` ||
|
||||
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||
fi
|
||||
|
||||
case "$topic" in
|
||||
refs/heads/??/*)
|
||||
;;
|
||||
*)
|
||||
exit 0 ;# we do not interrupt others.
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now we are dealing with a topic branch being rebased
|
||||
# on top of master. Is it OK to rebase it?
|
||||
|
||||
# Does the topic really exist?
|
||||
git show-ref -q "$topic" || {
|
||||
echo >&2 "No such branch $topic"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Is topic fully merged to master?
|
||||
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
||||
if test -z "$not_in_master"
|
||||
then
|
||||
echo >&2 "$topic is fully merged to master; better remove it."
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
fi
|
||||
|
||||
# Is topic ever merged to next? If so you should not be rebasing it.
|
||||
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
||||
only_next_2=`git rev-list ^master ${publish} | sort`
|
||||
if test "$only_next_1" = "$only_next_2"
|
||||
then
|
||||
not_in_topic=`git rev-list "^$topic" master`
|
||||
if test -z "$not_in_topic"
|
||||
then
|
||||
echo >&2 "$topic is already up-to-date with master"
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
||||
/usr/bin/perl -e '
|
||||
my $topic = $ARGV[0];
|
||||
my $msg = "* $topic has commits already merged to public branch:\n";
|
||||
my (%not_in_next) = map {
|
||||
/^([0-9a-f]+) /;
|
||||
($1 => 1);
|
||||
} split(/\n/, $ARGV[1]);
|
||||
for my $elem (map {
|
||||
/^([0-9a-f]+) (.*)$/;
|
||||
[$1 => $2];
|
||||
} split(/\n/, $ARGV[2])) {
|
||||
if (!exists $not_in_next{$elem->[0]}) {
|
||||
if ($msg) {
|
||||
print STDERR $msg;
|
||||
undef $msg;
|
||||
}
|
||||
print STDERR " $elem->[1]\n";
|
||||
}
|
||||
}
|
||||
' "$topic" "$not_in_next" "$not_in_master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
<<\DOC_END
|
||||
|
||||
This sample hook safeguards topic branches that have been
|
||||
published from being rewound.
|
||||
|
||||
The workflow assumed here is:
|
||||
|
||||
* Once a topic branch forks from "master", "master" is never
|
||||
merged into it again (either directly or indirectly).
|
||||
|
||||
* Once a topic branch is fully cooked and merged into "master",
|
||||
it is deleted. If you need to build on top of it to correct
|
||||
earlier mistakes, a new topic branch is created by forking at
|
||||
the tip of the "master". This is not strictly necessary, but
|
||||
it makes it easier to keep your history simple.
|
||||
|
||||
* Whenever you need to test or publish your changes to topic
|
||||
branches, merge them into "next" branch.
|
||||
|
||||
The script, being an example, hardcodes the publish branch name
|
||||
to be "next", but it is trivial to make it configurable via
|
||||
$GIT_DIR/config mechanism.
|
||||
|
||||
With this workflow, you would want to know:
|
||||
|
||||
(1) ... if a topic branch has ever been merged to "next". Young
|
||||
topic branches can have stupid mistakes you would rather
|
||||
clean up before publishing, and things that have not been
|
||||
merged into other branches can be easily rebased without
|
||||
affecting other people. But once it is published, you would
|
||||
not want to rewind it.
|
||||
|
||||
(2) ... if a topic branch has been fully merged to "master".
|
||||
Then you can delete it. More importantly, you should not
|
||||
build on top of it -- other people may already want to
|
||||
change things related to the topic as patches against your
|
||||
"master", so if you need further changes, it is better to
|
||||
fork the topic (perhaps with the same name) afresh from the
|
||||
tip of "master".
|
||||
|
||||
Let's look at this example:
|
||||
|
||||
o---o---o---o---o---o---o---o---o---o "next"
|
||||
/ / / /
|
||||
/ a---a---b A / /
|
||||
/ / / /
|
||||
/ / c---c---c---c B /
|
||||
/ / / \ /
|
||||
/ / / b---b C \ /
|
||||
/ / / / \ /
|
||||
---o---o---o---o---o---o---o---o---o---o---o "master"
|
||||
|
||||
|
||||
A, B and C are topic branches.
|
||||
|
||||
* A has one fix since it was merged up to "next".
|
||||
|
||||
* B has finished. It has been fully merged up to "master" and "next",
|
||||
and is ready to be deleted.
|
||||
|
||||
* C has not merged to "next" at all.
|
||||
|
||||
We would want to allow C to be rebased, refuse A, and encourage
|
||||
B to be deleted.
|
||||
|
||||
To compute (1):
|
||||
|
||||
git rev-list ^master ^topic next
|
||||
git rev-list ^master next
|
||||
|
||||
if these match, topic has not merged in next at all.
|
||||
|
||||
To compute (2):
|
||||
|
||||
git rev-list master..topic
|
||||
|
||||
if this is empty, it is fully merged to "master".
|
||||
|
||||
DOC_END
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to make use of push options.
|
||||
# The example simply echoes all push options that start with 'echoback='
|
||||
# and rejects all pushes when the "reject" push option is used.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-receive".
|
||||
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT"
|
||||
then
|
||||
i=0
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
|
||||
do
|
||||
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||
case "$value" in
|
||||
echoback=*)
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||
;;
|
||||
reject)
|
||||
exit 1
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare the commit log message.
|
||||
# Called by "git commit" with the name of the file that has the
|
||||
# commit message, followed by the description of the commit
|
||||
# message's source. The hook's purpose is to edit the commit
|
||||
# message file. If the hook fails with a non-zero status,
|
||||
# the commit is aborted.
|
||||
#
|
||||
# To enable this hook, rename this file to "prepare-commit-msg".
|
||||
|
||||
# This hook includes three examples. The first comments out the
|
||||
# "Conflicts:" part of a merge commit.
|
||||
#
|
||||
# The second includes the output of "git diff --name-status -r"
|
||||
# into the message, just before the "git status" output. It is
|
||||
# commented because it doesn't cope with --amend or with squashed
|
||||
# commits.
|
||||
#
|
||||
# The third example adds a Signed-off-by line to the message, that can
|
||||
# still be edited. This is rarely a good idea.
|
||||
|
||||
case "$2,$3" in
|
||||
merge,)
|
||||
/usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
|
||||
|
||||
# ,|template,)
|
||||
# /usr/bin/perl -i.bak -pe '
|
||||
# print "\n" . `git diff --cached --name-status -r`
|
||||
# if /^#/ && $first++ == 0' "$1" ;;
|
||||
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
|
@ -0,0 +1,128 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to block unannotated tags from entering.
|
||||
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
||||
#
|
||||
# To enable this hook, rename this file to "update".
|
||||
#
|
||||
# Config
|
||||
# ------
|
||||
# hooks.allowunannotated
|
||||
# This boolean sets whether unannotated tags will be allowed into the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowdeletetag
|
||||
# This boolean sets whether deleting tags will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowmodifytag
|
||||
# This boolean sets whether a tag may be modified after creation. By default
|
||||
# it won't be.
|
||||
# hooks.allowdeletebranch
|
||||
# This boolean sets whether deleting branches will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.denycreatebranch
|
||||
# This boolean sets whether remotely creating branches will be denied
|
||||
# in the repository. By default this is allowed.
|
||||
#
|
||||
|
||||
# --- Command line
|
||||
refname="$1"
|
||||
oldrev="$2"
|
||||
newrev="$3"
|
||||
|
||||
# --- Safety check
|
||||
if [ -z "$GIT_DIR" ]; then
|
||||
echo "Don't run this script from the command line." >&2
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Config
|
||||
allowunannotated=$(git config --bool hooks.allowunannotated)
|
||||
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
|
||||
denycreatebranch=$(git config --bool hooks.denycreatebranch)
|
||||
allowdeletetag=$(git config --bool hooks.allowdeletetag)
|
||||
allowmodifytag=$(git config --bool hooks.allowmodifytag)
|
||||
|
||||
# check for no description
|
||||
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||||
case "$projectdesc" in
|
||||
"Unnamed repository"* | "")
|
||||
echo "*** Project description file hasn't been set" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Check types
|
||||
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||||
zero="0000000000000000000000000000000000000000"
|
||||
if [ "$newrev" = "$zero" ]; then
|
||||
newrev_type=delete
|
||||
else
|
||||
newrev_type=$(git cat-file -t $newrev)
|
||||
fi
|
||||
|
||||
case "$refname","$newrev_type" in
|
||||
refs/tags/*,commit)
|
||||
# un-annotated tag
|
||||
short_refname=${refname##refs/tags/}
|
||||
if [ "$allowunannotated" != "true" ]; then
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,delete)
|
||||
# delete tag
|
||||
if [ "$allowdeletetag" != "true" ]; then
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,tag)
|
||||
# annotated tag
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
||||
then
|
||||
echo "*** Tag '$refname' already exists." >&2
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,commit)
|
||||
# branch
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,delete)
|
||||
# delete branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/remotes/*,commit)
|
||||
# tracking branch
|
||||
;;
|
||||
refs/remotes/*,delete)
|
||||
# delete tracking branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Anything else (is there anything else?)
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Finished
|
||||
exit 0
|
|
@ -0,0 +1,6 @@
|
|||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
5ca322560f72403ec54e015f2f41fb87a4c10945
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Settings><!--This file was automatically generated by Ruby plugin.
|
||||
You are allowed to:
|
||||
1. Remove rake task
|
||||
2. Add existing rake tasks
|
||||
To add existing rake tasks automatically delete this file and reload the project.
|
||||
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
|
@ -1,4 +1,4 @@
|
|||
source 'http://gems.ruby-china.org/'
|
||||
source 'https://gems.ruby-china.com/'
|
||||
|
||||
gemspec
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Settings><!--This file was automatically generated by Ruby plugin.
|
||||
You are allowed to:
|
||||
1. Remove rake task
|
||||
2. Add existing rake tasks
|
||||
To add existing rake tasks automatically delete this file and reload the project.
|
||||
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
|
@ -1,4 +1,4 @@
|
|||
source "http://gems.ruby-china.org/"
|
||||
source "https://gems.ruby-china.com/"
|
||||
|
||||
gemspec
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
rails_kindeditor (0.4.5)
|
||||
carrierwave
|
||||
mini_magick
|
||||
|
||||
GEM
|
||||
remote: https://gems.ruby-china.com/
|
||||
specs:
|
||||
activemodel (3.2.22.5)
|
||||
activesupport (= 3.2.22.5)
|
||||
builder (~> 3.0.0)
|
||||
activesupport (3.2.22.5)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
multi_json (~> 1.0)
|
||||
builder (3.0.0)
|
||||
carrierwave (0.11.2)
|
||||
activemodel (>= 3.2.0)
|
||||
activesupport (>= 3.2.0)
|
||||
json (>= 1.7)
|
||||
mime-types (>= 1.16)
|
||||
mimemagic (>= 0.3.0)
|
||||
i18n (0.6.11)
|
||||
json (1.8.6)
|
||||
mime-types (1.25.1)
|
||||
mimemagic (0.3.2)
|
||||
mini_magick (4.8.0)
|
||||
multi_json (1.13.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
carrierwave
|
||||
mini_magick
|
||||
rails_kindeditor!
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
|
@ -26,6 +26,65 @@ namespace :gitlab do
|
|||
end
|
||||
end
|
||||
|
||||
# 检查一个gitlab用户对应多个trustie用户的问题
|
||||
task :useless_user => :environment do
|
||||
# projects = Project.where(:id => [6286, 6292, 6293, 6294])
|
||||
ids = User.find_by_sql("select gid from users where gid is not null group by gid having count(gid) > 1").map(&:gid)
|
||||
users = User.where(:gid => ids)
|
||||
g = Gitlab.client
|
||||
# users = User.where(:gid => 8823)
|
||||
users.each do |user|
|
||||
puts "start"+ "#{user.id}"
|
||||
if Member.where("project_id >0 and user_id =?", user.id).blank? || g.user(user.gid).try(:username) != user.login
|
||||
puts user.id
|
||||
user.update_column(:gid, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 需要查出这样的用户,并且删除Gitlab中这样的用户
|
||||
task :sigle_useless_user => :environment do
|
||||
users = User.where("gid is not null")
|
||||
g = Gitlab.client
|
||||
# users = User.where(:gid => 8823)
|
||||
users.find_each do |user|
|
||||
# 没有创建或者加入过项目
|
||||
if Member.where("project_id >0 and user_id =?", user.id).blank? && g.user(user.gid).try(:username) != user.login
|
||||
puts user.id
|
||||
g.delete_user(user.gid)
|
||||
user.update_column(:gid, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 检查gitlab中username和trustie不一致的问题
|
||||
# 不一致的问题有一些是特殊符号导致的,比如:@、.等
|
||||
task :username => :environment do
|
||||
# projects = Project.where(:id => [6286, 6292, 6293, 6294])
|
||||
users = User.where("gid is not null")
|
||||
g = Gitlab.client
|
||||
# users = User.where(:gid => 8823)
|
||||
users.find_each do |user|
|
||||
if g.user(user.gid).try(:username) != user.login
|
||||
puts "start"+ "#{user.id}"
|
||||
g.edit_user(user.gid, :username => user.login)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 修复邮箱不一致的问题
|
||||
task :mail => :environment do
|
||||
users = User.where("gid is not null")
|
||||
g = Gitlab.client
|
||||
# users = User.where(:gid => 8823)
|
||||
users.find_each do |user|
|
||||
if g.user(user.gid).try(:email) != user.mail
|
||||
puts "start"+ "#{user.id}"
|
||||
g.edit_user_mail(user.gid, :email => user.mail)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "update user password"
|
||||
task :password => :environment do
|
||||
s = Trustie::Gitlab::Sync.new
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
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 and id not in (2,847,931,942)")
|
||||
projects.each do |project|
|
||||
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 "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
|
||||
end
|
||||
end
|
||||
# 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 and id not in (2,847,931,942)")
|
||||
# projects.each do |project|
|
||||
# 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 "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
|
||||
# end
|
||||
# end
|
||||
|
|
|
@ -1,32 +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
|
||||
# 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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue