Skip to content

Commit 21f7c02

Browse files
authored
Add contributors section - v2 (#90)
* Adding contributors section - v2 * Fixing test
1 parent 627ca0b commit 21f7c02

7 files changed

Lines changed: 97 additions & 1 deletion

File tree

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
@@ -119,6 +119,7 @@ private enum Themes { GCWEB, GCINTRANET }
119119
private Date dateModified = null;
120120
private String screenIdentifier = "";
121121
private String versionIdentifier = "";
122+
private List<Link> contributors = null;
122123
private boolean showSearch = Boolean.parseBoolean(this.getResourceBundleString("cdn", "goc.webtemplate.showsearch"));
123124
private boolean showPreContent = Boolean.parseBoolean(this.getResourceBundleString("cdn", "goc.webtemplate.showprecontent"));
124125
private boolean showPostContent = Boolean.parseBoolean(this.getResourceBundleString("cdn", "goc.webtemplate.showpostcontent"));
@@ -1131,6 +1132,21 @@ public void setScreenIdentifier(String value) {
11311132
this.screenIdentifier = value;
11321133
}
11331134

1135+
/**
1136+
* Returns the list of contributors, null if no list is currently specified.
1137+
*/
1138+
public List<Link> getContributors() {
1139+
this.initializeOnce();
1140+
return this.contributors;
1141+
}
1142+
1143+
/**
1144+
* Sets the list of contributors to the specified value.
1145+
*/
1146+
public void setContributors(List<Link> value) {
1147+
this.contributors = value;
1148+
}
1149+
11341150
/**
11351151
* Returns the configuration object containing the various session timeout settings.
11361152
*
@@ -2112,7 +2128,8 @@ public String getRenderPreFooter() {
21122128
this.showPostContent,
21132129
buildFeedback(this.getFeedbackLink()),
21142130
new ShareList(this.showSharePageLink, this.sharePageMediaSites),
2115-
JsonValueUtils.getNonEmptyString(this.getScreenIdentifier())
2131+
JsonValueUtils.getNonEmptyString(this.getScreenIdentifier()),
2132+
this.contributors
21162133
));
21172134
}
21182135

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 {
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
public class RenderPreFooterTest {
1213
@Test
@@ -43,4 +44,18 @@ public void testRenderFeedback() {
4344
assertTrue(sut.getRenderPreFooter().contains("\"showFeedback\":{\"enabled\":true,\"href\":\"http://www.google.ca\",\"text\":\"Contact\",\"theme\":\"Theme\",\"section\":\"Section\"}"),
4445
"PreFooter rendering: Not rendered as expected. (" + sut.getRenderPreFooter() + ")");
4546
}
47+
48+
@Test
49+
public void testRenderContributors() {
50+
AbstractCoreBeanImpl sut = new AbstractCoreBeanImpl();
51+
52+
List<Link> contributors = new ArrayList<Link>();
53+
Link link = new Link("https://esdc.prv", "ESDC");
54+
contributors.add(link);
55+
56+
sut.setContributors(contributors);
57+
58+
assertTrue(sut.getRenderPreFooter().contains("\"contributors\":[{\"href\":\"https://esdc.prv\",\"text\":\"ESDC\"}]"),
59+
"PreFooter rendering: Not rendered as expected. (" + sut.getRenderPreFooter() + ")");
60+
}
4661
}

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)