diff --git a/Gemfile b/Gemfile
index 634af9683..91259aad8 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
-source 'https://rubygems.org'
+source 'https://ruby.taobao.org'
unless RUBY_PLATFORM =~ /w32/
# unix-like only
@@ -19,19 +19,33 @@ gem 'acts-as-taggable-on', '2.4.1'
group :development do
gem 'better_errors', path: 'lib/better_errors'
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
- if ENV['PRY']
- gem 'pry'
- gem 'pry-nav'
- end
end
group :test do
- # shoulda的版本做了改动
#gem "shoulda", "~> 3.3.2"
gem "shoulda", "> 3.3.2"
gem "mocha", "~> 0.13.3"
gem 'capybara', '~> 2.0.0'
gem 'nokogiri', '< 1.6.0'
+
+ platforms :mri, :mingw do
+ group :rmagick do
+ # RMagick 2 supports ruby 1.9
+ # RMagick 1 would be fine for ruby 1.8 but Bundler does not support
+ # different requirements for the same gem on different platforms
+ gem "rmagick", ">= 2.0.0"
+ end
+ end
+end
+
+group :development, :test do
+ gem "guard-rails"
+ gem 'spork-testunit'
+ gem 'guard-spork'
+ gem 'guard-test', '~> 1.0.0'
+ gem 'ruby-prof'
+ gem 'pry'
+ gem 'pry-nav'
end
@@ -53,15 +67,6 @@ group :ldap do
end
-platforms :mri, :mingw do
- group :rmagick do
- # RMagick 2 supports ruby 1.9
- # RMagick 1 would be fine for ruby 1.8 but Bundler does not support
- # different requirements for the same gem on different platforms
- gem "rmagick", ">= 2.0.0"
- end
-end
-
# Optional gem for OpenID authentication
group :openid do
gem "ruby-openid", "~> 2.1.4", :require => "openid"
diff --git a/Gemfile.lock b/Gemfile.lock
index d30eb7bc4..68c4f3587 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -19,7 +19,7 @@ PATH
rails
GEM
- remote: https://rubygems.org/
+ remote: https://ruby.taobao.org/
remote: https://rubygems.org/
specs:
actionmailer (3.2.13)
@@ -51,7 +51,7 @@ GEM
multi_json (~> 1.0)
acts-as-taggable-on (2.4.1)
rails (>= 3, < 5)
- arel (3.0.2)
+ arel (3.0.3)
builder (3.0.0)
capybara (2.0.3)
mime-types (>= 1.16)
@@ -60,6 +60,8 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 1.0.0)
+ celluloid (0.15.2)
+ timers (~> 1.1.0)
childprocess (0.5.3)
ffi (~> 1.0, >= 1.0.11)
climate_control (0.0.3)
@@ -70,14 +72,31 @@ GEM
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
- coffee-script (2.2.0)
+ coffee-script (2.3.0)
coffee-script-source
execjs
- coffee-script-source (1.7.0)
+ coffee-script-source (1.7.1)
erubis (2.7.0)
- execjs (2.0.2)
- fastercsv (1.5.0)
+ execjs (2.2.1)
+ fastercsv (1.5.5)
+ ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
+ formatador (0.2.5)
+ guard (2.6.1)
+ formatador (>= 0.2.4)
+ listen (~> 2.7)
+ lumberjack (~> 1.0)
+ pry (>= 0.9.12)
+ thor (>= 0.18.1)
+ guard-rails (0.5.2)
+ guard (~> 2.0)
+ guard-spork (1.5.1)
+ childprocess (>= 0.2.3)
+ guard (>= 1.1)
+ spork (>= 0.8.4)
+ guard-test (1.0.0)
+ guard (>= 1.8)
+ test-unit (~> 2.2)
hike (1.2.3)
htmlentities (4.3.2)
i18n (0.6.1)
@@ -85,36 +104,56 @@ GEM
jquery-rails (2.0.3)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
- json (1.8.0)
+ json (1.8.1)
kaminari (0.16.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
+ libv8 (3.16.14.3)
+ listen (2.7.9)
+ celluloid (>= 0.15.2)
+ rb-fsevent (>= 0.9.3)
+ rb-inotify (>= 0.9)
+ lumberjack (1.0.9)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.4)
- mime-types (1.23)
+ method_source (0.8.2)
+ mime-types (1.25.1)
mocha (0.13.3)
metaclass (~> 0.0.1)
- multi_json (1.7.6)
+ multi_json (1.10.1)
+ mysql2 (0.3.11)
mysql2 (0.3.11-x86-mingw32)
net-ldap (0.3.1)
+ nokogiri (1.5.11)
nokogiri (1.5.11-x86-mingw32)
paperclip (3.5.4)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
mime-types
- polyglot (0.3.3)
+ polyglot (0.3.5)
+ pry (0.9.12.6)
+ coderay (~> 1.0)
+ method_source (~> 0.8)
+ slop (~> 3.4)
+ pry (0.9.12.6-x86-mingw32)
+ coderay (~> 1.0)
+ method_source (~> 0.8)
+ slop (~> 3.4)
+ win32console (~> 1.3)
+ pry-nav (0.2.3)
+ pry (~> 0.9.10)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
- rack-openid (1.3.1)
+ rack-openid (1.4.2)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-raw-upload (1.1.1)
multi_json
- rack-ssl (1.3.3)
+ rack-ssl (1.3.4)
rack
rack-test (0.6.2)
rack (>= 1.0)
@@ -134,8 +173,12 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.3.2)
+ rb-fsevent (0.9.4)
+ rb-inotify (0.9.5)
+ ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
+ ref (1.0.5)
rich (1.4.6)
jquery-rails
kaminari
@@ -146,8 +189,9 @@ GEM
sass-rails
rmagick (2.13.2)
ruby-openid (2.1.8)
- rubyzip (1.1.4)
- sass (3.2.14)
+ ruby-prof (0.15.1)
+ rubyzip (1.1.6)
+ sass (3.3.10)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
@@ -163,25 +207,36 @@ GEM
shoulda-context (1.2.1)
shoulda-matchers (2.6.1)
activesupport (>= 3.0.0)
+ slop (3.5.0)
+ spork (0.9.2)
+ spork-testunit (0.0.8)
+ spork (>= 0.6.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- thor (0.18.1)
+ test-unit (2.5.5)
+ therubyracer (0.12.1)
+ libv8 (~> 3.16.14.0)
+ ref
+ thor (0.19.1)
tilt (1.4.1)
- treetop (1.4.14)
+ timers (1.1.0)
+ treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.37)
- uglifier (2.4.0)
+ tzinfo (0.3.40)
+ uglifier (2.5.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
websocket (1.0.7)
+ win32console (1.3.2-x86-mingw32)
xpath (1.0.0)
nokogiri (~> 1.3)
PLATFORMS
+ ruby
x86-mingw32
DEPENDENCIES
@@ -194,6 +249,9 @@ DEPENDENCIES
coderay (~> 1.0.6)
coffee-rails (~> 3.2.1)
fastercsv (~> 1.5.0)
+ guard-rails
+ guard-spork
+ guard-test (~> 1.0.0)
htmlentities
i18n (~> 0.6.0)
jquery-rails (~> 2.0.2)
@@ -203,14 +261,18 @@ DEPENDENCIES
net-ldap (~> 0.3.1)
nokogiri (< 1.6.0)
paperclip (~> 3.5.4)
+ pry
+ pry-nav
rack-mini-profiler!
rack-openid
rails (= 3.2.13)
rich (= 1.4.6)
rmagick (>= 2.0.0)
ruby-openid (~> 2.1.4)
+ ruby-prof
sass-rails (~> 3.2.3)
seems_rateable!
shoulda (> 3.3.2)
+ spork-testunit
therubyracer
uglifier (>= 1.0.3)
diff --git a/Guardfile b/Guardfile
new file mode 100644
index 000000000..75aa93c15
--- /dev/null
+++ b/Guardfile
@@ -0,0 +1,39 @@
+# More info at https://github.com/guard/guard#readme
+
+# guard 'rails' do
+# watch('Gemfile.lock')
+# watch(%r{^(config|lib)/.*})
+# end
+#
+guard 'spork', :test_unit => true, :test_unit_env => {'RAILS_ENV' => 'test'}, :wait => 60 do
+ watch('config/application.rb')
+ watch('config/environment.rb')
+ watch('config/environments/test.rb')
+ watch(%r{^config/initializers/.+\.rb$})
+ watch('Gemfile.lock')
+ watch('spec/spec_helper.rb') { :rspec }
+ watch('test/test_helper.rb') { :test_unit }
+ watch(%r{features/support/}) { :cucumber }
+end
+
+guard :test, :drb => true, :all_after_pass => false, :all_on_start => false do
+ watch(%r{^test/.+_test\.rb$})
+ watch('test/test_helper.rb') { 'test' }
+
+ # Non-rails
+ watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
+
+ # Rails 4
+ # watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
+ # watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
+ # watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" }
+ # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
+ # watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" }
+
+ # Rails < 4
+ watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
+ watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
+ watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" }
+ watch(%r{^app/views/.+$}) { 'test/integration' }
+ watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
+end
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index d87644e43..fea29759d 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -246,19 +246,21 @@ class AdminController < ApplicationController
@first_page.title = params[:title]
if @first_page.save
respond_to do |format|
+ flash[:notice] = l(:notice_successful_update)
format.html {
- flash[:notice] = l(:notice_successful_update)
redirect_to admin_first_page_made_path
}
format.api { render_api_ok }
+ #format.json { render json: @first_page, status: :created, location: @first_page }
end
else
respond_to do |format|
+ flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}"
format.html {
- first_page_made
render :action => 'first_page_made'
}
format.api { render_validation_errors(@first_page) }
+ #format.json { render json: @first_page.errors, status: :unprocessable_entity }
end
end
end
@@ -272,6 +274,7 @@ class AdminController < ApplicationController
@first_page = FirstPage.where("page_type = 'project'").first
@course_page = FirstPage.where("page_type = 'course'").first
@first_page.web_title = params[:web_title]
+ @course_page.web_title = params[:web_title]
@course_page.title = params[:course_title]
@course_page.description = params[:course_description]
if @first_page.save && @course_page.save
@@ -284,8 +287,10 @@ class AdminController < ApplicationController
end
else
respond_to do |format|
+ flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@course_page.errors.full_messages[0]}"
+ #flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}"
format.html {
- course_page_made
+
render :action => 'course_page_made'
}
format.api { render_validation_errors(@first_page) }
@@ -303,6 +308,7 @@ class AdminController < ApplicationController
@first_page = FirstPage.where("page_type = 'project'").first
@contest_page = FirstPage.where("page_type = 'contest'").first
@first_page.web_title = params[:web_title]
+ @contest_page.web_title = params[:web_title]
@contest_page.title = params[:contest_title]
@contest_page.description = params[:contest_description]
if @first_page.save && @contest_page.save
@@ -315,8 +321,8 @@ class AdminController < ApplicationController
end
else
respond_to do |format|
+ flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@contest_page.errors.full_messages[0]}"
format.html {
- contest_page_made
render :action => 'contest_page_made'
}
format.api { render_validation_errors(@first_page) }
diff --git a/app/controllers/avatar_controller.rb b/app/controllers/avatar_controller.rb
index 73c1dbd90..fa7eb6052 100644
--- a/app/controllers/avatar_controller.rb
+++ b/app/controllers/avatar_controller.rb
@@ -2,7 +2,7 @@ class AvatarController < ApplicationController
#before_filter :set_cache_buster
- include AvatarHelper
+ include AvatarHelper
def upload
# Make sure that API users get used to set this content type
@@ -77,6 +77,40 @@ class AvatarController < ApplicationController
}
end
end
+
+ #add by zjc
+ #删除图片
+ def delete_image
+ @source_type = params[:source_type]
+ @source_id = params[:source_id]
+ @source = nil #eval(@source_type).find(@source_id)
+ c = Object.const_get(@source_type)
+ if c.respond_to?(:find)
+ @source = c.find(@source_id)
+ end
+
+ diskfile=disk_filename(@source_type,@source_id)
+ unless diskfile.nil? || diskfile == ""
+ path = File.dirname(diskfile)
+ if File.directory?(path) && File.exist?(diskfile)
+ File.delete(diskfile)
+ end
+ end
+ rescue e do
+ logger.info e.message
+ end
+ respond_to do |format|
+ format.js
+ format.api {
+ if saved
+ render :action => 'upload', :status => :created
+ else
+ render_validation_errors(@avatar)
+ end
+ }
+ end
+
+ end
private
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index b86630d98..7588eef21 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -92,57 +92,74 @@ class RepositoriesController < ApplicationController
end
def create
- ##xianbo
- @root_path=RepositoriesHelper::ROOT_PATH
- @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
- @project_path=@root_path+"htdocs/"+@repository_name
- @repository_tag=params[:repository][:upassword]
- @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
- logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag
- logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
- attrs = pickup_extra_info
- if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
+ if params[:repository_scm].to_s == 'Gitlab'
+ # add by nwb
+ # 增加对gitlab版本库的支持
+ attrs = pickup_extra_info
+ @repository = Repository.factory('Git')
+ @repository.safe_attributes = params[:repository]
+ if attrs[:attrs_extra].keys.any?
+ @repository.merge_extra_info(attrs[:attrs_extra])
+ end
+ @repository.project = @project
+ if request.post? && @repository.save
+ redirect_to settings_project_path(@project, :tab => 'repositories')
+ else
+ render :action => 'new'
+ end
+ else # 原逻辑
+ ##xianbo
+ @root_path=RepositoriesHelper::ROOT_PATH
+ @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
+ @project_path=@root_path+"htdocs/"+@repository_name
+ @repository_tag=params[:repository][:upassword]
+ @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
+ logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag
+ logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
+ attrs = pickup_extra_info
+ if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
params[:repository][:url]=@project_path
- end
- ###xianbo
- @repository = Repository.factory(params[:repository_scm])
- @repository.safe_attributes = params[:repository]
- if attrs[:attrs_extra].keys.any?
- @repository.merge_extra_info(attrs[:attrs_extra])
- end
- #by xianbo
-
- @repository.project = @project
- if request.post? && @repository.save
- if(params[:repository_scm]=="Git")
- system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag
- system "echo -e '"+@repo_name+"-write:"+
- " "+@repo_name+"' >> "+@root_path+"group.passwd"
- system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s
- system "git init --bare "+@project_path
- system "mv "+@project_path+"/hooks/post-update{.sample,}"
- system "chmod a+x "+@project_path+"/hooks/post-update"
- system "echo -e 'Allow from all \n Order Deny,Allow \n "+
- "
-
diff --git a/app/views/admin/course_page_made.html.erb b/app/views/admin/course_page_made.html.erb index 4554fb8e0..7d73c7c6e 100644 --- a/app/views/admin/course_page_made.html.erb +++ b/app/views/admin/course_page_made.html.erb @@ -16,7 +16,7 @@
-
diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb index a64bbb443..d3b7416e4 100644 --- a/app/views/admin/first_page_made.html.erb +++ b/app/views/admin/first_page_made.html.erb @@ -16,7 +16,7 @@
-