Merge remote-tracking branch 'origin/sw_new_course' into sw_new_course

sw_new_course
lizanle 10 years ago
commit 9a2e9a4ad2

@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
gem 'iconv' gem 'iconv'
end end
gem 'grack', path:'./lib/grack'
gem 'rest-client' gem 'rest-client'
gem "mysql2", "= 0.3.18" gem "mysql2", "= 0.3.18"
gem 'redis-rails' gem 'redis-rails'

@ -127,19 +127,18 @@ update
end end
else # 原逻辑 else # 原逻辑
##xianbo ##xianbo
params[:repository_scm] = "Git"
@root_path=RepositoriesHelper::ROOT_PATH @root_path=RepositoriesHelper::ROOT_PATH
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
@project_path=@root_path+"htdocs/"+@repository_name @project_path=@root_path+"htdocs/"+@repository_name
@repository_tag=params[:repository][:upassword] || params[:repository][:password] @repository_tag=params[:repository][:upassword] || params[:repository][:password] || '1234'
@repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag
logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
attrs = pickup_extra_info attrs = pickup_extra_info
if((@repository_tag!="")&&params[:repository_scm]=="Git") params[:repository][:url]=@project_path
params[:repository][:url]=@project_path
end
###xianbo ###xianbo
@repository = Repository.factory(params[:repository_scm]) @repository = Repository.factory(params[:repository_scm]||"Git")
@repository.safe_attributes = params[:repository] @repository.safe_attributes = params[:repository]
if attrs[:attrs_extra].keys.any? if attrs[:attrs_extra].keys.any?
@repository.merge_extra_info(attrs[:attrs_extra]) @repository.merge_extra_info(attrs[:attrs_extra])
@ -278,7 +277,8 @@ update
@course_tag = params[:course] @course_tag = params[:course]
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
ip = RepositoriesHelper::REPO_IP_ADDRESS ip = RepositoriesHelper::REPO_IP_ADDRESS
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ # @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+
@repos_url = "http://#{Setting.host_name}/#{@repository.login.to_s}/#{@repository.identifier.to_s}.git"
@repository.url.slice(project_path_cut, @repository.url.length).to_s @repository.url.slice(project_path_cut, @repository.url.length).to_s
if @course_tag == 1 if @course_tag == 1
render :action => 'show', :layout => 'base_courses' render :action => 'show', :layout => 'base_courses'

@ -45,7 +45,7 @@ class UsersController < ApplicationController
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist, :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,
:user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course, :user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course,
:search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project] :search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages]
#edit has been deleted by huang, 2013-9-23 #edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
@ -177,7 +177,7 @@ class UsersController < ApplicationController
return return
end end
respond_to do |format| respond_to do |format|
format.html{render :layout=>'base_users_new'} format.html{render :layout=>'new_base_user'}
end end
end end

@ -19,7 +19,7 @@
module RepositoriesHelper module RepositoriesHelper
if Rails.env.development? if Rails.env.development?
ROOT_PATH="/tmp/" if Rails.env.development? ROOT_PATH="/private/tmp/"
else else
ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/" ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/"
end end

