0
|
1
|
|
2 package nabble.view.lib;
|
|
3
|
|
4 import nabble.model.Node;
|
|
5
|
|
6 import javax.servlet.http.HttpServletRequest;
|
|
7
|
|
8
|
|
9 public final class EmbedUtils {
|
|
10 private EmbedUtils() {} // never
|
|
11
|
|
12 private static String url(HttpServletRequest request, Node node) {
|
|
13 return Jtp.getBaseUrl(request) + Jtp.path(node);
|
|
14 }
|
|
15
|
|
16 private static String getRawForumSnippet(HttpServletRequest request, Node app) {
|
|
17 return
|
|
18 "<a id=\"nabblelink\" href=\""
|
|
19 +(url(request,app))
|
|
20 +"\">"
|
|
21 +(app.getSubject())
|
|
22 +"</a>\r\n<script src=\""
|
|
23 +(Jtp.getBaseUrl(request))
|
|
24 +"/embed/f"
|
|
25 +(app.getId())
|
|
26 +"\"></script>"
|
|
27 ;
|
|
28 }
|
|
29
|
|
30 public static String getForumSnippet(HttpServletRequest request, Node app) {
|
|
31 return getRawForumSnippet(request,app).replace("<", "<").replace(">", ">");
|
|
32 }
|
|
33
|
|
34 public static String getTopicSnippet(HttpServletRequest request, Node rootPost) {
|
|
35 return
|
|
36 "<a id=\"nabblelink\" href=\""
|
|
37 +(url(request,rootPost))
|
|
38 +"\">"
|
|
39 +(rootPost.getSubject())
|
|
40 +"</a>\r\n<script src=\""
|
|
41 +(rootPost.getSite().getBaseUrl())
|
|
42 +"/embed/p"
|
|
43 +(rootPost.getId())
|
|
44 +"\"></script>"
|
|
45
|
|
46 .replace("<", "<").replace(">", ">");
|
|
47 }
|
|
48
|
|
49 }
|
|
50
|