Changeset - 574218777086
[Not reviewed]
default
0 9 0
domruf - 8 years ago 2017-09-27 22:45:28
dominikruf@gmail.com
ssh: show ssh URL on summary page

Original change has been heavily modified by Mads Kiilerich.
9 files changed with 72 insertions and 16 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/settings.py
Show inline comments
 
@@ -271,6 +271,7 @@ class SettingsController(BaseController)
 
                    ('use_gravatar', 'use_gravatar', 'bool'),
 
                    ('gravatar_url', 'gravatar_url', 'unicode'),
 
                    ('clone_uri_tmpl', 'clone_uri_tmpl', 'unicode'),
 
                    ('clone_ssh_tmpl', 'clone_ssh_tmpl', 'unicode'),
 
                ]
 
                for setting, form_key, type_ in settings:
 
                    Setting.create_or_update(setting, form_result[form_key], type_)
kallithea/controllers/summary.py
Show inline comments
 
@@ -119,6 +119,7 @@ class SummaryController(BaseRepoControll
 
            username = request.authuser.username
 
        c.clone_repo_url = c.db_repo.clone_url(clone_uri_tmpl=c.clone_uri_tmpl, with_id=False, username=username)
 
        c.clone_repo_url_id = c.db_repo.clone_url(clone_uri_tmpl=c.clone_uri_tmpl, with_id=True, username=username)
 
        c.ssh_repo_url = c.db_repo.clone_url(clone_uri_tmpl=c.clone_ssh_tmpl)
 

	
 
        if c.db_repo.enable_statistics:
 
            c.show_stats = True
kallithea/lib/base.py
Show inline comments
 
@@ -404,6 +404,7 @@ class BaseController(TGController):
 
            </script>''' % c.ga_code
 
        c.site_name = rc_config.get('title')
 
        c.clone_uri_tmpl = rc_config.get('clone_uri_tmpl') or Repository.DEFAULT_CLONE_URI
 
        c.clone_ssh_tmpl = rc_config.get('clone_ssh_tmpl') or Repository.DEFAULT_CLONE_SSH
 

	
 
        ## INI stored
 
        c.visual.allow_repo_location_change = str2bool(config.get('allow_repo_location_change', True))
kallithea/lib/db_manage.py
Show inline comments
 
@@ -375,6 +375,7 @@ class DbManage(object):
 
            ('use_gravatar', True, 'bool'),
 
            ('gravatar_url', User.DEFAULT_GRAVATAR_URL, 'unicode'),
 
            ('clone_uri_tmpl', Repository.DEFAULT_CLONE_URI, 'unicode'),
 
            ('clone_ssh_tmpl', Repository.DEFAULT_CLONE_SSH, 'unicode'),
 
            ('update_url', Setting.DEFAULT_UPDATE_URL, 'unicode'),
 
        ]
 
        for key, val, type_ in settings:
kallithea/model/db.py
Show inline comments
 
@@ -964,6 +964,7 @@ class Repository(Base, BaseDbModel):
 
    )
 

	
 
    DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}'
 
    DEFAULT_CLONE_SSH = 'ssh://{system_user}@{hostname}/{repo}'
 

	
 
    STATE_CREATED = u'repo_state_created'
 
    STATE_PENDING = u'repo_state_pending'
kallithea/model/forms.py
Show inline comments
 
@@ -371,6 +371,7 @@ def ApplicationVisualisationForm():
 
        use_gravatar = v.StringBoolean(if_missing=False)
 
        gravatar_url = v.UnicodeString(min=3)
 
        clone_uri_tmpl = v.UnicodeString(min=3)
 
        clone_ssh_tmpl = v.UnicodeString()
 

	
 
    return _ApplicationVisualisationForm
 

	
kallithea/templates/admin/settings/settings_visual.html
Show inline comments
 
@@ -37,7 +37,7 @@ ${h.form(url('admin_settings_visual'), m
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label">${_('Clone URL')}:</label>
 
                <label class="control-label">${_('HTTP Clone URL')}:</label>
 
                <div>
 
                    ${h.text('clone_uri_tmpl', size=80, class_='form-control')}
 
                    <span class="help-block">${_('''Schema of clone URL construction eg. '{scheme}://{user}@{netloc}/{repo}'.
 
@@ -52,6 +52,13 @@ ${h.form(url('admin_settings_visual'), m
 
                                                    ''')}
 
                    </span>
 
                </div>
 
                %if c.ssh_enabled:
 
                <label class="control-label">${_('SSH Clone URL')}:</label>
 
                <div>
 
                    ${h.text('clone_ssh_tmpl', size=80, class_='form-control')}
 
                    <span class="help-block">${_('''Schema for constructing SSH clone URL, eg. 'ssh://{system_user}@{hostname}/{repo}'.''')}</span>
 
                </div>
 
                %endif
 
            </div>
 

	
 
            <div class="form-group">
kallithea/templates/summary/summary.html
Show inline comments
 
@@ -53,16 +53,33 @@ ${self.repo_context_bar('summary')}
 
            <div class="form-group form-inline">
 
                <label>${_('Clone URL')}:</label>
 
                <div id="clone-url">
 
                  <div id="clone_by_name" class="input-group">
 
                  <div id="clone_by_name" class="input-group"
 
                    %if c.ssh_enabled:
 
                        style="display:none"
 
                    %endif
 
                    >
 
                    <span class="input-group-addon">${self.repolabel(c.db_repo)}</span>
 
                    <input class="form-control" size="80" readonly="readonly" value="${c.clone_repo_url}"/>
 
                    <span class="input-group-addon btn">${_('Show by ID')}</span>
 
                    <span class="input-group-addon btn use-id">${_('Use ID')}</span>
 
                    %if c.ssh_enabled:
 
                    <span class="input-group-addon btn use-ssh">${_('Use SSH')}</span>
 
                    %endif
 
                  </div>
 
                  <div id="clone_by_id" class="input-group" style="display:none">
 
                    <span class="input-group-addon">${self.repolabel(c.db_repo)}</span>
 
                    <input class="form-control" size="80" readonly="readonly" value="${c.clone_repo_url_id}"/>
 
                    <span class="input-group-addon btn">${_('Show by Name')}</span>
 
                    <span class="input-group-addon btn use-name">${_('Use Name')}</span>
 
                    %if c.ssh_enabled:
 
                    <span class="input-group-addon btn use-ssh">${_('Use SSH')}</span>
 
                    %endif
 
                  </div>
 
                  %if c.ssh_enabled:
 
                  <div id="clone_ssh" class="input-group">
 
                    <span class="input-group-addon">${self.repolabel(c.db_repo)}</span>
 
                    <input id="ssh_url" class="form-control" size="80" readonly="readonly" value="${c.ssh_repo_url}"/>
 
                    <span class="input-group-addon btn use-name">${_('Use HTTP')}</span>
 
                  </div>
 
                  %endif
 
                </div>
 
            </div>
 

	
 
@@ -233,15 +250,24 @@ $(document).ready(function(){
 
        }
 
    });
 

	
 
    var $clone_url = $('#clone-url');
 
    var $clone_by_name = $('#clone_by_name');
 
    var $clone_by_id = $('#clone_by_id');
 
    $clone_by_name.find('.btn').click(function(e){
 
        $clone_by_name.hide();
 
        $clone_by_id.show();
 
    var $clone_ssh = $('#clone_ssh');
 
    $clone_url.on('click', '.btn.use-name', function(e){
 
        $clone_by_name.show();
 
        $clone_by_id.hide();
 
        $clone_ssh.hide();
 
    });
 
    $clone_by_id.find('.btn').click(function(e){
 
    $clone_url.on('click', '.btn.use-id', function(e){
 
        $clone_by_id.show();
 
        $clone_by_name.hide();
 
        $clone_ssh.hide();
 
    });
 
    $clone_url.on('click', '.btn.use-ssh', function(e){
 
        $clone_by_id.hide();
 
        $clone_by_name.show();
 
        $clone_by_name.hide();
 
        $clone_ssh.show();
 
    });
 

	
 
    var cache = {}
kallithea/tests/functional/test_summary.py
Show inline comments
 
@@ -19,12 +19,21 @@ from kallithea.model.repo import RepoMod
 
from kallithea.model.meta import Session
 
from kallithea.model.scm import ScmModel
 

	
 
import pytest
 

	
 
fixture = Fixture()
 

	
 
@pytest.fixture
 
def custom_settings(set_test_settings):
 
    # overwrite DEFAULT_CLONE_SSH = 'ssh://{system_user}@{hostname}/{repo}'
 
    set_test_settings(
 
        ('clone_ssh_tmpl', 'ssh://ssh_user@ssh_hostname/{repo}', 'unicode'),
 
        )
 

	
 

	
 
class TestSummaryController(TestController):
 

	
 
    def test_index_hg(self):
 
    def test_index_hg(self, custom_settings):
 
        self.log_user()
 
        ID = Repository.get_by_repo_name(HG_REPO).repo_id
 
        response = self.app.get(url(controller='summary',
 
@@ -39,8 +48,7 @@ class TestSummaryController(TestControll
 
        response.mustcontain(
 
            """<i class="icon-globe">"""
 
        )
 

	
 
        # clone url...
 
        # clone URLs
 
        response.mustcontain(
 
            '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/%s"/>''' %
 
            (TEST_USER_ADMIN_LOGIN, HG_REPO)
 
@@ -49,8 +57,13 @@ class TestSummaryController(TestControll
 
            '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/_%s"/>''' %
 
            (TEST_USER_ADMIN_LOGIN, ID)
 
        )
 
        response.mustcontain(
 
            '''<input id="ssh_url" class="form-control" size="80" readonly="readonly" value="ssh://ssh_user@ssh_hostname/%s"/>''' %
 
            (HG_REPO)
 
        )
 

	
 
    def test_index_git(self):
 

	
 
    def test_index_git(self, custom_settings):
 
        self.log_user()
 
        ID = Repository.get_by_repo_name(GIT_REPO).repo_id
 
        response = self.app.get(url(controller='summary',
 
@@ -65,15 +78,19 @@ class TestSummaryController(TestControll
 
        response.mustcontain(
 
            """<i class="icon-globe">"""
 
        )
 

	
 
        # clone url...
 
        # clone URLs
 
        response.mustcontain(
 
            '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/%s"/>''' %
 
            (TEST_USER_ADMIN_LOGIN, GIT_REPO))
 
            (TEST_USER_ADMIN_LOGIN, GIT_REPO)
 
        )
 
        response.mustcontain(
 
            '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/_%s"/>''' %
 
            (TEST_USER_ADMIN_LOGIN, ID)
 
        )
 
        response.mustcontain(
 
            '''<input id="ssh_url" class="form-control" size="80" readonly="readonly" value="ssh://ssh_user@ssh_hostname/%s"/>''' %
 
            (GIT_REPO)
 
        )
 

	
 
    def test_index_by_id_hg(self):
 
        self.log_user()
0 comments (0 inline, 0 general)