parent
f3528cb4ab
commit
9c22bde88e
10 changed files with 87 additions and 68 deletions
|
|
@ -411,6 +411,7 @@ class AdminSettingsView(BaseAppView):
|
|||
('markup_renderer', 'rhodecode_markup_renderer', 'unicode'),
|
||||
('gravatar_url', 'rhodecode_gravatar_url', 'unicode'),
|
||||
('clone_uri_tmpl', 'rhodecode_clone_uri_tmpl', 'unicode'),
|
||||
('clone_uri_ssh_tmpl', 'rhodecode_clone_uri_ssh_tmpl', 'unicode'),
|
||||
('support_url', 'rhodecode_support_url', 'unicode'),
|
||||
('show_revision_number', 'rhodecode_show_revision_number', 'bool'),
|
||||
('show_sha_length', 'rhodecode_show_sha_length', 'int'),
|
||||
|
|
|
|||
|
|
@ -174,18 +174,22 @@ class RepoSummaryView(RepoAppView):
|
|||
if self._rhodecode_user.username != User.DEFAULT_USER:
|
||||
username = safe_str(self._rhodecode_user.username)
|
||||
|
||||
_def_clone_uri = _def_clone_uri_by_id = c.clone_uri_tmpl
|
||||
_def_clone_uri = _def_clone_uri_id = c.clone_uri_tmpl
|
||||
_def_clone_uri_ssh = c.clone_uri_ssh_tmpl
|
||||
|
||||
if '{repo}' in _def_clone_uri:
|
||||
_def_clone_uri_by_id = _def_clone_uri.replace(
|
||||
_def_clone_uri_id = _def_clone_uri.replace(
|
||||
'{repo}', '_{repoid}')
|
||||
elif '{repoid}' in _def_clone_uri:
|
||||
_def_clone_uri_by_id = _def_clone_uri.replace(
|
||||
_def_clone_uri_id = _def_clone_uri.replace(
|
||||
'_{repoid}', '{repo}')
|
||||
|
||||
c.clone_repo_url = self.db_repo.clone_url(
|
||||
user=username, uri_tmpl=_def_clone_uri)
|
||||
c.clone_repo_url_id = self.db_repo.clone_url(
|
||||
user=username, uri_tmpl=_def_clone_uri_by_id)
|
||||
user=username, uri_tmpl=_def_clone_uri_id)
|
||||
c.clone_repo_url_ssh = self.db_repo.clone_url(
|
||||
uri_tmpl=_def_clone_uri_ssh, ssh=True)
|
||||
|
||||
# If enabled, get statistics data
|
||||
|
||||
|
|
|
|||
|
|
@ -326,6 +326,7 @@ def attach_context_attributes(context, request, user_id):
|
|||
if request.GET.get('default_encoding'):
|
||||
context.default_encodings.insert(0, request.GET.get('default_encoding'))
|
||||
context.clone_uri_tmpl = rc_config.get('rhodecode_clone_uri_tmpl')
|
||||
context.clone_uri_ssh_tmpl = rc_config.get('rhodecode_clone_uri_ssh_tmpl')
|
||||
|
||||
# INI stored
|
||||
context.labs_active = str2bool(
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import time
|
|||
import urllib
|
||||
import urlobject
|
||||
import uuid
|
||||
import getpass
|
||||
|
||||
import pygments.lexers
|
||||
import sqlalchemy
|
||||
|
|
@ -613,11 +614,14 @@ def get_clone_url(request, uri_tmpl, repo_name, repo_id, **override):
|
|||
qualifed_home_url = request.route_url('home')
|
||||
parsed_url = urlobject.URLObject(qualifed_home_url)
|
||||
decoded_path = safe_unicode(urllib.unquote(parsed_url.path.rstrip('/')))
|
||||
|
||||
args = {
|
||||
'scheme': parsed_url.scheme,
|
||||
'user': '',
|
||||
'sys_user': getpass.getuser(),
|
||||
# path if we use proxy-prefix
|
||||
'netloc': parsed_url.netloc+decoded_path,
|
||||
'hostname': parsed_url.hostname,
|
||||
'prefix': decoded_path,
|
||||
'repo': repo_name,
|
||||
'repoid': str(repo_id)
|
||||
|
|
|
|||
|
|
@ -1532,6 +1532,7 @@ class Repository(Base, BaseModel):
|
|||
)
|
||||
DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}'
|
||||
DEFAULT_CLONE_URI_ID = '{scheme}://{user}@{netloc}/_{repoid}'
|
||||
DEFAULT_CLONE_URI_SSH = 'ssh://{sys_user}@{hostname}/{repo}'
|
||||
|
||||
STATE_CREATED = 'repo_state_created'
|
||||
STATE_PENDING = 'repo_state_pending'
|
||||
|
|
@ -2100,11 +2101,20 @@ class Repository(Base, BaseModel):
|
|||
uri_tmpl = override['uri_tmpl']
|
||||
del override['uri_tmpl']
|
||||
|
||||
ssh = False
|
||||
if 'ssh' in override:
|
||||
ssh = True
|
||||
del override['ssh']
|
||||
|
||||
# we didn't override our tmpl from **overrides
|
||||
if not uri_tmpl:
|
||||
rc_config = SettingsModel().get_all_settings(cache=True)
|
||||
uri_tmpl = rc_config.get(
|
||||
'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI
|
||||
if ssh:
|
||||
uri_tmpl = rc_config.get(
|
||||
'rhodecode_clone_uri_ssh_tmpl') or self.DEFAULT_CLONE_URI_SSH
|
||||
else:
|
||||
uri_tmpl = rc_config.get(
|
||||
'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI
|
||||
|
||||
request = get_current_request()
|
||||
return get_clone_url(request=request,
|
||||
|
|
|
|||
|
|
@ -393,6 +393,7 @@ def ApplicationVisualisationForm(localizer):
|
|||
rhodecode_markup_renderer = v.OneOf(['markdown', 'rst'])
|
||||
rhodecode_gravatar_url = v.UnicodeString(min=3)
|
||||
rhodecode_clone_uri_tmpl = v.UnicodeString(min=3)
|
||||
rhodecode_clone_uri_ssh_tmpl = v.UnicodeString(min=3)
|
||||
rhodecode_support_url = v.UnicodeString()
|
||||
rhodecode_show_revision_number = v.StringBoolean(if_missing=False)
|
||||
rhodecode_show_sha_length = v.Int(min=4, not_empty=True)
|
||||
|
|
|
|||
|
|
@ -57,14 +57,22 @@
|
|||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
#clone_url {
|
||||
width: ~"calc(100% - 103px)";
|
||||
padding: @padding/4;
|
||||
.left-clone {
|
||||
float: left;
|
||||
height: 30px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: @text-semibold;
|
||||
}
|
||||
|
||||
#clone_url_id {
|
||||
width: ~"calc(100% - 125px)";
|
||||
padding: @padding/4;
|
||||
.right-clone {
|
||||
float: right;
|
||||
width: 83%;
|
||||
}
|
||||
|
||||
.clone_url_input {
|
||||
width: ~"calc(100% - 35px)";
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
&.directory {
|
||||
|
|
|
|||
|
|
@ -167,18 +167,22 @@ ${h.secure_form(h.route_path('admin_settings_visual_update'), request=request)}
|
|||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">${_('Clone URL')}</h3>
|
||||
<h3 class="panel-title">${_('Clone URL templates')}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="field">
|
||||
${h.text('rhodecode_clone_uri_tmpl', size=60)}
|
||||
${h.text('rhodecode_clone_uri_tmpl', size=60)} HTTP[S]
|
||||
</div>
|
||||
<div class="field">
|
||||
${h.text('rhodecode_clone_uri_ssh_tmpl', size=60)} SSH
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<span class="help-block">
|
||||
${_('''Schema of clone url construction eg. '{scheme}://{user}@{netloc}/{repo}', available vars:
|
||||
{scheme} 'http' or 'https' sent from running RhodeCode server,
|
||||
{user} current user username,
|
||||
{sys_user} current system user running this process, usefull for ssh,
|
||||
{hostname} hostname of this server running RhodeCode,
|
||||
{netloc} network location/server host of running RhodeCode server,
|
||||
{repo} full repository name,
|
||||
{repoid} ID of repository, can be used to contruct clone-by-id''')}
|
||||
|
|
|
|||
|
|
@ -44,37 +44,41 @@
|
|||
</div>
|
||||
|
||||
<div class="fieldset">
|
||||
%if h.is_svn_without_proxy(c.rhodecode_db_repo):
|
||||
<div class="left-label disabled">
|
||||
${_('Read-only url')}:
|
||||
|
||||
<div class="left-clone">
|
||||
<select id="clone_option" name="clone_option">
|
||||
<option value="http" selected="selected">HTTP</option>
|
||||
<option value="http_id">HTTP UID</option>
|
||||
<option value="ssh">SSH</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="right-content disabled">
|
||||
<input type="text" class="input-monospace" id="clone_url" disabled value="${c.clone_repo_url}"/>
|
||||
<i id="clone_by_name_copy" class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url}" title="${_('Copy the clone url')}"></i>
|
||||
<div class="right-clone">
|
||||
<%
|
||||
maybe_disabled = ''
|
||||
if h.is_svn_without_proxy(c.rhodecode_db_repo):
|
||||
maybe_disabled = 'disabled'
|
||||
%>
|
||||
|
||||
<input type="text" class="input-monospace" id="clone_url_id" disabled value="${c.clone_repo_url_id}" style="display: none;"/>
|
||||
<i id="clone_by_id_copy" class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url_id}" title="${_('Copy the clone by id url')}" style="display: none"></i>
|
||||
<span id="clone_option_http">
|
||||
<input type="text" class="input-monospace clone_url_input" ${maybe_disabled} readonly="readonly" value="${c.clone_repo_url}"/>
|
||||
<i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url}" title="${_('Copy the clone url')}"></i>
|
||||
</span>
|
||||
|
||||
<a id="clone_by_name" class="clone" style="display: none;">${_('Show by Name')}</a>
|
||||
<a id="clone_by_id" class="clone">${_('Show by ID')}</a>
|
||||
<span style="display: none;" id="clone_option_http_id">
|
||||
<input type="text" class="input-monospace clone_url_input" ${maybe_disabled} readonly="readonly" value="${c.clone_repo_url_id}"/>
|
||||
<i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url_id}" title="${_('Copy the clone by id url')}"></i>
|
||||
</span>
|
||||
|
||||
<span style="display: none;" id="clone_option_ssh">
|
||||
<input type="text" class="input-monospace clone_url_input" ${maybe_disabled} readonly="readonly" value="${c.clone_repo_url_ssh}"/>
|
||||
<i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url_ssh}" title="${_('Copy the clone by ssh url')}"></i>
|
||||
</span>
|
||||
|
||||
% if maybe_disabled:
|
||||
<p class="help-block">${_('SVN Protocol is disabled. To enable it, see the')} <a href="${h.route_url('enterprise_svn_setup')}" target="_blank">${_('documentation here')}</a>.</p>
|
||||
% endif
|
||||
|
||||
<p class="help-block">${_('SVN Protocol is disabled. To enable it, see the')} <a href="${h.route_url('enterprise_svn_setup')}" target="_blank">${_('documentation here')}</a>.</p>
|
||||
</div>
|
||||
%else:
|
||||
<div class="left-label">
|
||||
${_('Clone url')}:
|
||||
</div>
|
||||
<div class="right-content">
|
||||
<input type="text" class="input-monospace" id="clone_url" readonly="readonly" value="${c.clone_repo_url}"/>
|
||||
<i id="clone_by_name_copy" class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url}" title="${_('Copy the clone url')}"></i>
|
||||
|
||||
<input type="text" class="input-monospace" id="clone_url_id" readonly="readonly" value="${c.clone_repo_url_id}" style="display: none;"/>
|
||||
<i id="clone_by_id_copy" class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url_id}" title="${_('Copy the clone by id url')}" style="display: none"></i>
|
||||
|
||||
<a id="clone_by_name" class="clone" style="display: none;">${_('Show by Name')}</a>
|
||||
<a id="clone_by_id" class="clone">${_('Show by ID')}</a>
|
||||
</div>
|
||||
%endif
|
||||
</div>
|
||||
|
||||
<div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none;">
|
||||
|
|
|
|||
|
|
@ -60,33 +60,15 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#clone_by_name').on('click',function(e){
|
||||
// show url by name and hide name button
|
||||
$('#clone_url').show();
|
||||
$('#clone_by_name').hide();
|
||||
|
||||
// hide url by id and show name button
|
||||
$('#clone_by_id').show();
|
||||
$('#clone_url_id').hide();
|
||||
|
||||
// hide copy by id
|
||||
$('#clone_by_name_copy').show();
|
||||
$('#clone_by_id_copy').hide();
|
||||
|
||||
});
|
||||
$('#clone_by_id').on('click',function(e){
|
||||
|
||||
// show url by id and hide id button
|
||||
$('#clone_by_id').hide();
|
||||
$('#clone_url_id').show();
|
||||
|
||||
// hide url by name and show id button
|
||||
$('#clone_by_name').show();
|
||||
$('#clone_url').hide();
|
||||
|
||||
// hide copy by id
|
||||
$('#clone_by_id_copy').show();
|
||||
$('#clone_by_name_copy').hide();
|
||||
$('#clone_option').on('change', function(e) {
|
||||
var selected = $(this).val();
|
||||
$.each(['http', 'http_id', 'ssh'], function (idx, val) {
|
||||
if(val === selected){
|
||||
$('#clone_option_' + val).show();
|
||||
} else {
|
||||
$('#clone_option_' + val).hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var initialCommitData = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue