From 8712e249976e4d57d58fe15df15ae83e59ddbfff Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sat, 22 Feb 2014 19:15:46 -0800 Subject: Adding Author and Feed Cookie. * Adding an Author indicator on the feed. * Adding showfeed cookie to enable/disable feed demo. * Hiding the feed on the introduction chapter. * Adding whitespace compression to all pages. --- .../grow/frontend/TrainingPageResource.java | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/com/p4square/grow/frontend/TrainingPageResource.java') diff --git a/src/com/p4square/grow/frontend/TrainingPageResource.java b/src/com/p4square/grow/frontend/TrainingPageResource.java index 7b36538..0c8f656 100644 --- a/src/com/p4square/grow/frontend/TrainingPageResource.java +++ b/src/com/p4square/grow/frontend/TrainingPageResource.java @@ -14,6 +14,7 @@ import java.util.Map; import freemarker.template.Template; +import org.restlet.data.CookieSetting; import org.restlet.data.Form; import org.restlet.data.MediaType; import org.restlet.data.Status; @@ -213,7 +214,27 @@ public class TrainingPageResource extends FreeMarkerPageResource { root.put("videos", videos); root.put("allowUserToSkip", allowUserToSkip); - boolean showfeed = getQueryValue("showfeed") != null; + // Optionally show the feed. + boolean showfeed = "true".equals(getRequest().getCookies().getFirstValue("showfeed")); + if (getQueryValue("showfeed") != null) { + CookieSetting cookie = new CookieSetting("showfeed", "true"); + cookie.setPath("/"); + if ("true".equals(getQueryValue("showfeed"))) { + showfeed = true; + getResponse().getCookieSettings().add(cookie); + } else { + showfeed = false; + cookie.setValue("false"); + cookie.setMaxAge(0); + getResponse().getCookieSettings().add(cookie); + } + } + + // Don't show the feed if the topic isn't allowed. + if (!FeedData.TOPICS.contains(mChapter)) { + showfeed = false; + } + root.put("showfeed", showfeed); if (showfeed) { root.put("feeddata", mFeedData); -- cgit v1.2.3