Skip to content

Instantly share code, notes, and snippets.

@joegaudet
Created December 3, 2011 19:23
Show Gist options
  • Save joegaudet/1427885 to your computer and use it in GitHub Desktop.
Save joegaudet/1427885 to your computer and use it in GitHub Desktop.
class GPlusController(val dispatcher:FlowDispatcher) extends FlowController {
// show
get("/posts/:id/googlePlus") {
val post = Post.find(params("id"))
val offering = post.getOffering()
val redirectUrl = FlowAuthentication.userFromRequest(request, response) match {
case Some(user) if (offering != None) => {
if (offering.get.userIsInOffering(Some(user))) {
"https://www.matygo.com/app/#threads/" + post.discussionThreadId
}
else "https://www.matygo.com/app"
}
case _ => "http://www.matygo.com"
}
val courseTitle = offering match {
case None => "a course"
case Some(offering) => offering.courseTitle
}
val content = "0; url=" + redirectUrl;
<html>
<head>
<meta http-equiv="Refresh" content={content} />
<title>Great Post</title>
</head>
<body>
<img src="https://s3.amazonaws.com/assets.matygo.com/matygologo.png" />
<p>From {courseTitle} <a href={redirectUrl}>on Matygo</a>.</p>
</body>
</html>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment