Files
@ 8585fbf3ed06
Branch filter:
Location: kallithea/rhodecode/templates/files/files_browser.html
8585fbf3ed06
8.7 KiB
text/html
Implemented #111 copy github node finder solution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | <%def name="file_class(node)">
%if node.is_file():
<%return "browser-file" %>
%else:
<%return "browser-dir"%>
%endif
</%def>
<div id="body" class="browserblock">
<div class="browser-header">
<div class="browser-nav">
${h.form(h.url.current())}
<div class="info_box">
<span class="rev">${_('view')}@rev</span>
<a class="rev" href="${c.url_prev}" title="${_('previous revision')}">«</a>
${h.text('at_rev',value=c.changeset.revision,size=5)}
<a class="rev" href="${c.url_next}" title="${_('next revision')}">»</a>
## ${h.submit('view',_('view'),class_="ui-button-small")}
</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>
<div class="browser-search">
<div class="search_activate">
<a id="filter_activate" href="#">${_('search file list')}</a>
</div>
<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','');
YUD.setStyle('filter_activate','display','none');
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>
</div>
<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>
<tbody id="tbody">
%if c.files_list.parent:
<tr class="parity0">
<td>
${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")}
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
%endif
%for cnt,node in enumerate(c.files_list):
<tr class="parity${cnt%2}">
<td>
${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))}
</td>
<td>
%if node.is_file():
${h.format_byte_size(node.size,binary=True)}
%endif
</td>
<td>
%if node.is_file():
${node.mimetype}
%endif
</td>
<td>
%if node.is_file():
<span class="tooltip" title="${node.last_changeset.raw_id}">
${'r%s:%s' % (node.last_changeset.revision,node.last_changeset.short_id)}</span>
%endif
</td>
<td>
%if node.is_file():
<span class="tooltip" title="${node.last_changeset.date}">
${h.age(node.last_changeset.date)}</span>
%endif
</td>
<td>
%if node.is_file():
${node.last_changeset.author}
%endif
</td>
</tr>
%endfor
</tbody>
<tbody id="tbody_filtered" style="display:none">
</tbody>
</table>
</div>
</div>
|