files_browser.html
222 lines
| 9.1 KiB
| text/html
|
HtmlLexer
r547 | <%def name="file_class(node)"> | ||
%if node.is_file(): | |||
<%return "browser-file" %> | |||
%else: | |||
<%return "browser-dir"%> | |||
%endif | |||
</%def> | |||
<div id="body" class="browserblock"> | |||
r949 | <div class="browser-header"> | ||
<div class="browser-nav"> | |||
${h.form(h.url.current())} | |||
<div class="info_box"> | |||
r1304 | <span class="rev">${_('view')}@rev</span> | ||
<a class="rev" href="${c.url_prev}" title="${_('previous revision')}">«</a> | |||
r1452 | ${h.text('at_rev',value=c.changeset.revision,size=5)} | ||
r1304 | <a class="rev" href="${c.url_next}" title="${_('next revision')}">»</a> | ||
## ${h.submit('view',_('view'),class_="ui-button-small")} | |||
r949 | </div> | ||
${h.end_form()} | |||
</div> | |||
<div class="browser-branch"> | |||
${h.checkbox('stay_at_branch',c.changeset.branch,c.changeset.branch==c.branch)} | |||
<label>${_('follow current branch')}</label> | |||
</div> | |||
r1452 | <div class="browser-search"> | ||
r1483 | <div id="search_activate_id" class="search_activate"> | ||
<a id="filter_activate" href="#">${_('search file list')}</a> | |||
</div> | |||
r1486 | % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name): | ||
<div id="add_node_id" class="add_node"> | |||
<a href="${h.url('files_add_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path)}">${_('add new file')}</a> | |||
</div> | |||
% endif | |||
r1452 | <div> | ||
<div id="node_filter_box_loading" style="display:none">${_('Loading file list...')}</div> | |||
<div id="node_filter_box" style="display:none"> | |||
${h.files_breadcrumbs(c.repo_name,c.changeset.raw_id,c.files_list.path)}/<input type="text" value="type to search..." name="filter" size="25" id="node_filter" autocomplete="off"> | |||
<script type="text/javascript"> | |||
YUE.on('stay_at_branch','click',function(e){ | |||
if(e.target.checked){ | |||
var uri = "${h.url.current(branch='__BRANCH__')}" | |||
uri = uri.replace('__BRANCH__',e.target.value); | |||
window.location = uri; | |||
} | |||
else{ | |||
window.location = "${h.url.current()}"; | |||
} | |||
}) | |||
var n_filter = YUD.get('node_filter'); | |||
var F = YAHOO.namespace('node_filter'); | |||
var url = '${h.url("files_nodelist_home",repo_name="__REPO__",revision="__REVISION__",f_path="__FPATH__")}'; | |||
var node_url = '${h.url("files_home",repo_name="__REPO__",revision="__REVISION__",f_path="__FPATH__")}'; | |||
url = url.replace('__REPO__','${c.repo_name}'); | |||
url = url.replace('__REVISION__','${c.changeset.raw_id}'); | |||
url = url.replace('__FPATH__','${c.files_list.path}'); | |||
node_url = node_url.replace('__REPO__','${c.repo_name}'); | |||
node_url = node_url.replace('__REVISION__','${c.changeset.raw_id}'); | |||
F.filterTimeout = null; | |||
var nodes = null; | |||
F.initFilter = function(){ | |||
YUD.setStyle('node_filter_box_loading','display',''); | |||
r1483 | YUD.setStyle('search_activate_id','display','none'); | ||
YUD.setStyle('add_node_id','display','none'); | |||
r1452 | YUC.initHeader('X-PARTIAL-XHR',true); | ||
YUC.asyncRequest('GET',url,{ | |||
success:function(o){ | |||
nodes = JSON.parse(o.responseText); | |||
YUD.setStyle('node_filter_box_loading','display','none'); | |||
YUD.setStyle('node_filter_box','display',''); | |||
}, | |||
failure:function(o){ | |||
console.log('failed to load'); | |||
} | |||
},null); | |||
} | |||
F.updateFilter = function(e) { | |||
return function(){ | |||
// Reset timeout | |||
F.filterTimeout = null; | |||
var query = e.target.value; | |||
var match = []; | |||
var matches = 0; | |||
var matches_max = 20; | |||
if (query != ""){ | |||
for(var i=0;i<nodes.length;i++){ | |||
var pos = nodes[i].toLowerCase().indexOf(query) | |||
if(query && pos != -1){ | |||
matches++ | |||
//show only certain amount to not kill browser | |||
if (matches > matches_max){ | |||
break; | |||
} | |||
var n = nodes[i]; | |||
var n_hl = n.substring(0,pos) | |||
+"<b>{0}</b>".format(n.substring(pos,pos+query.length)) | |||
+n.substring(pos+query.length) | |||
match.push('<tr><td><a class="browser-file" href="{0}">{1}</a></td><td colspan="5"></td></tr>'.format(node_url.replace('__FPATH__',n),n_hl)); | |||
} | |||
if(match.length >= matches_max){ | |||
match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format("${_('search truncated')}")); | |||
} | |||
} | |||
} | |||
if(query != ""){ | |||
YUD.setStyle('tbody','display','none'); | |||
YUD.setStyle('tbody_filtered','display',''); | |||
if (match.length==0){ | |||
match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format("${_('no matching files')}")); | |||
} | |||
YUD.get('tbody_filtered').innerHTML = match.join(""); | |||
} | |||
else{ | |||
YUD.setStyle('tbody','display',''); | |||
YUD.setStyle('tbody_filtered','display','none'); | |||
} | |||
} | |||
} | |||
YUE.on(YUD.get('filter_activate'),'click',function(){ | |||
F.initFilter(); | |||
}) | |||
YUE.on(n_filter,'click',function(){ | |||
n_filter.value = ''; | |||
}); | |||
YUE.on(n_filter,'keyup',function(e){ | |||
clearTimeout(F.filterTimeout); | |||
F.filterTimeout = setTimeout(F.updateFilter(e),600); | |||
}); | |||
</script> | |||
</div> | |||
</div> | |||
</div> | |||
r884 | </div> | ||
r949 | |||
r547 | <div class="browser-body"> | ||
<table class="code-browser"> | |||
<thead> | |||
<tr> | |||
<th>${_('Name')}</th> | |||
<th>${_('Size')}</th> | |||
<th>${_('Mimetype')}</th> | |||
<th>${_('Revision')}</th> | |||
<th>${_('Last modified')}</th> | |||
<th>${_('Last commiter')}</th> | |||
</tr> | |||
</thead> | |||
r1452 | |||
<tbody id="tbody"> | |||
r633 | %if c.files_list.parent: | ||
r547 | <tr class="parity0"> | ||
<td> | |||
r644 | ${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.files_list.parent.path),class_="browser-dir")} | ||
r547 | </td> | ||
<td></td> | |||
<td></td> | |||
<td></td> | |||
<td></td> | |||
<td></td> | |||
r633 | </tr> | ||
r547 | %endif | ||
r740 | %for cnt,node in enumerate(c.files_list): | ||
r887 | <tr class="parity${cnt%2}"> | ||
r547 | <td> | ||
r1176 | ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=h.safe_unicode(node.path)),class_=file_class(node))} | ||
r547 | </td> | ||
<td> | |||
r583 | %if node.is_file(): | ||
r547 | ${h.format_byte_size(node.size,binary=True)} | ||
r583 | %endif | ||
r547 | </td> | ||
<td> | |||
%if node.is_file(): | |||
${node.mimetype} | |||
%endif | |||
</td> | |||
<td> | |||
%if node.is_file(): | |||
r904 | <span class="tooltip" title="${node.last_changeset.raw_id}"> | ||
r1150 | ${'r%s:%s' % (node.last_changeset.revision,node.last_changeset.short_id)}</span> | ||
r547 | %endif | ||
</td> | |||
<td> | |||
%if node.is_file(): | |||
r904 | <span class="tooltip" title="${node.last_changeset.date}"> | ||
r887 | ${h.age(node.last_changeset.date)}</span> | ||
r547 | %endif | ||
</td> | |||
<td> | |||
%if node.is_file(): | |||
${node.last_changeset.author} | |||
%endif | |||
</td> | |||
</tr> | |||
%endfor | |||
r1452 | </tbody> | ||
<tbody id="tbody_filtered" style="display:none"> | |||
</tbody> | |||
r547 | </table> | ||
</div> | |||
</div> |