@ -38,7 +38,10 @@
</ul> </ul>
</div> </div>
<div class="navHomepageNews"> <div class="navHomepageNews">
<a href="javascript:void(0);" class="homepageNewsIcon"> <%= link_to image_tag("/images/news_icon_small.png" , :width => "21", :height => "24"), {:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %>
<% if User.current.count_new_message >0 %>
<div class="newsActive"></div>
<% end %>
<div class="newsActive"></div> <div class="newsActive"></div>
</a></div> </div>
</div> </div>

@ -10,7 +10,7 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_public', 'user_leftside', :media => 'all' %> <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_public', 'user_leftside', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %> <%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","user"%> <%= javascript_include_tag "bootstrap","avatars","new_user"%>
<%= heads_for_theme %> <%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %> <%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%> <%= yield :header_tags -%>

@ -62,15 +62,6 @@
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post"} do |f| %> <%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post"} do |f| %>
<div id="pro_st_edit_ku" class="pro_st_edit_ku"> <div id="pro_st_edit_ku" class="pro_st_edit_ku">
<ul> <ul>
<li >
<label class="label02"><%=l(:label_scm)%></label>
<%= select_tag('repository_scm',
options_for_select(["Git"],@repository.class.name.demodulize),
:data => {:remote => true, :method => 'get'})%>
<% if @repository && ! @repository.class.scm_available %>
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
<% end %>
</li>
<% unless judge_main_repository(@project) %> <% unless judge_main_repository(@project) %>
<li> <li>
<label class="label02"><%=l(:field_repository_is_default)%></label> <label class="label02"><%=l(:field_repository_is_default)%></label>
@ -84,14 +75,9 @@
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span> <span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span>
<% end %> <% end %>
</li> </li>
<li >
<label class="label02"><span class="c_red">*</span><%=l(:label_password)%></label>
<%= f.password_field :upassword, :label=> "", :no_label => true %>
<span class="c_grey"><%= l(:label_upassword_info)%></span>
</li>
<div class="cl"></div> <div class="cl"></div>
</ul> </ul>
<a href="#" onclick="$('#repository-form').submit();" class="blue_btn fl ml110"><%=l(:button_save)%></a> <a href="#" onclick="$('#repository-form').submit();" class="blue_btn fl ml110"><%=l(:button_save)%></a>
<a href="<%= settings_project_path(@project, :tab => 'repositories')%>" class="grey_btn fl ml10"><%=l(:button_cancel)%></a> <a href="<%= settings_project_path(@project, :tab => 'repositories')%>" class="grey_btn fl ml10"><%=l(:button_cancel)%></a>
</div><!--pro_st_edit_issues end--> </div><!--pro_st_edit_issues end-->
<% end %> <% end %>

@ -33,8 +33,9 @@
<div id="repos_git_more"> <div id="repos_git_more">
<br> <br>
<div class=" c_dark f14"> <div class=" c_dark f14">
<p color="red">git 克隆和提交的用户名和密码为登录用户名和密码 </p>
<p>项目代码请设置好正确的编码方式utf-8否则中文会出现乱码。</p> <p>项目代码请设置好正确的编码方式utf-8否则中文会出现乱码。</p>
<p>通过cmd命令提示符进入代码对应文件夹的根目录假设当前用户的登录名为user版本库名称为demo需要操作的版本库分支为branch。 <p>通过cmd命令提示符进入代码对应文件夹的根目录
如果是首次提交代码,执行如下命令:</p> 如果是首次提交代码,执行如下命令:</p>
</div> </div>
<div class="repos_explain"> <div class="repos_explain">
@ -45,19 +46,19 @@
<p>git commit -m "first commit"</p> <p>git commit -m "first commit"</p>
<p>git remote add origin <p>git remote add origin
http://user_demo@repository.trustie.net/user/demo.git <%= @repos_url %>
</p> </p>
<p>git config http.postBuffer 524288000 #设置本地post缓存为500MB</p> <p>git config http.postBuffer 524288000 #设置本地post缓存为500MB</p>
<p>git push -u origin branch:branch</p> <p>git push -u origin master</p>
</div> </div>
<!--repos_explain end--> <!--repos_explain end-->
<div class="c_dark f14"> <div class="c_dark f14">
<p>已经有本地库,还没有配置远程地址,打开命令行执行如下:</p> <p>已经有本地库,还没有配置远程地址,打开命令行执行如下:</p>
</div> </div>
<div class="repos_explain"> <div class="repos_explain">
<p>git remote add origin http://user_demo@repository.trustie.net/user/demo.git</p> <p>git remote add origin <%= @repos_url %></p>
<p>git add .</p> <p>git add .</p>
@ -65,14 +66,14 @@
<p>git config http.postBuffer 524288000 #设置本地post缓存为500MB</p> <p>git config http.postBuffer 524288000 #设置本地post缓存为500MB</p>
<p>git push -u origin branch:branch</p> <p>git push -u origin master</p>
</div> </div>
<!--repos_explain end--> <!--repos_explain end-->
<div class="c_dark f14"> <div class="c_dark f14">
<p>已有远程地址,创建一个远程分支,并切换到该分支,打开命令行执行如下:</p> <p>已有远程地址,创建一个远程分支,并切换到该分支,打开命令行执行如下:</p>
</div> </div>
<div class="repos_explain"> <div class="repos_explain">
<p>git clone http://user_demo@repository.trustie.net/user/demo.git</p> <p>git clone <%= @repos_url %></p>
<p>git push</p> <p>git push</p>
@ -86,7 +87,7 @@
</div> </div>
<div class="repos_explain"> <div class="repos_explain">
<p>git remote add trustie <p>git remote add trustie
http://user_demo@repository.trustie.net/user/demo.git <%= @repos_url %>
</p> </p>
<p>git add .</p> <p>git add .</p>

