files.html
144 lines
| 4.4 KiB
| text/html
|
HtmlLexer
r547 | <%inherit file="/base/base.html"/> | |||
<%def name="title()"> | ||||
r2686 | ${_('%s files') % c.repo_name} - ${c.rhodecode_name} | |||
r547 | </%def> | |||
<%def name="breadcrumbs_links()"> | ||||
Takumi IINO
|
r2492 | ${h.link_to(_(u'Home'),h.url('/'))} | ||
r547 | » | |||
${h.link_to(c.repo_name,h.url('files_home',repo_name=c.repo_name))} | ||||
» | ||||
${_('files')} | ||||
r1737 | %if c.file: | |||
r644 | @ r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} | |||
r1888 | %endif | |||
r547 | </%def> | |||
<%def name="page_nav()"> | ||||
r1888 | ${self.menu('files')} | |||
r547 | </%def> | |||
<%def name="main()"> | ||||
<div class="box"> | ||||
<!-- box / title --> | ||||
<div class="title"> | ||||
r644 | ${self.breadcrumbs()} | |||
<ul class="links"> | ||||
<li> | ||||
<span style="text-transform: uppercase;"><a href="#">${_('branch')}: ${c.changeset.branch}</a></span> | ||||
r1888 | </li> | |||
</ul> | ||||
r547 | </div> | |||
<div class="table"> | ||||
<div id="files_data"> | ||||
r1699 | <%include file='files_ypjax.html'/> | |||
r1888 | </div> | |||
r547 | </div> | |||
r1888 | </div> | |||
r2686 | ||||
r1699 | <script type="text/javascript"> | |||
r2686 | var CACHE = {}; | |||
var CACHE_EXPIRE = 60*1000; //cache for 60s | ||||
r2687 | //used to construct links from the search list | |||
r2891 | var url_base = '${h.url("files_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; | |||
r2687 | //send the nodelist request to this url | |||
r2891 | var node_list_url = '${h.url("files_nodelist_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; | |||
r2686 | ||||
var ypjax_links = function(){ | ||||
YUE.on(YUQ('.ypjax-link'), 'click',function(e){ | ||||
r2815 | ||||
r2686 | //don't do ypjax on middle click | |||
r2815 | if(e.which == 2 || !History.enabled){ | |||
r2686 | return true; | |||
} | ||||
r2815 | ||||
r2686 | var el = e.currentTarget; | |||
var url = el.href; | ||||
r2691 | ||||
r2686 | var _base_url = '${h.url("files_home",repo_name=c.repo_name,revision='',f_path='')}'; | |||
_base_url = _base_url.replace('//','/') | ||||
r2815 | ||||
r2686 | //extract rev and the f_path from url. | |||
parts = url.split(_base_url) | ||||
if(parts.length != 2){ | ||||
return false; | ||||
} | ||||
r2815 | ||||
r2686 | var parts2 = parts[1].split('/'); | |||
var rev = parts2.shift(); // pop the first element which is the revision | ||||
var f_path = parts2.join('/'); | ||||
r2815 | ||||
r2686 | var title = "${_('%s files') % c.repo_name}" + " - " + f_path; | |||
r2815 | ||||
r2891 | var _node_list_url = node_list_url.replace('__REV__',rev).replace('__FPATH__', f_path); | |||
var _url_base = url_base.replace('__REV__',rev); | ||||
r2691 | ||||
r2686 | // Change our States and save some data for handling events | |||
r2687 | var data = {url:url,title:title, url_base:_url_base, | |||
node_list_url:_node_list_url}; | ||||
r2815 | History.pushState(data, title, url); | |||
r2686 | //now we're sure that we can do ypjax things | |||
YUE.preventDefault(e) | ||||
return false; | ||||
}); | ||||
} | ||||
var callbacks = function(State){ | ||||
ypjax_links(); | ||||
tooltip_activate(); | ||||
fileBrowserListeners(State.url, State.data.node_list_url, State.data.url_base); | ||||
r2867 | YUE.on('hlcode','mouseup',getSelectionLink("${_('Selection link')}")); | |||
r2686 | // Inform Google Analytics of the change | |||
if ( typeof window.pageTracker !== 'undefined' ) { | ||||
window.pageTracker._trackPageview(State.url); | ||||
r2815 | } | |||
r2686 | } | |||
r2815 | YUE.onDOMReady(function(){ | |||
r2686 | ypjax_links(); | |||
var container = 'files_data'; | ||||
//Bind to StateChange Event | ||||
History.Adapter.bind(window,'statechange',function(){ | ||||
var State = History.getState(); | ||||
cache_key = State.url; | ||||
//check if we have this request in cache maybe ? | ||||
var _cache_obj = CACHE[cache_key]; | ||||
var _cur_time = new Date().getTime(); | ||||
// get from cache if it's there and not yet expired ! | ||||
if(_cache_obj !== undefined && _cache_obj[0] > _cur_time){ | ||||
YUD.get(container).innerHTML=_cache_obj[1]; | ||||
YUD.setStyle(container,'opacity','1.0'); | ||||
//callbacks after ypjax call | ||||
callbacks(State); | ||||
} | ||||
else{ | ||||
ypjax(State.url,container,function(o){ | ||||
//callbacks after ypjax call | ||||
callbacks(State); | ||||
if (o !== undefined){ | ||||
//store our request in cache | ||||
var _expire_on = new Date().getTime()+CACHE_EXPIRE; | ||||
CACHE[cache_key] = [_expire_on, o.responseText]; | ||||
} | ||||
}); | ||||
} | ||||
r2815 | }); | |||
r2687 | // init the search filter | |||
var _State = { | ||||
url: "${h.url.current()}", | ||||
data: { | ||||
r2891 | node_list_url: node_list_url.replace('__REV__',"${c.changeset.raw_id}").replace('__FPATH__', "${h.safe_unicode(c.file.path)}"), | |||
url_base: url_base.replace('__REV__',"${c.changeset.raw_id}") | ||||
r2687 | } | |||
} | ||||
fileBrowserListeners(_State.url, _State.data.node_list_url, _State.data.url_base); | ||||
r2686 | }); | |||
r1699 | </script> | |||
r2686 | ||||
r1888 | </%def> | |||