From 8dd2d4a39a2f0bc5b6741f98dee0a0bac808e7cd Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 16 Aug 2013 22:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=89=88=E6=9C=AC=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 24 ++-- app/controllers/my_controller.rb | 14 +-- app/controllers/projects_controller.rb | 3 + app/controllers/repositories_controller.rb | 31 ++--- app/controllers/versions_controller.rb | 2 +- app/views/repositories/_form_create.html.erb | 3 +- app/views/repositories/show.html.erb | 10 +- app/views/versions/show.html.erb | 113 +++++++++++-------- config/locales/en.yml | 3 +- config/locales/zh.yml | 3 +- 10 files changed, 115 insertions(+), 91 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 47c65c052..f89e9a4dd 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -99,8 +99,8 @@ class AccountController < ApplicationController # User self-registration def register - @root_path="/home/pdl/redmine-2.3.2-0/apache2/" - + # @root_path="/home/pdl/redmine-2.3.2-0/apache2/" +# (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration] if request.get? session[:auth_source_registration] = nil @@ -125,16 +125,16 @@ class AccountController < ApplicationController @user.login = params[:user][:login] unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank? @user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation] - system "htpasswd -mb "+@root_path+"user.passwd "+params[:user][:login]+" "+user_params[:password] - system "echo -e '\n"+params[:user][:login]+"-write:"+ - " "+params[:user][:login]+"' >> "+@root_path+"group.passwd" - system "mkdir "+@root_path+"htdocs/"+params[:user][:login] - - system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - " \n"+ - "Require group "+params[:user][:login]+"-write \n "+ - " \n ' >>"+ - @root_path+"htdocs/"+params[:user][:login]+"/.htaccess" + # system "htpasswd -mb "+@root_path+"user.passwd "+params[:user][:login]+" "+user_params[:password] + # system "echo -e '\n"+params[:user][:login]+"-write:"+ + # " "+params[:user][:login]+"' >> "+@root_path+"group.passwd" + # system "mkdir "+@root_path+"htdocs/"+params[:user][:login] +# + # system "echo -e 'Allow from all \n Order Deny,Allow \n "+ + # " \n"+ + # "Require group "+params[:user][:login]+"-write \n "+ + # " \n ' >>"+ + # @root_path+"htdocs/"+params[:user][:login]+"/.htaccess" end case Setting.self_registration diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 4fa516820..62a8e4a4e 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -87,9 +87,7 @@ class MyController < ApplicationController # Manage user's password def password - @root_path="/home/pdl/redmine-2.3.2-0/apache2/" @user = User.current - @middle = "^"+@user.login.to_s+":" unless @user.change_password_allowed? flash[:error] = l(:notice_can_t_change_password) redirect_to my_account_path @@ -98,17 +96,7 @@ class MyController < ApplicationController if request.post? if @user.check_password?(params[:password]) @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] - @root_path="/home/pdl/redmine-2.3.2-0/apache2/" - system "sed -i /"+@middle+"/{d} "+@root_path+"user.passwd" - system "htpasswd -mb "+@root_path+"user.passwd "+@user.login.to_s+" "+params[:new_password] - system "echo -e '\n"+@user.login.to_s+"-write:"+ - " "+@user.login.to_s+"' >> "+@root_path+"group.passwd" - system "mkdir "+@root_path+"htdocs/"+@user.login.to_s - system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - " \n"+ - "Require group "+@user.login.to_s+"-write \n "+ - " \n ' >>"+ - @root_path+"htdocs/"+@user.login.to_s+"/.htaccess" + if @user.save flash[:notice] = l(:notice_account_password_updated) redirect_to my_account_path diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9fa7ddda6..9c67b4c9f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -355,7 +355,10 @@ class ProjectsController < ApplicationController format.html { redirect_to admin_projects_path } format.api { render_api_ok } end + else + render :layout => "base" end + # hide project in layout @project = nil end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 413e36af1..a2167bdf9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -75,16 +75,10 @@ class RepositoriesController < ApplicationController @root_path="/home/pdl/redmine-2.3.2-0/apache2/" @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @project_path=@root_path+"htdocs/"+@repository_name - @repository_tag=params[:repository][:url] + @repository_tag=params[:repository][:upassword] attrs = pickup_extra_info - if(!@repository_tag) - # params[:repository][:password]=params[:repository][:upassword] - if(params[:repository_scm]=="Git") - params[:repository][:url]=@project_path - end - # else - # render_error l(:error_scm_password_not_set); return - # render :action => 'newrepo' + if((@repository_tag!="")&¶ms[:repository_scm]=="Git") + params[:repository][:url]=@project_path end ###xianbo @repository = Repository.factory(params[:repository_scm]) @@ -97,10 +91,19 @@ class RepositoriesController < ApplicationController @repository.project = @project if request.post? && @repository.save if(params[:repository_scm]=="Git") - system "git init --bare "+@project_path - system "mv "+@project_path+"/hooks/post-update{.sample,}" - system "chmod a+x "+@project_path+"/hooks/post-update" - + system "htpasswd -mb "+@root_path+"user.passwd "+User.current.login.to_s+" "+@repository_tag + system "echo -e '\n"+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write:"+ + " "+User.current.login.to_s+"' >> "+@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 "+ + " \n"+ + "Require group "+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write \n "+ + " \n ' >> "+ + @root_path+"htdocs/"+ @repository_name+"/.htaccess" + puts "before ======================================================================" puts system "cd "+@project_path+" ;git update-server-info" flag = system "cd "+@project_path+" ;git update-server-info" @@ -108,7 +111,7 @@ class RepositoriesController < ApplicationController @repository.update_attributes(:login => User.current.login.to_s) end redirect_to settings_project_path(@project, :tab => 'repositories') - else if(!@repository_tag) + else if(@repository_tag) render :action => 'newrepo', :layout =>'base_projects' else render :action => 'new', :layout =>'base_projects' diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 18371f9f8..49e32ba17 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -185,7 +185,7 @@ class VersionsController < ApplicationController if ids = params[:tracker_ids] @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } else - @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s } + @selected_tracker_ids = (selectable_trackers).collect {|t| t.id.to_s } end end end diff --git a/app/views/repositories/_form_create.html.erb b/app/views/repositories/_form_create.html.erb index 9815db08b..89ae6ffd0 100644 --- a/app/views/repositories/_form_create.html.erb +++ b/app/views/repositories/_form_create.html.erb @@ -28,7 +28,8 @@ border:none <%= l(:text_repository_identifier_info).html_safe %> <% end %>

