diff --git a/rhodecode/apps/admin/views/settings.py b/rhodecode/apps/admin/views/settings.py --- a/rhodecode/apps/admin/views/settings.py +++ b/rhodecode/apps/admin/views/settings.py @@ -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'), diff --git a/rhodecode/apps/repository/views/repo_summary.py b/rhodecode/apps/repository/views/repo_summary.py --- a/rhodecode/apps/repository/views/repo_summary.py +++ b/rhodecode/apps/repository/views/repo_summary.py @@ -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 diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -326,6 +326,7 @@ def attach_context_attributes(context, r 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( diff --git a/rhodecode/lib/utils2.py b/rhodecode/lib/utils2.py --- a/rhodecode/lib/utils2.py +++ b/rhodecode/lib/utils2.py @@ -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, rep 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) diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -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, diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -393,6 +393,7 @@ def ApplicationVisualisationForm(localiz 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) diff --git a/rhodecode/public/css/summary.less b/rhodecode/public/css/summary.less --- a/rhodecode/public/css/summary.less +++ b/rhodecode/public/css/summary.less @@ -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 { diff --git a/rhodecode/templates/admin/settings/settings_visual.mako b/rhodecode/templates/admin/settings/settings_visual.mako --- a/rhodecode/templates/admin/settings/settings_visual.mako +++ b/rhodecode/templates/admin/settings/settings_visual.mako @@ -167,18 +167,22 @@
${_('SVN Protocol is disabled. To enable it, see the')} ${_('documentation here')}.
+${_('SVN Protocol is disabled. To enable it, see the')} ${_('documentation here')}.
+ % endif +