@@ -56,6 +56,8 @@ org.opengrok.web.DirectoryListing,
56
56
org.opengrok.indexer.web.SearchHelper"
57
57
%>
58
58
<%
59
+ final String DUMMY_REVISION = " unknown" ;
60
+
59
61
{
60
62
// need to set it here since requesting parameters
61
63
if (request. getCharacterEncoding() == null ) {
@@ -65,6 +67,30 @@ org.opengrok.indexer.web.SearchHelper"
65
67
PageConfig cfg = PageConfig . get(request);
66
68
cfg. checkSourceRootExistence();
67
69
70
+ String rev = cfg. getRequestedRevision();
71
+ if (! cfg. isDir() && rev. length() == 0 ) {
72
+ /*
73
+ * Get the latest revision and redirect so that the revision number
74
+ * appears in the URL.
75
+ */
76
+ String location = cfg. getRevisionLocation(cfg. getLatestRevision());
77
+ if (location != null ) {
78
+ response. sendRedirect(location);
79
+ return ;
80
+ }
81
+ if (! cfg. getEnv(). isGenerateHtml()) {
82
+ /*
83
+ * Economy mode is on and failed to get the last revision
84
+ * (presumably running with history turned off). Use dummy
85
+ * revision string so that xref can be generated from the resource
86
+ * file directly.
87
+ */
88
+ location = cfg. getRevisionLocation(DUMMY_REVISION );
89
+ response. sendRedirect(location);
90
+ return ;
91
+ }
92
+ }
93
+
68
94
Annotation annotation = cfg. getAnnotation();
69
95
if (annotation != null ) {
70
96
int r = annotation. getWidestRevision();
@@ -90,7 +116,6 @@ document.pageReady.push(function() { pageReadyList();});
90
116
PageConfig cfg = PageConfig . get(request);
91
117
String rev = cfg. getRequestedRevision();
92
118
Project project = cfg. getProject();
93
- final String DUMMY_REVISION = " unknown" ;
94
119
95
120
String navigateWindowEnabled = project != null ? Boolean . toString(
96
121
project. isNavigateWindowEnabled()) : " false" ;
@@ -186,7 +211,7 @@ document.pageReady.push(function() { pageReadyList();});
186
211
}
187
212
} else if (rev. length() != 0 ) {
188
213
// requesting a revision
189
- File xrefFile = null ;
214
+ File xrefFile;
190
215
if (cfg. isLatestRevision(rev) &&
191
216
(xrefFile = cfg. findDataFile()) != null ) {
192
217
if (cfg. annotate()) {
@@ -396,25 +421,8 @@ Click <a href="<%= rawPath %>">download <%= basename %></a><%
396
421
}
397
422
} else {
398
423
// requesting cross referenced file
399
- File xrefFile = null ;
400
-
401
- // Get the latest revision and redirect so that the revision number appears in the URL.
402
- String location = cfg. getRevisionLocation(cfg. getLatestRevision());
403
- if (location != null ) {
404
- response. sendRedirect(location);
405
- return ;
406
- } else {
407
- if (! cfg. getEnv(). isGenerateHtml()) {
408
- // Economy mode is on and failed to get the last revision (presumably running with history turned off).
409
- // Use dummy revision string so that xref can be generated from the resource file directly.
410
- location = cfg. getRevisionLocation(DUMMY_REVISION );
411
- response. sendRedirect(location);
412
- return ;
413
- }
414
-
415
- xrefFile = cfg. findDataFile();
416
- }
417
424
425
+ File xrefFile = cfg. findDataFile();
418
426
if (xrefFile != null ) {
419
427
% >
420
428
<div id =" src" data-navigate-window-enabled =" <%= navigateWindowEnabled % >" >
0 commit comments