修正版本库

This commit is contained in:
Administrator 2013-08-16 22:43:44 +08:00
parent 6977c851fb
commit 8dd2d4a39a
10 changed files with 115 additions and 91 deletions

View File

@ -99,8 +99,8 @@ class AccountController < ApplicationController
# User self-registration # User self-registration
def register 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] (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
if request.get? if request.get?
session[:auth_source_registration] = nil session[:auth_source_registration] = nil
@ -125,16 +125,16 @@ class AccountController < ApplicationController
@user.login = params[:user][:login] @user.login = params[:user][:login]
unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank? 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] @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 "htpasswd -mb "+@root_path+"user.passwd "+params[:user][:login]+" "+user_params[:password]
system "echo -e '\n"+params[:user][:login]+"-write:"+ # system "echo -e '\n"+params[:user][:login]+"-write:"+
" "+params[:user][:login]+"' >> "+@root_path+"group.passwd" # " "+params[:user][:login]+"' >> "+@root_path+"group.passwd"
system "mkdir "+@root_path+"htdocs/"+params[:user][:login] # system "mkdir "+@root_path+"htdocs/"+params[:user][:login]
#
system "echo -e 'Allow from all \n Order Deny,Allow \n "+ # system "echo -e 'Allow from all \n Order Deny,Allow \n "+
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+ # "<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
"Require group "+params[:user][:login]+"-write \n "+ # "Require group "+params[:user][:login]+"-write \n "+
"</Limit> \n ' >>"+ # "</Limit> \n ' >>"+
@root_path+"htdocs/"+params[:user][:login]+"/.htaccess" # @root_path+"htdocs/"+params[:user][:login]+"/.htaccess"
end end
case Setting.self_registration case Setting.self_registration

View File

@ -87,9 +87,7 @@ class MyController < ApplicationController
# Manage user's password # Manage user's password
def password def password
@root_path="/home/pdl/redmine-2.3.2-0/apache2/"
@user = User.current @user = User.current
@middle = "^"+@user.login.to_s+":"
unless @user.change_password_allowed? unless @user.change_password_allowed?
flash[:error] = l(:notice_can_t_change_password) flash[:error] = l(:notice_can_t_change_password)
redirect_to my_account_path redirect_to my_account_path
@ -98,17 +96,7 @@ class MyController < ApplicationController
if request.post? if request.post?
if @user.check_password?(params[:password]) if @user.check_password?(params[:password])
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] @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 "+
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
"Require group "+@user.login.to_s+"-write \n "+
"</Limit> \n ' >>"+
@root_path+"htdocs/"+@user.login.to_s+"/.htaccess"
if @user.save if @user.save
flash[:notice] = l(:notice_account_password_updated) flash[:notice] = l(:notice_account_password_updated)
redirect_to my_account_path redirect_to my_account_path

View File

@ -355,7 +355,10 @@ class ProjectsController < ApplicationController
format.html { redirect_to admin_projects_path } format.html { redirect_to admin_projects_path }
format.api { render_api_ok } format.api { render_api_ok }
end end
else
render :layout => "base"
end end
# hide project in layout # hide project in layout
@project = nil @project = nil
end end

View File

