Show More
@@ -217,11 +217,11 b' class CodeHtmlFormatter(HtmlFormatter):' | |||||
217 | '<tr><td><div class="linenodiv" ' |
|
217 | '<tr><td><div class="linenodiv" ' | |
218 | 'style="background-color: #f0f0f0; padding-right: 10px">' |
|
218 | 'style="background-color: #f0f0f0; padding-right: 10px">' | |
219 | '<pre style="line-height: 125%">' + |
|
219 | '<pre style="line-height: 125%">' + | |
220 | ls + '</pre></div></td><td class="code">') |
|
220 | ls + '</pre></div></td><td id="hlcode" class="code">') | |
221 | else: |
|
221 | else: | |
222 | yield 0, ('<table class="%stable">' % self.cssclass + |
|
222 | yield 0, ('<table class="%stable">' % self.cssclass + | |
223 | '<tr><td class="linenos"><div class="linenodiv"><pre>' + |
|
223 | '<tr><td class="linenos"><div class="linenodiv"><pre>' + | |
224 | ls + '</pre></div></td><td class="code">') |
|
224 | ls + '</pre></div></td><td id="hlcode" class="code">') | |
225 | yield 0, dummyoutfile.getvalue() |
|
225 | yield 0, dummyoutfile.getvalue() | |
226 | yield 0, '</td></tr></table>' |
|
226 | yield 0, '</td></tr></table>' | |
227 |
|
227 | |||
@@ -252,7 +252,7 b' def pygmentize_annotation(repo_name, fil' | |||||
252 | golden_ratio = 0.618033988749895 |
|
252 | golden_ratio = 0.618033988749895 | |
253 | h = 0.22717784590367374 |
|
253 | h = 0.22717784590367374 | |
254 |
|
254 | |||
255 |
for |
|
255 | for _ in xrange(n): | |
256 | h += golden_ratio |
|
256 | h += golden_ratio | |
257 | h %= 1 |
|
257 | h %= 1 | |
258 | HSV_tuple = [h, 0.95, 0.95] |
|
258 | HSV_tuple = [h, 0.95, 0.95] |
@@ -73,24 +73,63 b'' | |||||
73 | ${_('Binary file (%s)') % c.file.mimetype} |
|
73 | ${_('Binary file (%s)') % c.file.mimetype} | |
74 | %else: |
|
74 | %else: | |
75 | % if c.file.size < c.cut_off_limit: |
|
75 | % if c.file.size < c.cut_off_limit: | |
76 |
${h.pygmentize_annotation(c.repo_name,c.file,linenos=True,anchorlinenos=True,lineanchors=' |
|
76 | ${h.pygmentize_annotation(c.repo_name,c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")} | |
77 | %else: |
|
77 | %else: | |
78 | ${_('File is to big to display')} ${h.link_to(_('show as raw'), |
|
78 | ${_('File is to big to display')} ${h.link_to(_('show as raw'), | |
79 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.cs.revision,f_path=c.f_path))} |
|
79 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.cs.revision,f_path=c.f_path))} | |
80 | %endif |
|
80 | %endif | |
81 |
|
|
81 | <script type="text/javascript"> | |
82 | YAHOO.util.Event.onDOMReady(function(){ |
|
82 | function highlight_lines(lines){ | |
83 | YAHOO.util.Event.addListener('show_rev','click',function(e){ |
|
83 | for(pos in lines){ | |
84 | YAHOO.util.Event.preventDefault(e); |
|
84 | YUD.setStyle('L'+lines[pos],'background-color','#FFFFBE'); | |
85 | var cs = YAHOO.util.Dom.get('diff1').value; |
|
85 | } | |
86 | var url = "${h.url('files_annotate_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs); |
|
86 | } | |
87 | window.location = url; |
|
87 | page_highlights = location.href.substring(location.href.indexOf('#')+1).split('L'); | |
88 | }); |
|
88 | if (page_highlights.length == 2){ | |
89 | }); |
|
89 | highlight_ranges = page_highlights[1].split(","); | |
90 | </script> |
|
90 | ||
|
91 | var h_lines = []; | |||
|
92 | for (pos in highlight_ranges){ | |||
|
93 | var _range = highlight_ranges[pos].split('-'); | |||
|
94 | if(_range.length == 2){ | |||
|
95 | var start = parseInt(_range[0]); | |||
|
96 | var end = parseInt(_range[1]); | |||
|
97 | if (start < end){ | |||
|
98 | for(var i=start;i<=end;i++){ | |||
|
99 | h_lines.push(i); | |||
|
100 | } | |||
|
101 | } | |||
|
102 | } | |||
|
103 | else{ | |||
|
104 | h_lines.push(parseInt(highlight_ranges[pos])); | |||
|
105 | } | |||
|
106 | } | |||
|
107 | highlight_lines(h_lines); | |||
|
108 | ||||
|
109 | //remember original location | |||
|
110 | var old_hash = location.href.substring(location.href.indexOf('#')); | |||
|
111 | ||||
|
112 | // this makes a jump to anchor moved by 3 posstions for padding | |||
|
113 | window.location.hash = '#L'+Math.max(parseInt(h_lines[0])-3,1); | |||
|
114 | ||||
|
115 | //sets old anchor | |||
|
116 | window.location.hash = old_hash; | |||
|
117 | ||||
|
118 | } | |||
|
119 | </script> | |||
91 | %endif |
|
120 | %endif | |
92 | </div> |
|
121 | </div> | |
93 | </div> |
|
122 | </div> | |
|
123 | <script type="text/javascript"> | |||
|
124 | YAHOO.util.Event.onDOMReady(function(){ | |||
|
125 | YUE.on('show_rev','click',function(e){ | |||
|
126 | YAHOO.util.Event.preventDefault(e); | |||
|
127 | var cs = YAHOO.util.Dom.get('diff1').value; | |||
|
128 | var url = "${h.url('files_annotate_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs); | |||
|
129 | window.location = url; | |||
|
130 | }); | |||
|
131 | }); | |||
|
132 | </script> | |||
94 | </div> |
|
133 | </div> | |
95 | </div> |
|
134 | </div> | |
96 | </div> |
|
135 | </div> |
@@ -51,12 +51,11 b'' | |||||
51 | ${_('File is to big to display')} ${h.link_to(_('show as raw'), |
|
51 | ${_('File is to big to display')} ${h.link_to(_('show as raw'), | |
52 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path))} |
|
52 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path))} | |
53 | %endif |
|
53 | %endif | |
54 |
|
||||
55 | <script type="text/javascript"> |
|
54 | <script type="text/javascript"> | |
56 | function highlight_lines(lines){ |
|
55 | function highlight_lines(lines){ | |
57 | for(pos in lines){ |
|
56 | for(pos in lines){ | |
58 | YUD.setStyle('L'+lines[pos],'background-color','#FFFFBE'); |
|
57 | YUD.setStyle('L'+lines[pos],'background-color','#FFFFBE'); | |
59 |
} |
|
58 | } | |
60 | } |
|
59 | } | |
61 | page_highlights = location.href.substring(location.href.indexOf('#')+1).split('L'); |
|
60 | page_highlights = location.href.substring(location.href.indexOf('#')+1).split('L'); | |
62 | if (page_highlights.length == 2){ |
|
61 | if (page_highlights.length == 2){ | |
@@ -78,7 +77,17 b'' | |||||
78 | h_lines.push(parseInt(highlight_ranges[pos])); |
|
77 | h_lines.push(parseInt(highlight_ranges[pos])); | |
79 | } |
|
78 | } | |
80 | } |
|
79 | } | |
81 |
highlight_lines(h_lines); |
|
80 | highlight_lines(h_lines); | |
|
81 | ||||
|
82 | //remember original location | |||
|
83 | var old_hash = location.href.substring(location.href.indexOf('#')); | |||
|
84 | ||||
|
85 | // this makes a jump to anchor moved by 3 posstions for padding | |||
|
86 | window.location.hash = '#L'+Math.max(parseInt(h_lines[0])-3,1); | |||
|
87 | ||||
|
88 | //sets old anchor | |||
|
89 | window.location.hash = old_hash; | |||
|
90 | ||||
82 | } |
|
91 | } | |
83 | </script> |
|
92 | </script> | |
84 | %endif |
|
93 | %endif | |
@@ -86,12 +95,79 b'' | |||||
86 | </div> |
|
95 | </div> | |
87 |
|
96 | |||
88 | <script type="text/javascript"> |
|
97 | <script type="text/javascript"> | |
89 |
Y |
|
98 | YUE.onDOMReady(function(){ | |
90 |
Y |
|
99 | YUE.on('show_rev','click',function(e){ | |
91 |
Y |
|
100 | YUE.preventDefault(e); | |
92 | var cs = YAHOO.util.Dom.get('diff1').value; |
|
101 | var cs = YAHOO.util.Dom.get('diff1').value; | |
93 | var url = "${h.url('files_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs); |
|
102 | var url = "${h.url('files_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs); | |
94 | window.location = url; |
|
103 | window.location = url; | |
95 |
|
|
104 | }); | |
|
105 | ||||
|
106 | function getIdentNode(n){ | |||
|
107 | //iterate thru nodes untill matched interesting node ! | |||
|
108 | ||||
|
109 | if (typeof n == 'undefined'){ | |||
|
110 | return -1 | |||
|
111 | } | |||
|
112 | ||||
|
113 | if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){ | |||
|
114 | return n | |||
|
115 | } | |||
|
116 | else{ | |||
|
117 | return getIdentNode(n.parentNode); | |||
|
118 | } | |||
|
119 | } | |||
|
120 | ||||
|
121 | function getSelectionLink() { | |||
|
122 | //get selection from start/to nodes | |||
|
123 | if (typeof window.getSelection != "undefined") { | |||
|
124 | s = window.getSelection(); | |||
|
125 | ||||
|
126 | from = getIdentNode(s.anchorNode); | |||
|
127 | till = getIdentNode(s.focusNode); | |||
|
128 | ||||
|
129 | f_int = parseInt(from.id.replace('L','')); | |||
|
130 | t_int = parseInt(till.id.replace('L','')); | |||
|
131 | ||||
|
132 | if (f_int > t_int){ | |||
|
133 | //highlight from bottom | |||
|
134 | offset = -35; | |||
|
135 | } | |||
|
136 | else{ | |||
|
137 | //highligth from top | |||
|
138 | offset = 35; | |||
|
139 | } | |||
|
140 | ||||
|
141 | ranges = [f_int,t_int].sort(); | |||
|
142 | ||||
|
143 | if (ranges[0] != ranges[1]){ | |||
|
144 | if(YUD.get('linktt') == null){ | |||
|
145 | hl_div = document.createElement('div'); | |||
|
146 | hl_div.id = 'linktt'; | |||
|
147 | } | |||
|
148 | anchor = '#L'+ranges[0]+'-'+ranges[1]; | |||
|
149 | hl_div.innerHTML = ''; | |||
|
150 | l = document.createElement('a'); | |||
|
151 | l.href = location.href.substring(0,location.href.indexOf('#'))+anchor; | |||
|
152 | l.innerHTML = "${_('Selection link')}" | |||
|
153 | hl_div.appendChild(l); | |||
|
154 | ||||
|
155 | YUD.get('body').appendChild(hl_div); | |||
|
156 | ||||
|
157 | xy = YUD.getXY(till.id); | |||
|
158 | ||||
|
159 | YUD.addClass('linktt','yui-tt'); | |||
|
160 | YUD.setStyle('linktt','top',xy[1]+offset+'px'); | |||
|
161 | YUD.setStyle('linktt','left',xy[0]+'px'); | |||
|
162 | YUD.setStyle('linktt','visibility','visible'); | |||
|
163 | } | |||
|
164 | else{ | |||
|
165 | YUD.setStyle('linktt','visibility','hidden'); | |||
|
166 | } | |||
|
167 | } | |||
|
168 | } | |||
|
169 | ||||
|
170 | YUE.on('hlcode','mouseup',getSelectionLink) | |||
|
171 | ||||
96 | }); |
|
172 | }); | |
97 | </script> No newline at end of file |
|
173 | </script> |
General Comments 0
You need to be logged in to leave comments.
Login now