Changeset - fd03ac0708cf
[Not reviewed]
default
0 2 0
Mads Kiilerich - 6 years ago 2019-06-30 13:03:35
mads@kiilerich.com
Grafted from: d337ae31cdcf
files: keep _repo_files_url as "global" const variable
2 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/files/files.html
Show inline comments
 
@@ -31,49 +31,47 @@ ${self.repo_context_bar('files', c.revis
 
    </div>
 
    <div class="panel-body">
 
        <div id="files_data">
 
            <%include file='files_ypjax.html'/>
 
        </div>
 
    </div>
 
</div>
 

	
 
<script type="text/javascript">
 
var CACHE = {};
 
var CACHE_EXPIRE = 5*60*1000; //cache for 5*60s
 
//used to construct links from the search list
 
var _repo_files_url = ${h.jshtml(h.url("files_home",repo_name=c.repo_name,revision='',f_path='').replace('//', '/'))};
 
var url_base = ${h.js(h.url("files_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__'))};
 
//send the nodelist request to this url
 
var node_list_url = ${h.js(h.url("files_nodelist_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__'))};
 

	
 
## new pyroutes URLs
 
pyroutes.register('files_nodelist_home', ${h.js(h.url('files_nodelist_home', repo_name=c.repo_name,revision='%(revision)s',f_path='%(f_path)s'))}, ['revision', 'f_path']);
 
pyroutes.register('files_history_home', ${h.js(h.url('files_history_home', repo_name=c.repo_name,revision='%(revision)s',f_path='%(f_path)s'))}, ['revision', 'f_path']);
 
pyroutes.register('files_authors_home', ${h.js(h.url('files_authors_home', repo_name=c.repo_name,revision='%(revision)s',f_path='%(f_path)s'))}, ['revision', 'f_path']);
 

	
 
var ypjax_links = function(){
 
    $('.ypjax-link').click(function(e){
 

	
 
        //don't do ypjax on middle click
 
        if (e.which == 2) {
 
            return true;
 
        }
 

	
 
        var el = e.currentTarget;
 
        var url = el.href;
 

	
 
        var _base_url = ${h.jshtml(h.url("files_home",repo_name=c.repo_name,revision='',f_path=''))};
 
        _base_url = _base_url.replace('//','/');
 

	
 
        //extract rev and the f_path from url.
 
        parts = url.split(_base_url);
 
        parts = url.split(_repo_files_url);
 
        if(parts.length != 2){
 
            return false;
 
        }
 

	
 
        var parts2 = parts[1].split('/');
 
        var rev = parts2.shift(); // pop the first element which is the revision
 
        var f_path = parts2.join('/');
 

	
 
        //page title - make this consistent with title mako block above
 
        var title = ${h.jshtml(_('%s Files') % c.repo_name)} + " \u00B7 " + (f_path || '/') + " \u00B7 " + ${h.jshtml(c.site_name)};
 

	
 
        var _node_list_url = node_list_url.replace('__REV__',rev).replace('__FPATH__', f_path);
kallithea/tests/other/test_vcs_operations.py
Show inline comments
 
@@ -554,21 +554,24 @@ class TestVCSOperations(TestController):
 
        # add submodule
 
        stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', fork_url, dest_dir)
 
        stdout, stderr = Command(dest_dir).execute('git submodule add', clone_url, 'testsubmodule')
 
        stdout, stderr = Command(dest_dir).execute('git commit -am "added testsubmodule pointing to', clone_url, '"', EMAIL=TEST_USER_ADMIN_EMAIL)
 
        stdout, stderr = Command(dest_dir).execute('git push', fork_url, 'master')
 

	
 
        # check for testsubmodule link in files page
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='index',
 
                                    repo_name=testfork['git'],
 
                                    revision='tip',
 
                                    f_path='/'))
 
        # check _repo_files_url that will be used to reload as AJAX
 
        response.mustcontain('var _repo_files_url = ("/%s/files/");' % testfork['git'])
 

	
 
        response.mustcontain('<a class="submodule-dir" href="%s" target="_blank"><i class="icon-file-submodule"></i><span>testsubmodule @ ' % clone_url)
 

	
 
        # check that following a submodule link actually works - and redirects
 
        response = self.app.get(url(controller='files', action='index',
 
                                    repo_name=testfork['git'],
 
                                    revision='tip',
 
                                    f_path='/testsubmodule'),
 
                                status=302)
 
        assert response.location == clone_url
0 comments (0 inline, 0 general)