Show More
@@ -217,11 +217,11 b' class CodeHtmlFormatter(HtmlFormatter):' | |||
|
217 | 217 | '<tr><td><div class="linenodiv" ' |
|
218 | 218 | 'style="background-color: #f0f0f0; padding-right: 10px">' |
|
219 | 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 | 221 | else: |
|
222 | 222 | yield 0, ('<table class="%stable">' % self.cssclass + |
|
223 | 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 | 225 | yield 0, dummyoutfile.getvalue() |
|
226 | 226 | yield 0, '</td></tr></table>' |
|
227 | 227 | |
@@ -252,7 +252,7 b' def pygmentize_annotation(repo_name, fil' | |||
|
252 | 252 | golden_ratio = 0.618033988749895 |
|
253 | 253 | h = 0.22717784590367374 |
|
254 | 254 | |
|
255 |
for |
|
|
255 | for _ in xrange(n): | |
|
256 | 256 | h += golden_ratio |
|
257 | 257 | h %= 1 |
|
258 | 258 | HSV_tuple = [h, 0.95, 0.95] |
@@ -73,14 +73,56 b'' | |||
|
73 | 73 | ${_('Binary file (%s)') % c.file.mimetype} |
|
74 | 74 | %else: |
|
75 | 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 | 77 | %else: |
|
78 | 78 | ${_('File is to big to display')} ${h.link_to(_('show as raw'), |
|
79 | 79 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.cs.revision,f_path=c.f_path))} |
|
80 | 80 | %endif |
|
81 | 81 |
|
|
82 | function highlight_lines(lines){ | |
|
83 | for(pos in lines){ | |
|
84 | YUD.setStyle('L'+lines[pos],'background-color','#FFFFBE'); | |
|
85 | } | |
|
86 | } | |
|
87 | page_highlights = location.href.substring(location.href.indexOf('#')+1).split('L'); | |
|
88 | if (page_highlights.length == 2){ | |
|
89 | highlight_ranges = page_highlights[1].split(","); | |
|
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> | |
|
120 | %endif | |
|
121 | </div> | |
|
122 | </div> | |
|
123 | <script type="text/javascript"> | |
|
82 | 124 |
|
|
83 |
|
|
|
125 | YUE.on('show_rev','click',function(e){ | |
|
84 | 126 |
|
|
85 | 127 |
|
|
86 | 128 |
|
@@ -88,9 +130,6 b'' | |||
|
88 | 130 |
|
|
89 | 131 |
|
|
90 | 132 |
|
|
91 | %endif | |
|
92 | </div> | |
|
93 | </div> | |
|
94 | 133 | </div> |
|
95 | 134 | </div> |
|
96 | 135 | </div> |
@@ -51,7 +51,6 b'' | |||
|
51 | 51 | ${_('File is to big to display')} ${h.link_to(_('show as raw'), |
|
52 | 52 | h.url('files_raw_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path))} |
|
53 | 53 | %endif |
|
54 | ||
|
55 | 54 | <script type="text/javascript"> |
|
56 | 55 | function highlight_lines(lines){ |
|
57 | 56 | for(pos in lines){ |
@@ -79,6 +78,16 b'' | |||
|
79 | 78 | } |
|
80 | 79 | } |
|
81 | 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 | 92 | </script> |
|
84 | 93 | %endif |
@@ -86,12 +95,79 b'' | |||
|
86 | 95 | </div> |
|
87 | 96 | |
|
88 | 97 | <script type="text/javascript"> |
|
89 |
Y |
|
|
90 |
Y |
|
|
91 |
Y |
|
|
98 | YUE.onDOMReady(function(){ | |
|
99 | YUE.on('show_rev','click',function(e){ | |
|
100 | YUE.preventDefault(e); | |
|
92 | 101 | var cs = YAHOO.util.Dom.get('diff1').value; |
|
93 | 102 | var url = "${h.url('files_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs); |
|
94 | 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 | 173 | </script> No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now