@ -75,17 +75,11 @@ class RepositoriesController < ApplicationController
@root_path="/home/pdl/redmine-2.3.2-0/apache2/" @root_path="/home/pdl/redmine-2.3.2-0/apache2/"
@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][:url] @repository_tag=params[:repository][:upassword]
attrs = pickup_extra_info attrs = pickup_extra_info
if(!@repository_tag) if((@repository_tag!="")&&params[:repository_scm]=="Git")
# params[:repository][:password]=params[:repository][:upassword]
if(params[:repository_scm]=="Git")
params[:repository][:url]=@project_path params[:repository][:url]=@project_path
end end
# else
# render_error l(:error_scm_password_not_set); return
# render :action => 'newrepo'
end
###xianbo ###xianbo
@repository = Repository.factory(params[:repository_scm]) @repository = Repository.factory(params[:repository_scm])
@repository.safe_attributes = params[:repository] @repository.safe_attributes = params[:repository]
@ -97,9 +91,18 @@ class RepositoriesController < ApplicationController
@repository.project = @project @repository.project = @project
if request.post? && @repository.save if request.post? && @repository.save
if(params[:repository_scm]=="Git") if(params[:repository_scm]=="Git")
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 "git init --bare "+@project_path
system "mv "+@project_path+"/hooks/post-update{.sample,}" system "mv "+@project_path+"/hooks/post-update{.sample,}"
system "chmod a+x "+@project_path+"/hooks/post-update" system "chmod a+x "+@project_path+"/hooks/post-update"
system "echo -e 'Allow from all \n Order Deny,Allow \n "+
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
"Require group "+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write \n "+
"</Limit> \n ' >> "+
@root_path+"htdocs/"+ @repository_name+"/.htaccess"
puts "before ======================================================================" puts "before ======================================================================"
puts system "cd "+@project_path+" ;git update-server-info" puts system "cd "+@project_path+" ;git update-server-info"
@ -108,7 +111,7 @@ class RepositoriesController < ApplicationController
@repository.update_attributes(:login => User.current.login.to_s) @repository.update_attributes(:login => User.current.login.to_s)
end end
redirect_to settings_project_path(@project, :tab => 'repositories') redirect_to settings_project_path(@project, :tab => 'repositories')
else if(!@repository_tag) else if(@repository_tag)
render :action => 'newrepo', :layout =>'base_projects' render :action => 'newrepo', :layout =>'base_projects'
else else
render :action => 'new', :layout =>'base_projects' render :action => 'new', :layout =>'base_projects'

View File

@ -185,7 +185,7 @@ class VersionsController < ApplicationController
if ids = params[:tracker_ids] 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 } @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 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 end
end end

View File

@ -28,7 +28,8 @@ border:none
<%= l(:text_repository_identifier_info).html_safe %></em> <%= l(:text_repository_identifier_info).html_safe %></em>
<% end %></p> <% end %></p>
<!-- <p><%= f.text_field :url, :size => 60, :required => true,:readonly=>true, :class=>'textbg'%></p> --> <!-- <p><%= f.text_field :url, :size => 60, :required => true,:readonly=>true, :class=>'textbg'%></p> -->
<!-- <p><%= f.password_field :upassword, :required =>true, :label=> :field_password %></p> --> <p><%= f.password_field :upassword, :required =>true, :label=> :field_password %>
<em class="info"><%= l(:label_upassword_info)%></em></p>
</div> </div>
<p> <p>
<%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %> <%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %>

View File

