Skip to content

Commit 7f95e1a

Browse files
authored
Adding contributors section (#82)
1 parent fcf843b commit 7f95e1a

8 files changed

Lines changed: 98 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## v4.0.5
66

77
- [CDTS](https://github.com/wet-boew/cdts-sgdc/) v5.0.5 & [wet-boew](https://github.com/wet-boew/wet-boew) v4.0.89
8+
- Adding a Contributors pattern allowing users to highlight departments that have contributed to the content of the page. Please visit the sample pages for all the details.
89
- Adding an optional languagePrecedence property for Splash page allowing users to decide the order of official languages
910
- Updated static fallback files
1011

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/AbstractCoreBean.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ private enum Themes { GCWEB, GCINTRANET }
122122
private Date dateModified = null;
123123
private String screenIdentifier = "";
124124
private String versionIdentifier = "";
125+
private List<Link> contributors = null;
125126
private boolean showSearch = Boolean.parseBoolean(this.getResourceBundleString("cdn", "goc.webtemplate.showsearch"));
126127
private boolean showPreContent = Boolean.parseBoolean(this.getResourceBundleString("cdn", "goc.webtemplate.showprecontent"));
127128
private boolean showPostContent = Boolean.parseBoolean(this.getResourceBundleString("cdn", "goc.webtemplate.showpostcontent"));
@@ -1158,6 +1159,21 @@ public void setScreenIdentifier(String value) {
11581159
this.screenIdentifier = value;
11591160
}
11601161

1162+
/**
1163+
* Returns the list of contributors, null if no list is currently specified.
1164+
*/
1165+
public List<Link> getContributors() {
1166+
this.initializeOnce();
1167+
return this.contributors;
1168+
}
1169+
1170+
/**
1171+
* Sets the list of contributors to the specified value.
1172+
*/
1173+
public void setContributors(List<Link> value) {
1174+
this.contributors = value;
1175+
}
1176+
11611177
/**
11621178
* Returns the configuration object containing the various session timeout settings.
11631179
*
@@ -2096,7 +2112,8 @@ private IPreFooter buildPreFooter(boolean isTransactional, boolean isUnilingualE
20962112
this.showPostContent,
20972113
buildFeedback(this.getFeedbackLink()),
20982114
new ShareList(this.showSharePageLink, this.sharePageMediaSites),
2099-
JsonValueUtils.getNonEmptyString(this.getScreenIdentifier())
2115+
JsonValueUtils.getNonEmptyString(this.getScreenIdentifier()),
2116+
this.contributors
21002117
);
21012118
} else { //(isUnilingualError)
21022119
return new UnilingualErrorPreFooter(null, false);

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/jsonentities/PreFooter.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package goc.webtemplate.component.jsonentities;
22

33
import java.io.Serializable;
4+
import java.util.List;
45

56
import com.google.gson.annotations.JsonAdapter;
67

8+
import goc.webtemplate.Link;
9+
710
/**
811
* Objects of this class are meant to be serialized to a JSON object to be passed
912
* as parameter to the 'wet.builder.preFooter' JavaScript function in the template
@@ -24,20 +27,27 @@ public class PreFooter implements Serializable, IPreFooter {
2427
private ShareList showShare;
2528

2629
private String screenIdentifier;
30+
private List<Link> contributors;
2731

2832

2933
public PreFooter() {
3034
}
3135

3236
public PreFooter(String cdnEnv, String versionIdentifier, String dateModified, boolean showPostContent,
3337
Feedback showFeedback, ShareList showShare, String screenIdentifier) {
38+
this(cdnEnv, versionIdentifier, dateModified, showPostContent, showFeedback, showShare, screenIdentifier, null);
39+
}
40+
41+
public PreFooter(String cdnEnv, String versionIdentifier, String dateModified, boolean showPostContent,
42+
Feedback showFeedback, ShareList showShare, String screenIdentifier, List<Link> contributors) {
3443
this.cdnEnv = cdnEnv;
3544
this.versionIdentifier = versionIdentifier;
3645
this.dateModified = dateModified;
3746
this.showPostContent = showPostContent;
3847
this.showFeedback = showFeedback;
3948
this.showShare = showShare;
4049
this.screenIdentifier = screenIdentifier;
50+
this.contributors = contributors;
4151
}
4252

4353
public String getCdnEnv() {
@@ -95,4 +105,12 @@ public String getScreenIdentifier() {
95105
public void setScreenIdentifier(String screenIdentifier) {
96106
this.screenIdentifier = screenIdentifier;
97107
}
108+
109+
public List<Link> getContributors() {
110+
return contributors;
111+
}
112+
113+
public void setContributors(List<Link> contributors) {
114+
this.contributors = contributors;
115+
}
98116
}

gocwebtemplate-core/gocwebtemplate-core-base/src/test/java/goc/webtemplate/component/abstractcorebeantest/RenderPreFooterTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.jupiter.api.Test;
88
import goc.webtemplate.Constants;
99
import goc.webtemplate.FeedbackLink;
10+
import goc.webtemplate.Link;
1011

1112
/**
1213
* This contains tests for RenderSetup in relation with the preFooter attributes,
@@ -49,4 +50,18 @@ public void testRenderFeedback() {
4950
assertTrue(sut.getRenderSetup().contains("\"showFeedback\":{\"enabled\":true,\"href\":\"http://www.google.ca\",\"text\":\"Contact\",\"theme\":\"Theme\",\"section\":\"Section\"}"),
5051
"PreFooter rendering: Not rendered as expected. (" + sut.getRenderSetup() + ")");
5152
}
53+
54+
@Test
55+
public void testRenderContributors() {
56+
AbstractCoreBeanImpl sut = new AbstractCoreBeanImpl();
57+
58+
List<Link> contributors = new ArrayList<Link>();
59+
Link link = new Link("https://esdc.prv", "ESDC");
60+
contributors.add(link);
61+
62+
sut.setContributors(contributors);
63+
64+
assertTrue(sut.getRenderSetup().contains("\"contributors\":[{\"href\":\"https://esdc.prv\",\"text\":\"ESDC\"}]"),
65+
"PreFooter rendering: Not rendered as expected. (" + sut.getRenderSetup() + ")");
66+
}
5267
}

gocwebtemplate-sample-jsp/src/main/java/goc/webtemplate/jsp/samplebeans/FeedbackAndShareThisPageSampleBean.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import goc.webtemplate.Constants;
77
import goc.webtemplate.FeedbackLink;
8+
import goc.webtemplate.Link;
89
import goc.webtemplate.component.jsp.DefaultTemplateCoreBean;
910

1011
public class FeedbackAndShareThisPageSampleBean extends DefaultTemplateCoreBean {
@@ -26,10 +27,15 @@ public void onWebTemplateInitialize() {
2627
feedbackLink.setTheme("Theme");
2728
feedbackLink.setSection("Section");
2829

30+
List<Link> contributors = new ArrayList<Link>();
31+
Link link = new Link("https://esdc.prv", "ESDC");
32+
contributors.add(link);
33+
2934
this.setFeedbackLink(feedbackLink);
3035
this.setShowSharePageLink(true);
3136
this.getSharePageMediaSites().add(Constants.SocialMediaSites.blogger);
3237
this.getSharePageMediaSites().add(Constants.SocialMediaSites.facebook);
3338
this.getSharePageMediaSites().add(Constants.SocialMediaSites.twitter);
39+
this.setContributors(contributors);
3440
}
3541
}

gocwebtemplate-sample-jsp/src/main/webapp/samplecontents/feedbackandsharethispagesamplecontent.jsp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,21 @@ public void onWebTemplateInitialize() {
8585
}
8686
</pre>
8787
</div>
88+
<h2>Contributors</h2>
89+
<p>The contributors pattern is a way for the users to pattern to highlight institutions/organizations that have contributed to the content on a webpage.</p>
90+
<p>Set programmatically via the <code class="wb-prettify">setContributors</code> method in your custom bean class.</p>
91+
<div class="wb-prettify all-pre lang-vb linenums">
92+
<pre>
93+
@Override
94+
public void onWebTemplateInitialize() {
95+
//...
96+
List&lt;Link&gt; contributors = new ArrayList&lt;Link&gt;();
97+
Link link = new Link("https://esdc.prv", "ESDC");
98+
contributors.add(link);
99+
100+
this.setContributors(contributors);
101+
//...
102+
}
103+
</pre>
104+
</div>
88105
<%@ include file="_sampleslist.jsp" %>

gocwebtemplate-sample-spring/src/main/java/goc/webtemplate/spring/samplebeans/FeedbackAndShareThisPageSampleBean.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import goc.webtemplate.Constants;
99
import goc.webtemplate.FeedbackLink;
10+
import goc.webtemplate.Link;
1011
import goc.webtemplate.component.spring.DefaultTemplateCoreBean;
1112

1213
@Component(value = "feedbackandsharethispagesamplebean")
@@ -29,10 +30,15 @@ public void onWebTemplateInitialize() {
2930
feedbackLink.setTheme("Theme");
3031
feedbackLink.setSection("Section");
3132

33+
List<Link> contributors = new ArrayList<Link>();
34+
Link link = new Link("https://esdc.prv", "ESDC");
35+
contributors.add(link);
36+
3237
this.setFeedbackLink(feedbackLink);
3338
this.setShowSharePageLink(true);
3439
this.getSharePageMediaSites().add(Constants.SocialMediaSites.blogger);
3540
this.getSharePageMediaSites().add(Constants.SocialMediaSites.facebook);
3641
this.getSharePageMediaSites().add(Constants.SocialMediaSites.twitter);
42+
this.setContributors(contributors);
3743
}
3844
}

gocwebtemplate-sample-spring/src/main/resources/samples/FeedbackAndShareThisPageSample.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ <h2>Share This Page Link</h2>
8888
}
8989
</pre>
9090
</div>
91+
<h2>Contributors</h2>
92+
<p>The contributors pattern is a way for the users to pattern to highlight institutions/organizations that have contributed to the content on a webpage.</p>
93+
<p>Set programmatically via the <code class="wb-prettify">setContributors</code> method in your custom bean class.</p>
94+
<div class="wb-prettify all-pre lang-vb linenums">
95+
<pre>
96+
@Override
97+
public void onWebTemplateInitialize() {
98+
//...
99+
List&lt;Link&gt; contributors = new ArrayList&lt;Link&gt;();
100+
Link link = new Link("https://esdc.prv", "ESDC");
101+
contributors.add(link);
102+
103+
this.setContributors(contributors);
104+
//...
105+
}
106+
</pre>
107+
</div>
91108

92109
<div th:replace="_samplelist :: samplelist"></div>
93110
</section>

0 commit comments

Comments
 (0)