Show More
@@ -1,159 +1,161 b'' | |||
|
1 | 1 | <%inherit file="/base/base.html"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${_('%s files') % c.repo_name} - ${c.rhodecode_name} |
|
5 | 5 | </%def> |
|
6 | 6 | |
|
7 | 7 | <%def name="breadcrumbs_links()"> |
|
8 | 8 | ${h.link_to(_(u'Home'),h.url('/'))} |
|
9 | 9 | » |
|
10 | 10 | ${h.link_to(c.repo_name,h.url('files_home',repo_name=c.repo_name))} |
|
11 | 11 | » |
|
12 | 12 | ${_('files')} |
|
13 | 13 | %if c.file: |
|
14 | 14 | @ r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} |
|
15 | 15 | %endif |
|
16 | 16 | </%def> |
|
17 | 17 | |
|
18 | 18 | <%def name="page_nav()"> |
|
19 | 19 | ${self.menu('files')} |
|
20 | 20 | </%def> |
|
21 | 21 | |
|
22 | 22 | <%def name="main()"> |
|
23 | 23 | <div class="box"> |
|
24 | 24 | <!-- box / title --> |
|
25 | 25 | <div class="title"> |
|
26 | 26 | ${self.breadcrumbs()} |
|
27 | 27 | <ul class="links"> |
|
28 | 28 | <li> |
|
29 | 29 | <span style="text-transform: uppercase;"><a href="#">${_('branch')}: ${c.changeset.branch}</a></span> |
|
30 | 30 | </li> |
|
31 | 31 | </ul> |
|
32 | 32 | </div> |
|
33 | 33 | <div class="table"> |
|
34 | 34 | <div id="files_data"> |
|
35 | 35 | <%include file='files_ypjax.html'/> |
|
36 | 36 | </div> |
|
37 | 37 | </div> |
|
38 | 38 | </div> |
|
39 | 39 | |
|
40 | 40 | <script type="text/javascript"> |
|
41 | 41 | var CACHE = {}; |
|
42 | 42 | var CACHE_EXPIRE = 5*60*1000; //cache for 5*60s |
|
43 | 43 | //used to construct links from the search list |
|
44 | 44 | var url_base = '${h.url("files_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; |
|
45 | 45 | //send the nodelist request to this url |
|
46 | 46 | var node_list_url = '${h.url("files_nodelist_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; |
|
47 | 47 | // send the node history requst to this url |
|
48 | 48 | var node_history_url = '${h.url("files_history_home",repo_name=c.repo_name,revision='__REV__',f_path='__FPATH__')}'; |
|
49 | 49 | |
|
50 | 50 | var ypjax_links = function(){ |
|
51 | 51 | YUE.on(YUQ('.ypjax-link'), 'click',function(e){ |
|
52 | 52 | |
|
53 | 53 | //don't do ypjax on middle click |
|
54 | 54 | if(e.which == 2 || !History.enabled){ |
|
55 | 55 | return true; |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | var el = e.currentTarget; |
|
59 | 59 | var url = el.href; |
|
60 | 60 | |
|
61 | 61 | var _base_url = '${h.url("files_home",repo_name=c.repo_name,revision='',f_path='')}'; |
|
62 | 62 | _base_url = _base_url.replace('//','/') |
|
63 | 63 | |
|
64 | 64 | //extract rev and the f_path from url. |
|
65 | 65 | parts = url.split(_base_url) |
|
66 | 66 | if(parts.length != 2){ |
|
67 | 67 | return false; |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | var parts2 = parts[1].split('/'); |
|
71 | 71 | var rev = parts2.shift(); // pop the first element which is the revision |
|
72 | 72 | var f_path = parts2.join('/'); |
|
73 | 73 | |
|
74 | 74 | var title = "${_('%s files') % c.repo_name}" + " - " + f_path; |
|
75 | 75 | |
|
76 | 76 | var _node_list_url = node_list_url.replace('__REV__',rev).replace('__FPATH__', f_path); |
|
77 | 77 | var _url_base = url_base.replace('__REV__',rev); |
|
78 | 78 | |
|
79 | 79 | // Change our States and save some data for handling events |
|
80 | 80 | var data = {url:url,title:title, url_base:_url_base, |
|
81 | 81 | node_list_url:_node_list_url, rev:rev, f_path:f_path}; |
|
82 | 82 | History.pushState(data, title, url); |
|
83 | 83 | |
|
84 | 84 | //now we're sure that we can do ypjax things |
|
85 | 85 | YUE.preventDefault(e); |
|
86 | 86 | return false; |
|
87 | 87 | }); |
|
88 | 88 | } |
|
89 | 89 | |
|
90 | 90 | var callbacks = function(State){ |
|
91 | 91 | ypjax_links(); |
|
92 | 92 | tooltip_activate(); |
|
93 | 93 | fileBrowserListeners(State.url, State.data.node_list_url, State.data.url_base); |
|
94 | 94 | |
|
95 | 95 | if(YUD.get('hlcode')){ |
|
96 | 96 | YUE.on('hlcode', 'mouseup', getSelectionLink); |
|
97 | 97 | } |
|
98 | 98 | //console.log(State); |
|
99 | 99 | if(YUD.get('load_node_history')){ |
|
100 | 100 | //remove all listeners due to problems of history state |
|
101 | 101 | YUE.removeListener('load_node_history', 'click'); |
|
102 | 102 | YUE.on('load_node_history', 'click', function(e){ |
|
103 | 103 | var _url = node_history_url.replace('__REV__',State.data.rev).replace('__FPATH__', State.data.f_path); |
|
104 |
ypjax(_url, 'node_history', function(o){ |
|
|
104 | ypjax(_url, 'node_history', function(o){ | |
|
105 | tooltip_activate(); | |
|
106 | }) | |
|
105 | 107 | }); |
|
106 | 108 | } |
|
107 | 109 | // Inform Google Analytics of the change |
|
108 | 110 | if ( typeof window.pageTracker !== 'undefined' ) { |
|
109 | 111 | window.pageTracker._trackPageview(State.url); |
|
110 | 112 | } |
|
111 | 113 | } |
|
112 | 114 | |
|
113 | 115 | YUE.onDOMReady(function(){ |
|
114 | 116 | ypjax_links(); |
|
115 | 117 | var container = 'files_data'; |
|
116 | 118 | //Bind to StateChange Event |
|
117 | 119 | History.Adapter.bind(window,'statechange',function(){ |
|
118 | 120 | var State = History.getState(); |
|
119 | 121 | cache_key = State.url; |
|
120 | 122 | //check if we have this request in cache maybe ? |
|
121 | 123 | var _cache_obj = CACHE[cache_key]; |
|
122 | 124 | var _cur_time = new Date().getTime(); |
|
123 | 125 | // get from cache if it's there and not yet expired ! |
|
124 | 126 | if(_cache_obj !== undefined && _cache_obj[0] > _cur_time){ |
|
125 | 127 | YUD.get(container).innerHTML=_cache_obj[1]; |
|
126 | 128 | YUD.setStyle(container,'opacity','1.0'); |
|
127 | 129 | |
|
128 | 130 | //callbacks after ypjax call |
|
129 | 131 | callbacks(State); |
|
130 | 132 | } |
|
131 | 133 | else{ |
|
132 | 134 | ypjax(State.url,container,function(o){ |
|
133 | 135 | //callbacks after ypjax call |
|
134 | 136 | callbacks(State); |
|
135 | 137 | if (o !== undefined){ |
|
136 | 138 | //store our request in cache |
|
137 | 139 | var _expire_on = new Date().getTime()+CACHE_EXPIRE; |
|
138 | 140 | CACHE[cache_key] = [_expire_on, o.responseText]; |
|
139 | 141 | } |
|
140 | 142 | }); |
|
141 | 143 | } |
|
142 | 144 | }); |
|
143 | 145 | |
|
144 | 146 | // init the search filter |
|
145 | 147 | var _State = { |
|
146 | 148 | url: "${h.url.current()}", |
|
147 | 149 | data: { |
|
148 | 150 | node_list_url: node_list_url.replace('__REV__',"${c.changeset.raw_id}").replace('__FPATH__', "${h.safe_unicode(c.file.path)}"), |
|
149 | 151 | url_base: url_base.replace('__REV__',"${c.changeset.raw_id}"), |
|
150 | 152 | rev:"${c.changeset.raw_id}", |
|
151 | 153 | f_path: "${h.safe_unicode(c.file.path)}" |
|
152 | 154 | } |
|
153 | 155 | } |
|
154 | 156 | fileBrowserListeners(_State.url, _State.data.node_list_url, _State.data.url_base); |
|
155 | 157 | }); |
|
156 | 158 | |
|
157 | 159 | </script> |
|
158 | 160 | |
|
159 | 161 | </%def> |
@@ -1,111 +1,113 b'' | |||
|
1 | 1 | <div id="node_history"> |
|
2 | 2 | %if c.load_full_history: |
|
3 | 3 | <%include file='files_history_box.html'/> |
|
4 | 4 | %else: |
|
5 | 5 | <div style="padding-bottom:10px"> |
|
6 | 6 | <span id="load_node_history" class="ui-btn">${_('Load file history')}</span> |
|
7 | 7 | </div> |
|
8 | 8 | %endif |
|
9 | 9 | </div> |
|
10 | 10 | |
|
11 | 11 | |
|
12 | 12 | <div id="body" class="codeblock"> |
|
13 | 13 | <div class="code-header"> |
|
14 | 14 | <div class="stats"> |
|
15 | 15 | <div class="left img"><img src="${h.url('/images/icons/file.png')}"/></div> |
|
16 | 16 | <div class="left item"><pre class="tooltip" title="${h.tooltip(h.fmt_date(c.file_changeset.date))}">${h.link_to("r%s:%s" % (c.file_changeset.revision,h.short_id(c.file_changeset.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id))}</pre></div> |
|
17 | 17 | <div class="left item"><pre>${h.format_byte_size(c.file.size,binary=True)}</pre></div> |
|
18 | 18 | <div class="left item last"><pre>${c.file.mimetype}</pre></div> |
|
19 | 19 | <div class="buttons"> |
|
20 | 20 | %if c.annotate: |
|
21 | 21 | ${h.link_to(_('show source'), h.url('files_home', repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")} |
|
22 | 22 | %else: |
|
23 | 23 | ${h.link_to(_('show annotation'),h.url('files_annotate_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")} |
|
24 | 24 | %endif |
|
25 | 25 | ${h.link_to(_('show as raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")} |
|
26 | 26 | ${h.link_to(_('download as raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")} |
|
27 | 27 | % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name): |
|
28 | 28 | % if not c.file.is_binary: |
|
29 | 29 | ${h.link_to(_('edit'),h.url('files_edit_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")} |
|
30 | 30 | % endif |
|
31 | 31 | % endif |
|
32 | 32 | </div> |
|
33 | 33 | </div> |
|
34 | 34 | <div class="author"> |
|
35 | 35 | <div class="gravatar"> |
|
36 | 36 | <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(c.file_changeset.author),16)}"/> |
|
37 | 37 | </div> |
|
38 | 38 | <div title="${c.file_changeset.author}" class="user">${h.person(c.file_changeset.author)}</div> |
|
39 | 39 | </div> |
|
40 | 40 | <div class="commit">${h.urlify_commit(c.file_changeset.message,c.repo_name)}</div> |
|
41 | 41 | </div> |
|
42 | 42 | <div class="code-body"> |
|
43 | 43 | %if c.file.is_binary: |
|
44 | 44 | ${_('Binary file (%s)') % c.file.mimetype} |
|
45 | 45 | %else: |
|
46 | 46 | % if c.file.size < c.cut_off_limit: |
|
47 | 47 | %if c.annotate: |
|
48 | 48 | ${h.pygmentize_annotation(c.repo_name,c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")} |
|
49 | 49 | %else: |
|
50 | 50 | ${h.pygmentize(c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")} |
|
51 | 51 | %endif |
|
52 | 52 | %else: |
|
53 | 53 | ${_('File is too big to display')} ${h.link_to(_('show as raw'), |
|
54 | 54 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path))} |
|
55 | 55 | %endif |
|
56 | 56 | %endif |
|
57 | 57 | </div> |
|
58 | 58 | </div> |
|
59 | 59 | |
|
60 | 60 | <script type="text/javascript"> |
|
61 | 61 | YUE.onDOMReady(function(){ |
|
62 | 62 | function highlight_lines(lines){ |
|
63 | 63 | for(pos in lines){ |
|
64 | 64 | YUD.setStyle('L'+lines[pos],'background-color','#FFFFBE'); |
|
65 | 65 | } |
|
66 | 66 | } |
|
67 | 67 | page_highlights = location.href.substring(location.href.indexOf('#')+1).split('L'); |
|
68 | 68 | if (page_highlights.length == 2){ |
|
69 | 69 | highlight_ranges = page_highlights[1].split(","); |
|
70 | 70 | |
|
71 | 71 | var h_lines = []; |
|
72 | 72 | for (pos in highlight_ranges){ |
|
73 | 73 | var _range = highlight_ranges[pos].split('-'); |
|
74 | 74 | if(_range.length == 2){ |
|
75 | 75 | var start = parseInt(_range[0]); |
|
76 | 76 | var end = parseInt(_range[1]); |
|
77 | 77 | if (start < end){ |
|
78 | 78 | for(var i=start;i<=end;i++){ |
|
79 | 79 | h_lines.push(i); |
|
80 | 80 | } |
|
81 | 81 | } |
|
82 | 82 | } |
|
83 | 83 | else{ |
|
84 | 84 | h_lines.push(parseInt(highlight_ranges[pos])); |
|
85 | 85 | } |
|
86 | 86 | } |
|
87 | 87 | highlight_lines(h_lines); |
|
88 | 88 | |
|
89 | 89 | //remember original location |
|
90 | 90 | var old_hash = location.href.substring(location.href.indexOf('#')); |
|
91 | 91 | |
|
92 | 92 | // this makes a jump to anchor moved by 3 posstions for padding |
|
93 | 93 | window.location.hash = '#L'+Math.max(parseInt(h_lines[0])-3,1); |
|
94 | 94 | |
|
95 | 95 | //sets old anchor |
|
96 | 96 | window.location.hash = old_hash; |
|
97 | 97 | |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | // select code link event |
|
101 | 101 | YUE.on('hlcode', 'mouseup', getSelectionLink); |
|
102 | 102 | |
|
103 | 103 | //load history of file |
|
104 | 104 | YUE.on('load_node_history', 'click', function(e){ |
|
105 | 105 | var _url = node_history_url.replace('__REV__','${c.file_changeset.raw_id}').replace('__FPATH__', '${c.f_path}'); |
|
106 |
ypjax(_url, 'node_history', function(o){ |
|
|
106 | ypjax(_url, 'node_history', function(o){ | |
|
107 | tooltip_activate(); | |
|
108 | }) | |
|
107 | 109 | }); |
|
108 | 110 | |
|
109 | 111 | }); |
|
110 | 112 | |
|
111 | 113 | </script> |
General Comments 0
You need to be logged in to leave comments.
Login now