@@ -147,6 +147,52 @@ document.pageReady.push(function() { pageReadyList();});
147147
148148 }
149149 }
150+ } else if (cfg. annotate()) {
151+ // annotate
152+ BufferedInputStream bin =
153+ new BufferedInputStream (new FileInputStream (resourceFile));
154+ try {
155+ FileAnalyzerFactory a = AnalyzerGuru . find(basename);
156+ Genre g = AnalyzerGuru . getGenre(a);
157+ if (g == null ) {
158+ a = AnalyzerGuru . find(bin);
159+ g = AnalyzerGuru . getGenre(a);
160+ }
161+ if (g == Genre . IMAGE ) {
162+ % >
163+ <div id =" src" >
164+ <img src =" <%= rawPath % >" />
165+ </div ><%
166+ } else if ( g == Genre . HTML ) {
167+ r = new InputStreamReader (bin);
168+ Util . dump(out, r);
169+ } else if (g == Genre . PLAIN ) {
170+ % >
171+ <div id =" src" data-navigate-window-enabled =" <%= navigateWindowEnabled % >" >
172+ <pre ><%
173+ // We're generating xref for the latest revision, so we can
174+ // find the definitions in the index.
175+ Definitions defs = IndexDatabase . getDefinitions(resourceFile);
176+ Annotation annotation = cfg. getAnnotation();
177+ r = IOUtils . createBOMStrippedReader(bin);
178+ AnalyzerGuru . writeXref(a, r, out, defs, annotation,
179+ Project . getProject(resourceFile));
180+ % > </pre >
181+ </div ><%
182+ } else {
183+ % >
184+ Click <a href =" <%= rawPath % >" >download <%= basename % > </a ><%
185+ }
186+ } finally {
187+ if (r != null ) {
188+ try { r. close(); bin = null ; }
189+ catch (Exception e) { /* ignore */ }
190+ }
191+ if (bin != null ) {
192+ try { bin. close(); }
193+ catch (Exception e) { /* ignore */ }
194+ }
195+ }
150196 } else if (rev. length() != 0 ) {
151197 // requesting a revision
152198 if (cfg. isLatestRevision(rev)) {
@@ -248,70 +294,24 @@ document.pageReady.push(function() { pageReadyList();});
248294 } else {
249295 // requesting cross referenced file
250296 File xrefFile = null ;
251- if (! cfg. annotate()) {
252- // Get the latest revision and redirect so that the revision number
253- // appears in the URL.
254- String location = cfg. getLatestRevisionLocation();
255- if (location != null ) {
256- response. sendRedirect(location);
257- return ;
258- } else {
259- xrefFile = cfg. findDataFile();
260- }
297+
298+ // Get the latest revision and redirect so that the revision number
299+ // appears in the URL.
300+ String location = cfg. getLatestRevisionLocation();
301+ if (location != null ) {
302+ response. sendRedirect(location);
303+ return ;
304+ } else {
305+ xrefFile = cfg. findDataFile();
261306 }
307+
262308 if (xrefFile != null ) {
263309% >
264310<div id =" src" data-navigate-window-enabled =" <%= navigateWindowEnabled % >" >
265311 <pre ><%
266312 Util . dump(out, xrefFile, xrefFile. getName(). endsWith(" .gz" ));
267313 % > </pre >
268314</div ><%
269- } else {
270- // annotate
271- BufferedInputStream bin =
272- new BufferedInputStream (new FileInputStream (resourceFile));
273- try {
274- FileAnalyzerFactory a = AnalyzerGuru . find(basename);
275- Genre g = AnalyzerGuru . getGenre(a);
276- if (g == null ) {
277- a = AnalyzerGuru . find(bin);
278- g = AnalyzerGuru . getGenre(a);
279- }
280- if (g == Genre . IMAGE ) {
281- % >
282- <div id =" src" >
283- <img src =" <%= rawPath % >" />
284- </div ><%
285- } else if ( g == Genre . HTML ) {
286- r = new InputStreamReader (bin);
287- Util . dump(out, r);
288- } else if (g == Genre . PLAIN ) {
289- % >
290- <div id =" src" data-navigate-window-enabled =" <%= navigateWindowEnabled % >" >
291- <pre ><%
292- // We're generating xref for the latest revision, so we can
293- // find the definitions in the index.
294- Definitions defs = IndexDatabase . getDefinitions(resourceFile);
295- Annotation annotation = cfg. getAnnotation();
296- r = IOUtils . createBOMStrippedReader(bin);
297- AnalyzerGuru . writeXref(a, r, out, defs, annotation,
298- Project . getProject(resourceFile));
299- % > </pre >
300- </div ><%
301- } else {
302- % >
303- Click <a href =" <%= rawPath % >" >download <%= basename % > </a ><%
304- }
305- } finally {
306- if (r != null ) {
307- try { r. close(); bin = null ; }
308- catch (Exception e) { /* ignore */ }
309- }
310- if (bin != null ) {
311- try { bin. close(); }
312- catch (Exception e) { /* ignore */ }
313- }
314- }
315315 }
316316 }
317317}
0 commit comments