Changeset - 97ec8cf362c3
[Not reviewed]
default
0 4 0
Mads Kiilerich - 9 years ago 2017-02-16 02:42:37
mads@kiilerich.com
style: introduce Bootstrap input-group - especially for repo summary pages

Based on work by Dominik Ruf.
4 files changed with 53 insertions and 37 deletions:
0 comments (0 inline, 0 general)
kallithea/public/css/style.css
Show inline comments
 
@@ -4522,24 +4522,34 @@ ul.user_group_member li {
 

	
 
.popover.top {
 
    margin-top: -10px;
 
}
 
.popover.top > .arrow {
 
    bottom: -11px;
 
    left: 50%;
 
    margin-left: -11px;
 
    border-top-color: #999;
 
    border-top-color: rgba(0,0,0,.25);
 
    border-bottom-width: 0;
 
}
 

	
 
.popover.bottom {
 
    margin-top: 10px;
 
}
 
.popover.bottom > .arrow {
 
    top: -11px;
 
    left: 50%;
 
    margin-left: -11px;
 
    border-top-width: 0;
 
    border-bottom-color: #999;
 
    border-bottom-color: rgba(0,0,0,.25);
 
}
 

	
 
#clone_by_name.input-group > span,
 
#clone_by_id.input-group > span {
 
    display: inline-block;
 
}
 

	
 
#clone_by_name.input-group > input,
 
#clone_by_id.input-group > input {
 
    width: 80% !important;
 
}
kallithea/templates/admin/settings/settings_vcs.html
Show inline comments
 
