Skip to content

Commit 3561ebc

Browse files
author
Vladimir Kotal
authored
Merge pull request #1342 from vladak/body_include
make index_body.html an include like {header,footer}_include
2 parents 0be0dfb + dc26274 commit 3561ebc

File tree

6 files changed

+38
-37
lines changed

6 files changed

+38
-37
lines changed

README.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,16 @@ web.xml of source.war file and change them (see note1) appropriately.
420420
* DATA_ROOT: absolute path of the directory where OpenGrok data
421421
files are stored
422422

423-
- Header file 'header_include' can be created under DATA_ROOT.
424-
The contents of this file file will be appended to the header of each
423+
- File 'header_include' can be created under DATA_ROOT.
424+
The contents of this file will be appended to the header of each
425425
web page after the OpenGrok logo element.
426-
- Footer file 'footer_include' can be created under DATA_ROOT.
427-
The contents of this file file will be appended to the footer of each
426+
- File 'footer_include' can be created under DATA_ROOT.
427+
The contents of this file will be appended to the footer of each
428428
web page after the information about last index update.
429-
- The body of the home page can be changed by updating index_body.html
430-
under the webapp directory.
429+
- The file 'body_include' can be created under DATA_ROOT.
430+
The contents of this file will be inserted above the footer of the web
431+
application's "Home" page.
432+
431433

432434
5.4.3 - Path Descriptions (optional)
433435
------------------------------------

build.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,6 @@ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
958958
<fileset dir="${web.src.dir}">
959959
<include name="**/*.jsp"/>
960960
<include name="**/*.jspf"/>
961-
<include name="**/index_body.html"/>
962961
</fileset>
963962
</copy>
964963
<jasper validateXml="false"

doc/EXAMPLE.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,15 @@ SRC_ROOT=/opengrok/source
3434
DATA_ROOT=/opengrok/data
3535
EXUB_CTAGS=/absolute/path/to/Exubrant/Ctags
3636

37-
The last thing we need to do is to configure the web application. To do so,
37+
The last thing we need to do is to configure the web application. To do so,
3838
please execute the following commands:
3939
$ mkdir /opengrok/web/source
4040
$ cd /opengrok/web/source
4141
$ unzip /path/to/opengrok-release/source.war
4242

4343
edit WEB-INF/web.xml and specify SRC_ROOT and DATA_ROOT.
4444

45-
You may also want to modify the file index_body.html before you re-create
46-
the war-file with the following commands:
45+
re-create the war-file with the following commands:
4746

4847
$ cd /opengrok/web/source
4948
$ zip -r /opengrok/web/source.war

src/org/opensolaris/opengrok/configuration/Configuration.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* CDDL HEADER END
1818
*/
1919

20-
/*
21-
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
20+
/*
21+
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opensolaris.opengrok.configuration;
2424

@@ -826,6 +826,7 @@ private static String getFileContent(File file) {
826826
*
827827
* @return an empty string if it could not be read successfully, the
828828
* contents of the file otherwise.
829+
* @see #FOOTER_INCLUDE_FILE
829830
*/
830831
public String getFooterIncludeFileContent() {
831832
if (footer == null) {
@@ -847,6 +848,7 @@ public String getFooterIncludeFileContent() {
847848
*
848849
* @return an empty string if it could not be read successfully, the
849850
* contents of the file otherwise.
851+
* @see #HEADER_INCLUDE_FILE
850852
*/
851853
public String getHeaderIncludeFileContent() {
852854
if (header == null) {
@@ -855,6 +857,27 @@ public String getHeaderIncludeFileContent() {
855857
return header;
856858
}
857859

860+
/**
861+
* The name of the file relative to the <var>DATA_ROOT</var>, which should
862+
* be included into the body of web app's "Home" page.
863+
*/
864+
public static final String BODY_INCLUDE_FILE = "body_include";
865+
866+
private transient String body = null;
867+
868+
/**
869+
* Get the contents of the body include file.
870+
* @return an empty string if it could not be read successfully, the
871+
* contents of the file otherwise.
872+
* @see Configuration#BODY_INCLUDE_FILE
873+
*/
874+
public String getBodyIncludeFileContent() {
875+
if (body == null) {
876+
body = getFileContent(new File(getDataRoot(), BODY_INCLUDE_FILE));
877+
}
878+
return body;
879+
}
880+
858881
/**
859882
* Get the eftar file, which contains definition tags.
860883
*

web/index.jsp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ include file="menu.jspf"
4747
4848
%></div>
4949
</div>
50-
<div id="results"><%@
51-
52-
include file="index_body.html"
53-
54-
%>
50+
<div id="results">
51+
<%= cfg.getEnv().getConfiguration().getBodyIncludeFileContent() %>
52+
</div>
5553
<%@
5654
5755
include file="repos.jspf"

web/index_body.html

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)