@ -4,10 +4,18 @@
<%= render :partial => 'navigation' %> <%= render :partial => 'navigation' %>
</div> </div>
<% project_path_cut = 40 %>
<% ip = "repository.trustie.net" %><!--Added by young For formatting project's path-->
<h3> <h3>
<%= render :partial => 'breadcrumbs', <%= render :partial => 'breadcrumbs',
:locals => { :path => @path, :kind => 'dir', :revision => @rev } %> :locals => { :path => @path, :kind => 'dir', :revision => @rev } %>
<div style="font-size:11px;">
<%if @repository.type.to_s=="Repository::Git"%>
<td>http://<%= @repository.login.to_s %>@<%= ip %><%=h @repository.url.slice(project_path_cut, @repository.url.length) %></td><!--Modified by tanxianbo-->
<%else %>
<td><%=h @repository.url %></td>
<% end %>
</div>
<% if @repositories.size > 1 %> <% if @repositories.size > 1 %>
<p style=" word-wrap: break-word; word-break: break-all"> <p style=" word-wrap: break-word; word-break: break-all">
(<%= l(:label_all_revisions) %><%= @repositories.sort.collect {|repo| (<%= l(:label_all_revisions) %><%= @repositories.sort.collect {|repo|

View File

@ -1,58 +1,77 @@
<!--modified by young--> <%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>
<div class="contextual">
<%= link_to(l(:button_edit), edit_version_path(@version), :class => 'icon icon-edit') if User.current.allowed_to?(:manage_versions, @version.project) %> <div class="contextual" style="padding-right: 10px;">
<%= 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? %> <%= render :partial => 'navigation' %>
<%= 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 }) %>
</div> </div>
<h3><%= h(@version.name) %></h3>
<div id="roadmap"> <h3>
<%= render :partial => 'versions/overview', :locals => {:version => @version} %> <%= render :partial => 'breadcrumbs',
<%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %> :locals => { :path => @path, :kind => 'dir', :revision => @rev } %>
<% if @repositories.size > 1 %>
<p style=" word-wrap: break-word; word-break: break-all">
(<%= l(:label_all_revisions) %><%= @repositories.sort.collect {|repo|
<% if @issues.present? %> link_to h(repo.name),
<%= form_tag({}) do -%> {:controller => 'repositories', :action => 'show',
<table class="list related-issues"> :id => @project, :repository_id => repo.identifier_param, :rev => nil, :path => nil},
<caption>&#187;<%= l(:label_related_issues) %></caption> :class => 'repository' + (repo == @repository ? ' selected' : '')
<%- @issues.each do |issue| -%> }.join('&nbsp|&nbsp').html_safe %>)</p>
<tr class="hascontextmenu">
<td class="checkbox"><%= check_box_tag 'ids[]', issue.id, false, :id => nil %></td>
<td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td>
</tr>
<% end %> <% end %>
</table> </h3>
<% end %>
<%= context_menu issues_context_menu_path %> <% if !@entries.nil? && authorize_for('repositories', 'browse') %>
<%= render :partial => 'dir_list' %>
<% end %> <% end %>
<div class="splitcontent"> <%= render_properties(@properties) %>
<% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %>
<fieldset class="time-tracking"><legend><%= l(:label_time_tracking) %></legend> <% if authorize_for('repositories', 'revisions') %>
<table> <% if @changesets && !@changesets.empty? %>
<tr> <h3><%= l(:label_latest_revision_plural) %></h3>
<th><%= l(:field_estimated_hours) %></th> <%= render :partial => 'revisions',
<td class="total-hours"><%= html_hours(l_hours(@version.estimated_hours)) %></td> :locals => {:project => @project, :path => @path,
</tr> :revisions => @changesets, :entry => nil }%>
<% if User.current.allowed_to?(:view_time_entries, @project) %>
<tr>
<th><%= l(:label_spent_time) %></th>
<td class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td>
</tr>
<% end %> <% end %>
</table> <p>
</fieldset> <% 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 %>
</p>
<% 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 %> <% end %>
<div id="status_by" style="margin-top:10px;"><!--by young--> <% other_formats_links do |f| %>
<%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %> <%= f.link_to 'Atom',
</div> :url => {:action => 'revisions', :id => @project,
</div> :repository_id => @repository.identifier_param,
</div> :key => User.current.rss_key} %>
<% end %>
<% end %>
<% end %>
<%= call_hook :view_versions_show_bottom, :version => @version %>
<% html_title @version.name %>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "scm" %>
<% end %>
<% html_title(l(:label_repository)) -%>

View File

@ -1246,3 +1246,4 @@ en:
label_max_number: Must be at most 25 characters long. label_max_number: Must be at most 25 characters long.
label_all_revisions: All revisions label_all_revisions: All revisions
label_repository_name: Repository name label_repository_name: Repository name
label_upassword_info: The password can be shared in the group

View File

@ -1258,3 +1258,4 @@ zh:
label_tags_numbers: Tag统计 label_tags_numbers: Tag统计
label_max_number: 至多25个字符。 label_max_number: 至多25个字符。
label_all_revisions: 所有版本: label_all_revisions: 所有版本:
label_upassword_info: 该密码在项目组内可共享