- +

<%= f.password_field :upassword, :required =>true, :label=> :field_password %> + <%= l(:label_upassword_info)%>

<%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index f6a0ef6c4..bd610bcdf 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -4,10 +4,18 @@ <%= render :partial => 'navigation' %> - +<% project_path_cut = 40 %> +<% ip = "repository.trustie.net" %>

<%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %> +
+ <%if @repository.type.to_s=="Repository::Git"%> + http://<%= @repository.login.to_s %>@<%= ip %><%=h @repository.url.slice(project_path_cut, @repository.url.length) %> + <%else %> + <%=h @repository.url %> + <% end %> +
<% if @repositories.size > 1 %>

(<%= l(:label_all_revisions) %><%= @repositories.sort.collect {|repo| diff --git a/app/views/versions/show.html.erb b/app/views/versions/show.html.erb index 2bc1eb90d..f6a0ef6c4 100644 --- a/app/views/versions/show.html.erb +++ b/app/views/versions/show.html.erb @@ -1,58 +1,77 @@ - -

-<%= link_to(l(:button_edit), edit_version_path(@version), :class => 'icon icon-edit') if User.current.allowed_to?(:manage_versions, @version.project) %> -<%= link_to_if_authorized(l(:button_edit_associated_wikipage, :page_title => @version.wiki_page_title), {:controller => 'wiki', :action => 'edit', :project_id => @version.project, :id => Wiki.titleize(@version.wiki_page_title)}, :class => 'icon icon-edit') unless @version.wiki_page_title.blank? || @version.project.wiki.nil? %> -<%= delete_link version_path(@version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)) if User.current.allowed_to?(:manage_versions, @version.project) %> -<%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %> +<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %> + +
+ <%= render :partial => 'navigation' %>
-

<%= h(@version.name) %>

-
-<%= render :partial => 'versions/overview', :locals => {:version => @version} %> -<%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %> +

+ <%= render :partial => 'breadcrumbs', + :locals => { :path => @path, :kind => 'dir', :revision => @rev } %> + <% if @repositories.size > 1 %> +

+ (<%= l(:label_all_revisions) %><%= @repositories.sort.collect {|repo| + link_to h(repo.name), + {:controller => 'repositories', :action => 'show', + :id => @project, :repository_id => repo.identifier_param, :rev => nil, :path => nil}, + :class => 'repository' + (repo == @repository ? ' selected' : '') + }.join(' | ').html_safe %>)

+ <% end %> +

+<% if !@entries.nil? && authorize_for('repositories', 'browse') %> + <%= render :partial => 'dir_list' %> +<% end %> +<%= render_properties(@properties) %> -<% if @issues.present? %> -<%= form_tag({}) do -%> - - - <%- @issues.each do |issue| -%> - - - - +<% if authorize_for('repositories', 'revisions') %> + <% if @changesets && !@changesets.empty? %> +

<%= l(:label_latest_revision_plural) %>

+ <%= render :partial => 'revisions', + :locals => {:project => @project, :path => @path, + :revisions => @changesets, :entry => nil }%> + <% end %> +

+ <% has_branches = (!@repository.branches.nil? && @repository.branches.length > 0) + sep = '' %> + <% if @repository.supports_all_revisions? && @path.blank? %> + <%= link_to l(:label_view_all_revisions), :action => 'revisions', :id => @project, + :repository_id => @repository.identifier_param %> + <% sep = '|' %> + <% end %> + <% if @repository.supports_directory_revisions? && + ( has_branches || !@path.blank? || !@rev.blank? ) %> + <%= sep %> + <%= link_to l(:label_view_revisions), + :action => 'changes', + :path => to_path_param(@path), + :id => @project, + :repository_id => @repository.identifier_param, + :rev => @rev %> + <% end %> +

+ <% if @repository.supports_all_revisions? %> + <% content_for :header_tags do %> + <%= auto_discovery_link_tag( + :atom, params.merge( + {:format => 'atom', :action => 'revisions', + :id => @project, :page => nil, :key => User.current.rss_key})) %> + <% end %> + + <% other_formats_links do |f| %> + <%= f.link_to 'Atom', + :url => {:action => 'revisions', :id => @project, + :repository_id => @repository.identifier_param, + :key => User.current.rss_key} %> + <% end %> <% end %> - -<% end %> -<%= context_menu issues_context_menu_path %> <% end %> -
-<% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %> -
<%= l(:label_time_tracking) %> - - - - - -<% if User.current.allowed_to?(:view_time_entries, @project) %> - - - - -<% end %> -
<%= l(:field_estimated_hours) %><%= html_hours(l_hours(@version.estimated_hours)) %>
<%= l(:label_spent_time) %><%= html_hours(l_hours(@version.spent_hours)) %>
-
+ + +<% content_for :header_tags do %> + <%= stylesheet_link_tag "scm" %> <% end %> -
-<%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %> -
-
-
- -<%= call_hook :view_versions_show_bottom, :version => @version %> - -<% html_title @version.name %> +<% html_title(l(:label_repository)) -%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 838e74d92..c04402ce9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1245,4 +1245,5 @@ en: label_tags_numbers: Tag numbers: label_max_number: Must be at most 25 characters long. label_all_revisions: All revisions: - label_repository_name: Repository name \ No newline at end of file + label_repository_name: Repository name + label_upassword_info: The password can be shared in the group diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 6d220779d..383d3347f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1257,4 +1257,5 @@ zh: label_tags_user_mail: 用户邮箱: label_tags_numbers: Tag统计: label_max_number: 至多25个字符。 - label_all_revisions: 所有版本: \ No newline at end of file + label_all_revisions: 所有版本: + label_upassword_info: 该密码在项目组内可共享