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