##// END OF EJS Templates
ui: allow selecting and specifing ssh clone url....
marcink -
r2497:9a1b0044 default
parent child Browse files
Show More
@@ -411,6 +411,7 b' class AdminSettingsView(BaseAppView):'
411 411 ('markup_renderer', 'rhodecode_markup_renderer', 'unicode'),
412 412 ('gravatar_url', 'rhodecode_gravatar_url', 'unicode'),
413 413 ('clone_uri_tmpl', 'rhodecode_clone_uri_tmpl', 'unicode'),
414 ('clone_uri_ssh_tmpl', 'rhodecode_clone_uri_ssh_tmpl', 'unicode'),
414 415 ('support_url', 'rhodecode_support_url', 'unicode'),
415 416 ('show_revision_number', 'rhodecode_show_revision_number', 'bool'),
416 417 ('show_sha_length', 'rhodecode_show_sha_length', 'int'),
@@ -174,18 +174,22 b' class RepoSummaryView(RepoAppView):'
174 174 if self._rhodecode_user.username != User.DEFAULT_USER:
175 175 username = safe_str(self._rhodecode_user.username)
176 176
177 _def_clone_uri = _def_clone_uri_by_id = c.clone_uri_tmpl
177 _def_clone_uri = _def_clone_uri_id = c.clone_uri_tmpl
178 _def_clone_uri_ssh = c.clone_uri_ssh_tmpl
179
178 180 if '{repo}' in _def_clone_uri:
179 _def_clone_uri_by_id = _def_clone_uri.replace(
181 _def_clone_uri_id = _def_clone_uri.replace(
180 182 '{repo}', '_{repoid}')
181 183 elif '{repoid}' in _def_clone_uri:
182 _def_clone_uri_by_id = _def_clone_uri.replace(
184 _def_clone_uri_id = _def_clone_uri.replace(
183 185 '_{repoid}', '{repo}')
184 186
185 187 c.clone_repo_url = self.db_repo.clone_url(
186 188 user=username, uri_tmpl=_def_clone_uri)
187 189 c.clone_repo_url_id = self.db_repo.clone_url(
188 user=username, uri_tmpl=_def_clone_uri_by_id)
190 user=username, uri_tmpl=_def_clone_uri_id)
191 c.clone_repo_url_ssh = self.db_repo.clone_url(
192 uri_tmpl=_def_clone_uri_ssh, ssh=True)
189 193
190 194 # If enabled, get statistics data
191 195
@@ -326,6 +326,7 b' def attach_context_attributes(context, r'
326 326 if request.GET.get('default_encoding'):
327 327 context.default_encodings.insert(0, request.GET.get('default_encoding'))
328 328 context.clone_uri_tmpl = rc_config.get('rhodecode_clone_uri_tmpl')
329 context.clone_uri_ssh_tmpl = rc_config.get('rhodecode_clone_uri_ssh_tmpl')
329 330
330 331 # INI stored
331 332 context.labs_active = str2bool(
@@ -34,6 +34,7 b' import time'
34 34 import urllib
35 35 import urlobject
36 36 import uuid
37 import getpass
37 38
38 39 import pygments.lexers
39 40 import sqlalchemy
@@ -613,11 +614,14 b' def get_clone_url(request, uri_tmpl, rep'
613 614 qualifed_home_url = request.route_url('home')
614 615 parsed_url = urlobject.URLObject(qualifed_home_url)
615 616 decoded_path = safe_unicode(urllib.unquote(parsed_url.path.rstrip('/')))
617
616 618 args = {
617 619 'scheme': parsed_url.scheme,
618 620 'user': '',
621 'sys_user': getpass.getuser(),
619 622 # path if we use proxy-prefix
620 623 'netloc': parsed_url.netloc+decoded_path,
624 'hostname': parsed_url.hostname,
621 625 'prefix': decoded_path,
622 626 'repo': repo_name,
623 627 'repoid': str(repo_id)
@@ -1532,6 +1532,7 b' class Repository(Base, BaseModel):'
1532 1532 )
1533 1533 DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}'
1534 1534 DEFAULT_CLONE_URI_ID = '{scheme}://{user}@{netloc}/_{repoid}'
1535 DEFAULT_CLONE_URI_SSH = 'ssh://{sys_user}@{hostname}/{repo}'
1535 1536
1536 1537 STATE_CREATED = 'repo_state_created'
1537 1538 STATE_PENDING = 'repo_state_pending'
@@ -2100,11 +2101,20 b' class Repository(Base, BaseModel):'
2100 2101 uri_tmpl = override['uri_tmpl']
2101 2102 del override['uri_tmpl']
2102 2103
2104 ssh = False
2105 if 'ssh' in override:
2106 ssh = True
2107 del override['ssh']
2108
2103 2109 # we didn't override our tmpl from **overrides
2104 2110 if not uri_tmpl:
2105 2111 rc_config = SettingsModel().get_all_settings(cache=True)
2106 uri_tmpl = rc_config.get(
2107 'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI
2112 if ssh:
2113 uri_tmpl = rc_config.get(
2114 'rhodecode_clone_uri_ssh_tmpl') or self.DEFAULT_CLONE_URI_SSH
2115 else:
2116 uri_tmpl = rc_config.get(
2117 'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI
2108 2118
2109 2119 request = get_current_request()
2110 2120 return get_clone_url(request=request,
@@ -393,6 +393,7 b' def ApplicationVisualisationForm(localiz'
393 393 rhodecode_markup_renderer = v.OneOf(['markdown', 'rst'])
394 394 rhodecode_gravatar_url = v.UnicodeString(min=3)
395 395 rhodecode_clone_uri_tmpl = v.UnicodeString(min=3)
396 rhodecode_clone_uri_ssh_tmpl = v.UnicodeString(min=3)
396 397 rhodecode_support_url = v.UnicodeString()
397 398 rhodecode_show_revision_number = v.StringBoolean(if_missing=False)
398 399 rhodecode_show_sha_length = v.Int(min=4, not_empty=True)
@@ -57,14 +57,22 b''
57 57 white-space: pre-wrap;
58 58 }
59 59
60 #clone_url {
61 width: ~"calc(100% - 103px)";
62 padding: @padding/4;
60 .left-clone {
61 float: left;
62 height: 30px;
63 margin: 0;
64 padding: 0;
65 font-family: @text-semibold;
63 66 }
64 67
65 #clone_url_id {
66 width: ~"calc(100% - 125px)";
67 padding: @padding/4;
68 .right-clone {
69 float: right;
70 width: 83%;
71 }
72
73 .clone_url_input {
74 width: ~"calc(100% - 35px)";
75 padding: 5px;
68 76 }
69 77
70 78 &.directory {
@@ -167,18 +167,22 b''
167 167
168 168 <div class="panel panel-default">
169 169 <div class="panel-heading">
170 <h3 class="panel-title">${_('Clone URL')}</h3>
170 <h3 class="panel-title">${_('Clone URL templates')}</h3>
171 171 </div>
172 172 <div class="panel-body">
173 173 <div class="field">
174 ${h.text('rhodecode_clone_uri_tmpl', size=60)}
174 ${h.text('rhodecode_clone_uri_tmpl', size=60)} HTTP[S]
175 175 </div>
176
176 <div class="field">
177 ${h.text('rhodecode_clone_uri_ssh_tmpl', size=60)} SSH
178 </div>
177 179 <div class="field">
178 180 <span class="help-block">
179 181 ${_('''Schema of clone url construction eg. '{scheme}://{user}@{netloc}/{repo}', available vars:
180 182 {scheme} 'http' or 'https' sent from running RhodeCode server,
181 183 {user} current user username,
184 {sys_user} current system user running this process, usefull for ssh,
185 {hostname} hostname of this server running RhodeCode,
182 186 {netloc} network location/server host of running RhodeCode server,
183 187 {repo} full repository name,
184 188 {repoid} ID of repository, can be used to contruct clone-by-id''')}
@@ -44,37 +44,41 b''
44 44 </div>
45 45
46 46 <div class="fieldset">
47 %if h.is_svn_without_proxy(c.rhodecode_db_repo):
48 <div class="left-label disabled">
49 ${_('Read-only url')}:
50 </div>
51 <div class="right-content disabled">
52 <input type="text" class="input-monospace" id="clone_url" disabled value="${c.clone_repo_url}"/>
53 <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>
54 47
55 <input type="text" class="input-monospace" id="clone_url_id" disabled value="${c.clone_repo_url_id}" style="display: none;"/>
56 <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>
57
58 <a id="clone_by_name" class="clone" style="display: none;">${_('Show by Name')}</a>
59 <a id="clone_by_id" class="clone">${_('Show by ID')}</a>
60
61 <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>
48 <div class="left-clone">
49 <select id="clone_option" name="clone_option">
50 <option value="http" selected="selected">HTTP</option>
51 <option value="http_id">HTTP UID</option>
52 <option value="ssh">SSH</option>
53 </select>
62 54 </div>
63 %else:
64 <div class="left-label">
65 ${_('Clone url')}:
66 </div>
67 <div class="right-content">
68 <input type="text" class="input-monospace" id="clone_url" readonly="readonly" value="${c.clone_repo_url}"/>
69 <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>
55 <div class="right-clone">
56 <%
57 maybe_disabled = ''
58 if h.is_svn_without_proxy(c.rhodecode_db_repo):
59 maybe_disabled = 'disabled'
60 %>
61
62 <span id="clone_option_http">
63 <input type="text" class="input-monospace clone_url_input" ${maybe_disabled} readonly="readonly" value="${c.clone_repo_url}"/>
64 <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url}" title="${_('Copy the clone url')}"></i>
65 </span>
70 66
71 <input type="text" class="input-monospace" id="clone_url_id" readonly="readonly" value="${c.clone_repo_url_id}" style="display: none;"/>
72 <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>
67 <span style="display: none;" id="clone_option_http_id">
68 <input type="text" class="input-monospace clone_url_input" ${maybe_disabled} readonly="readonly" value="${c.clone_repo_url_id}"/>
69 <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url_id}" title="${_('Copy the clone by id url')}"></i>
70 </span>
73 71
74 <a id="clone_by_name" class="clone" style="display: none;">${_('Show by Name')}</a>
75 <a id="clone_by_id" class="clone">${_('Show by ID')}</a>
72 <span style="display: none;" id="clone_option_ssh">
73 <input type="text" class="input-monospace clone_url_input" ${maybe_disabled} readonly="readonly" value="${c.clone_repo_url_ssh}"/>
74 <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.clone_repo_url_ssh}" title="${_('Copy the clone by ssh url')}"></i>
75 </span>
76
77 % if maybe_disabled:
78 <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>
79 % endif
80
76 81 </div>
77 %endif
78 82 </div>
79 83
80 84 <div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none;">
@@ -60,33 +60,15 b''
60 60
61 61 <script type="text/javascript">
62 62 $(document).ready(function(){
63 $('#clone_by_name').on('click',function(e){
64 // show url by name and hide name button
65 $('#clone_url').show();
66 $('#clone_by_name').hide();
67
68 // hide url by id and show name button
69 $('#clone_by_id').show();
70 $('#clone_url_id').hide();
71
72 // hide copy by id
73 $('#clone_by_name_copy').show();
74 $('#clone_by_id_copy').hide();
75
76 });
77 $('#clone_by_id').on('click',function(e){
78
79 // show url by id and hide id button
80 $('#clone_by_id').hide();
81 $('#clone_url_id').show();
82
83 // hide url by name and show id button
84 $('#clone_by_name').show();
85 $('#clone_url').hide();
86
87 // hide copy by id
88 $('#clone_by_id_copy').show();
89 $('#clone_by_name_copy').hide();
63 $('#clone_option').on('change', function(e) {
64 var selected = $(this).val();
65 $.each(['http', 'http_id', 'ssh'], function (idx, val) {
66 if(val === selected){
67 $('#clone_option_' + val).show();
68 } else {
69 $('#clone_option_' + val).hide();
70 }
71 });
90 72 });
91 73
92 74 var initialCommitData = {
General Comments 0
You need to be logged in to leave comments. Login now