@ -228,7 +228,7 @@
<%# 用户留言消息 %> <%# 用户留言消息 %>
<% unless @user_feedback_messages.nil? %> <% unless @user_feedback_messages.nil? %>
<% @user_feedback_messages.each do |ufm| %> <% @user_feedback_messages.each do |ufm| %>
<% if ufm.journals_for_message_type == "Principal" %> <% if ufm.journals_for_message_type == "JournalsForMessage" %>
<ul class="homepageNewsList fl"> <ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"> <li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(ufm.journals_for_message.user), :width => "30", :height => "30") %></a> <a href="javascript:void(0);"><%= image_tag(url_to_avatar(ufm.journals_for_message.user), :width => "30", :height => "30") %></a>

@ -197,9 +197,12 @@ default:
#max_concurrent_ajax_uploads: 2 #max_concurrent_ajax_uploads: 2
#pic_types: "bmp,jpeg,jpg,png,gif" #pic_types: "bmp,jpeg,jpg,png,gif"
repository_root_path: '/tmp/htdocs'
# specific configuration options for production environment # specific configuration options for production environment
# that overrides the default ones # that overrides the default ones
production: production:
repository_root_path: '/home/pdl/redmine-2.3.2-0/apache2/htdocs'
cookie_domain: ".trustie.net" cookie_domain: ".trustie.net"
rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf
email_delivery: email_delivery:

@ -28,6 +28,9 @@
RedmineApp::Application.routes.draw do RedmineApp::Application.routes.draw do
mount Mobile::API => '/api' mount Mobile::API => '/api'
# Enable Grack support
mount Trustie::Grack.new, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
resources :homework_users resources :homework_users
resources :no_uses resources :no_uses
delete 'no_uses', :to => 'no_uses#delete' delete 'no_uses', :to => 'no_uses#delete'

@ -0,0 +1,14 @@
language: ruby
env:
- TRAVIS=true
branches:
only:
- 'master'
rvm:
- 1.9.3-p327
- 2.0.0
before_script:
- "bundle install"
- "git submodule init"
- "git submodule update"
script: "bundle exec rake"

@ -0,0 +1,16 @@
2.0.2
- Revert MR that broke smart HTTP clients.
2.0.1
- Make sure child processes get reaped after popen, again.
2.0.0
- Use safer shell commands and avoid Dir.chdir
- Restrict the environment for shell commands
- Make Grack::Server thread-safe (zimbatm)
- Make sure child processes get reaped after popen
- Verify requested path is actually a Git directory (Ryan Canty)
1.1.0
- Modifies service_rpc to use chunked transfer (https://github.com/gitlabhq/grack/pull/1)

@ -0,0 +1,10 @@
source "http://ruby.taobao.org"
gemspec
group :development do
gem 'byebug'
gem 'rake'
gem 'pry'
gem 'rack-test'
end

@ -0,0 +1,37 @@
PATH
remote: .
specs:
gitlab-grack (2.0.2)
rack (~> 1.5.1)
GEM
remote: http://ruby.taobao.org/
specs:
byebug (4.0.5)
columnize (= 0.9.0)
coderay (1.1.0)
columnize (0.9.0)
metaclass (0.0.1)
method_source (0.8.2)
mocha (0.14.0)
metaclass (~> 0.0.1)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rake (10.1.0)
slop (3.6.0)
PLATFORMS
ruby
DEPENDENCIES
byebug
gitlab-grack!
mocha (~> 0.11)
pry
rack-test
rake

@ -0,0 +1,95 @@
Grack - Ruby/Rack Git Smart-HTTP Server Handler
===============================================
[![Build Status](https://travis-ci.org/gitlabhq/grack.png)](https://travis-ci.org/gitlabhq/grack)
[![Code Climate](https://codeclimate.com/github/gitlabhq/grack.png)](https://codeclimate.com/github/gitlabhq/grack)
This project aims to replace the builtin git-http-backend CGI handler
distributed with C Git with a Rack application. This reason for doing this
is to allow far more webservers to be able to handle Git smart http requests.
The default git-http-backend only runs as a CGI script, and specifically is
only targeted for Apache 2.x usage (it requires PATH_INFO to be set and
specifically formatted). So, instead of trying to get it to work with
other CGI capable webservers (Lighttpd, etc), we can get it running on nearly
every major and minor webserver out there by making it Rack capable. Rack
applications can run with the following handlers:
* CGI
* FCGI
* Mongrel (and EventedMongrel and SwiftipliedMongrel)
* WEBrick
* SCGI
* LiteSpeed
* Thin
These web servers include Rack handlers in their distributions:
* Ebb
* Fuzed
* Phusion Passenger (which is mod_rack for Apache and for nginx)
* Unicorn
* Puma
With [Warbler](http://caldersphere.rubyforge.org/warbler/classes/Warbler.html),
and JRuby, we can also generate a WAR file that can be deployed in any Java
web application server (Tomcat, Glassfish, Websphere, JBoss, etc).
Since the git-http-backend is really just a simple wrapper for the upload-pack
and receive-pack processes with the '--stateless-rpc' option, it does not
actually re-implement very much.
Dependencies
========================
* Ruby - http://www.ruby-lang.org
* Rack - http://rack.rubyforge.org
* A Rack-compatible web server
* Git >= 1.7 (currently the 'pu' branch)
* Mocha (only for running the tests)
Quick Start
========================
$ gem install rack
$ (edit config.ru to set git project path)
$ rackup --host 127.0.0.1 -p 8080 config.ru
$ git clone http://127.0.0.1:8080/schacon/grit.git
Contributing
========================
If you would like to contribute to the Grack project, I prefer to get
pull-requests via GitHub. You should include tests for whatever functionality
you add. Just fork this project, push your changes to your fork and click
the 'pull request' button. To run the tests, you first need to install the
'mocha' mocking library and initialize the submodule.
$ sudo gem install mocha
$ git submodule init
$ git submodule update
Then you should be able to run the tests with a 'rake' command. You can also
run coverage tests with 'rake rcov' if you have rcov installed.
License
========================
(The MIT License)
Copyright (c) 2009 Scott Chacon <schacon@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,27 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
task :default => :test
desc "Run the tests."
task :test do
Dir.glob("tests/*_test.rb").each do |f|
system "ruby #{f}"
end
end
desc "Run test coverage."
task :rcov do
system "rcov tests/*_test.rb -i lib/git_http.rb -x rack -x Library -x tests"
system "open coverage/index.html"
end
namespace :grack do
desc "Start Grack"
task :start do
system('./bin/testserver')
end
end
desc "Start everything."
multitask :start => [ 'grack:start' ]

@ -0,0 +1,6 @@
#! /bin/bash
set -e
cd $(dirname "$0")/..
exec /usr/bin/env bundle exec pry -Ilib -r grack

@ -0,0 +1,24 @@
#! /usr/bin/env ruby
libdir = File.absolute_path( File.join( File.dirname(__FILE__), '../lib' ) )
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
Bundler.require(:default, :development)
require 'grack'
require 'rack'
root = File.absolute_path( File.join( File.dirname(__FILE__), '../examples' ) )
app = Grack::Server.new({
project_root: root,
upload_pack: true,
receive_pack:true
})
app1= Rack::Builder.new do
use Grack::Auth do |username, password|
[username, password] == ['123', '455']
end
run app
end
Rack::Server.start app: app1, Port: 3001

@ -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
test -x "$GIT_DIR/hooks/commit-msg" &&
exec "$GIT_DIR/hooks/commit-msg" ${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

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save