@@ -38,53 +38,55 @@ ${h.form(url('admin_settings'), method='
 
                            ${h.checkbox('extensions_largefiles','True')}
 
                            ${_('Enable largefiles extension')}
 
                        </label>
 
                    </div>
 
                    <div class="checkbox">
 
                        <label>
 
                            ${h.checkbox('extensions_hgsubversion','True')}
 
                            ${_('Enable hgsubversion extension')}
 
                        </label>
 
                    </div>
 
                    <span class="help-block">${_('Requires hgsubversion library to be installed. Enables cloning of remote Subversion repositories while converting them to Mercurial.')}</span>
 
                    ##<div class="checkbox">
 
                    ##    <label>
 
                    ##        ${h.checkbox('extensions_hggit','True')}
 
                    ##        ${_('Enable hg-git extension')}
 
                    ##    </label>
 
                    ##</div>
 
                    ##<span class="help-block">${_('Requires hg-git library to be installed. Enables cloning of remote Git repositories while converting them to Mercurial.')}</span>
 
                </div>
 
            </div>
 
            %if c.visual.allow_repo_location_change:
 
            <div class="form-group">
 
                <label class="control-label" for="paths_root_path">${_('Location of repositories')}:</label>
 
                <div>
 
                    ${h.text('paths_root_path',size=60,readonly="readonly",class_='form-control')}
 
                    <span id="path_unlock" data-toggle="tooltip" style="cursor: pointer"
 
                    <div class="input-group">
 
                        ${h.text('paths_root_path',size=60,readonly="readonly",class_='form-control')}
 
                        <span id="path_unlock" data-toggle="tooltip" class="input-group-btn"
 
                            title="${_('Click to unlock. You must restart Kallithea in order to make this setting take effect.')}">
 
                        <span class="btn btn-default btn-sm"><i id="path_unlock_icon" class="icon-lock"></i></span>
 
                    </span>
 
                            <span class="btn btn-default btn-sm"><i id="path_unlock_icon" class="icon-lock"></i></span>
 
                        </span>
 
                    </div>
 
                    <span class="help-block">${_('Filesystem location where repositories are stored. After changing this value, a restart and rescan of the repository folder are both required.')}</span>
 
                </div>
 
            </div>
 
            %else:
 
            ## form still requires this but we cannot internally change it anyway
 
            ${h.hidden('paths_root_path',size=30,readonly="readonly")}
 
            %endif
 
            <div class="form-group">
 
                <div class="buttons">
 
                    ${h.submit('save',_('Save Settings'),class_="btn btn-default")}
 
                    ${h.reset('reset',_('Reset'),class_="btn btn-default")}
 
                </div>
 
           </div>
 
        </div>
 
    </div>
 
    ${h.end_form()}
 

	
 
    <script type="text/javascript">
 
        $(document).ready(function(){
 
            $('#path_unlock').on('click', function(e){
 
                $('#path_unlock_icon').removeClass('icon-lock');
 
                $('#path_unlock_icon').addClass('icon-lock-open-alt');
 
                $('#paths_root_path').removeAttr('readonly');
 
            });
kallithea/templates/summary/summary.html
Show inline comments
 
@@ -45,55 +45,60 @@
 
    if (branch){
 
      window.location = "${h.url('changelog_home',repo_name=c.repo_name,branch='__BRANCH__')}"
 
        .replace('__BRANCH__',branch);
 
    }
 
  }
 
  redirect_hash_branch();
 
  window.onhashchange = function() {
 
    redirect_hash_branch();
 
  };
 
  </script>
 
</%block>
 

	
 
<%def name="main()">
 
${self.repo_context_bar('summary')}
 
<%
 
summary = lambda n:{False:'summary-short'}.get(n)
 
%>
 
<div class="panel panel-primary">
 
    <div class="panel-heading clearfix">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <div id="summary-panel-body" class="form panel-body">
 
        <div id="summary" class="form-horizontal">
 
            <div class="form-group form-inline clearfix">
 
              <label>${_('Clone URL')}:</label>
 
                <div class="${summary(c.show_stats)}">
 
                  ${self.repotag(c.db_repo)}
 
                  <input style="width:80%" type="text" id="clone_url" readonly="readonly" value="${c.clone_repo_url}"/>
 
                  <input style="display:none;width:80%" type="text" id="clone_url_id" readonly="readonly" value="${c.clone_repo_url_id}"/>
 
                  <div style="display:none" id="clone_by_name" class="btn btn-default btn-sm">${_('Show by Name')}</div>
 
                  <div id="clone_by_id" class="btn btn-default btn-sm">${_('Show by ID')}</div>
 
                <label>${_('Clone URL')}:</label>
 
                <div id="clone-url">
 
                  <div id="clone_by_name" class="input-group">
 
                    <span class="input-group-addon">${self.repotag(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>
 
                  </div>
 
                  <div id="clone_by_id" class="input-group" style="display:none">
 
                    <span class="input-group-addon">${self.repotag(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>
 
                  </div>
 
                </div>
 
            </div>
 

	
 
            <div class="form-group clearfix">
 
              <label>${_('Description')}:</label>
 
              <div class="${summary(c.show_stats)} desc">${h.urlify_text(c.db_repo.description, stylize=c.visual.stylify_metatags)}</div>
 
            </div>
 

	
 
            <div class="form-group clearfix">
 
              <label>${_('Trending files')}:</label>
 
              <div class="${summary(c.show_stats)}">
 
                %if c.show_stats:
 
                <div id="lang_stats"></div>
 
                %else:
 
                   ${_('Statistics are disabled for this repository')}
 
                   %if h.HasPermissionAny('hg.admin')('enable stats on from summary'):
 
                        ${h.link_to(_('Enable'),h.url('edit_repo',repo_name=c.repo_name, anchor='repo_enable_statistics'),class_="btn btn-default btn-xs")}
 
                   %endif
 
                %endif
 
              </div>
 
            </div>
 

	
 
            <div class="form-group clearfix">
 
              <label>${_('Download')}:</label>
 
@@ -182,79 +187,67 @@ summary = lambda n:{False:'summary-short
 
            <%include file='../changelog/changelog_summary_data.html'/>
 
        </div>
 
    </div>
 
</div>
 

	
 
%if c.readme_data:
 
<div id="readme" class="anchor">
 
<div class="panel panel-primary">
 
    <div class="panel-heading" title="${_('Readme file from revision %s:%s') % (c.db_repo.landing_rev[0], c.db_repo.landing_rev[1])}">
 
        <div class="breadcrumbs panel-title">
 
            <a href="${h.url('files_home',repo_name=c.repo_name,revision='tip',f_path=c.readme_file)}">${c.readme_file}</a>
 
        </div>
 
    </div>
 
    <div class="readme panel-body">
 
      <div class="readme_box">
 
        ${c.readme_data|n}
 
      </div>
 
    </div>
 
</div>
 
</div>
 
%endif
 

	
 
<script type="text/javascript">
 
$(document).ready(function(){
 
    var $clone_url = $('#clone_url');
 
    var $clone_url_id = $('#clone_url_id');
 
    var $clone_by_name = $('#clone_by_name');
 
    var $clone_by_id = $('#clone_by_id');
 
    $clone_url.click(function(e){
 
        if($clone_url.hasClass('selected')){
 
    $('#clone-url input').click(function(e){
 
        if($(this).hasClass('selected')){
 
            $(this).removeClass('selected');
 
            return ;
 
        }else{
 
            $clone_url.addClass('selected');
 
            $clone_url.select();
 
            $(this).addClass('selected');
 
            $(this).select();
 
        }
 
    });
 

	
 
    $clone_by_name.click(function(e){
 
        // show url by name and hide name button
 
        $clone_url.show();
 
    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();
 

	
 
        // hide url by id and show name button
 
        $clone_by_id.show();
 
        $clone_url_id.hide();
 
    });
 

	
 
    $clone_by_id.click(function(e){
 
        // show url by id and hide id button
 
    $clone_by_id.find('.btn').click(function(e){
 
        $clone_by_id.hide();
 
        $clone_url_id.show();
 

	
 
        // hide url by name and show id button
 
        $clone_by_name.show();
 
        $clone_url.hide();
 
    });
 

	
 
    var cache = {}
 
    $("#download_options").select2({
 
        placeholder: _TM['Select changeset'],
 
        dropdownAutoWidth: true,
 
        query: function(query){
 
          var key = 'cache';
 
          var cached = cache[key] ;
 
          if(cached) {
 
            var data = {results: []};
 
            //filter results
 
            $.each(cached.results, function(){
 
                var section = this.text;
 
                var children = [];
 
                $.each(this.children, function(){
 
                    if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){
 
                        children.push({'id': this.id, 'text': this.text});
 
                    }
 
                });
 
                data.results.push({'text': section, 'children': children});
 
            });
 
            query.callback(data);
 
          }else{
kallithea/tests/functional/test_summary.py
Show inline comments
 
@@ -3,87 +3,98 @@
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from kallithea.tests.base import *
 
from kallithea.tests.fixture import Fixture
 
from kallithea.model.db import Repository
 
from kallithea.model.repo import RepoModel
 
from kallithea.model.meta import Session
 
from kallithea.model.scm import ScmModel
 

	
 
fixture = Fixture()
 

	
 

	
 
class TestSummaryController(TestController):
 

	
 
    def test_index(self):
 
    def test_index_hg(self):
 
        self.log_user()
 
        ID = Repository.get_by_repo_name(HG_REPO).repo_id
 
        response = self.app.get(url(controller='summary',
 
                                    action='index',
 
                                    repo_name=HG_REPO))
 

	
 
        #repo type
 
        response.mustcontain(
 
            """<span class="repotag">hg"""
 
        )
 
        #public/private
 
        response.mustcontain(
 
            """<i class="icon-globe">"""
 
        )
 

	
 
        # clone url...
 
        response.mustcontain('''id="clone_url" readonly="readonly" value="http://%s@localhost:80/%s"''' % (TEST_USER_ADMIN_LOGIN, HG_REPO))
 
        response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://%s@localhost:80/_%s"''' % (TEST_USER_ADMIN_LOGIN, ID))
 
        response.mustcontain(
 
            '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/%s"/>''' %
 
            (TEST_USER_ADMIN_LOGIN, HG_REPO)
 
        )
 
        response.mustcontain(
 
            '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/_%s"/>''' %
 
            (TEST_USER_ADMIN_LOGIN, ID)
 
        )
 

	
 
    def test_index_git(self):
 
        self.log_user()
 
        ID = Repository.get_by_repo_name(GIT_REPO).repo_id
 
        response = self.app.get(url(controller='summary',
 
                                    action='index',
 
                                    repo_name=GIT_REPO))
 

	
 
        #repo type
 
        response.mustcontain(
 
            """<span class="repotag">git"""
 
        )
 
        #public/private
 
        response.mustcontain(
 
            """<i class="icon-globe">"""
 
        )
 

	
 
        # clone url...
 
        response.mustcontain('''id="clone_url" readonly="readonly" value="http://%s@localhost:80/%s"''' % (TEST_USER_ADMIN_LOGIN, GIT_REPO))
 
        response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://%s@localhost:80/_%s"''' % (TEST_USER_ADMIN_LOGIN, ID))
 
        response.mustcontain(
 
            '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/%s"/>''' %
 
            (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)
 
        )
 

	
 
    def test_index_by_id_hg(self):
 
        self.log_user()
 
        ID = Repository.get_by_repo_name(HG_REPO).repo_id
 
        response = self.app.get(url(controller='summary',
 
                                    action='index',
 
                                    repo_name='_%s' % ID))
 

	
 
        #repo type
 
        response.mustcontain(
 
            """<span class="repotag">hg"""
 
        )
 
        #public/private
 
        response.mustcontain(
 
            """<i class="icon-globe">"""
 
        )
 

	
 
    def test_index_by_repo_having_id_path_in_name_hg(self):
 
        self.log_user()
 
        fixture.create_repo(name=u'repo_1')
 
        response = self.app.get(url(controller='summary',
 
                                    action='index',
 
                                    repo_name='repo_1'))
 

	
0 comments (0 inline, 0 general)