Mercurial Hosting > nabble
diff src/nabble/view/lib/EmbedUtils.jmp @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/nabble/view/lib/EmbedUtils.jmp Thu Mar 21 19:15:52 2019 -0600 @@ -0,0 +1,32 @@ +<% +package nabble.view.lib; + +import nabble.model.Node; + +import javax.servlet.http.HttpServletRequest; + + +public final class EmbedUtils { + private EmbedUtils() {} // never + + private static String url(HttpServletRequest request, Node node) { + return Jtp.getBaseUrl(request) + Jtp.path(node); + } + + private static String getRawForumSnippet(HttpServletRequest request, Node app) { + return %><a id="nabblelink" href="<%=url(request,app)%>"><%=app.getSubject()%></a> +<script src="<%=Jtp.getBaseUrl(request)%>/embed/f<%=app.getId()%>"></script><%; + } + + public static String getForumSnippet(HttpServletRequest request, Node app) { + return getRawForumSnippet(request,app).replace("<", "<").replace(">", ">"); + } + + public static String getTopicSnippet(HttpServletRequest request, Node rootPost) { + return %><a id="nabblelink" href="<%=url(request,rootPost)%>"><%=rootPost.getSubject()%></a> +<script src="<%=rootPost.getSite().getBaseUrl()%>/embed/p<%=rootPost.getId()%>"></script><% + .replace("<", "<").replace(">", ">"); + } + +} +%>