0
|
1 package nabble.view.web.template;
|
|
2
|
|
3 import nabble.model.Node;
|
|
4 import nabble.model.Site;
|
|
5 import nabble.naml.compiler.Command;
|
|
6 import nabble.naml.compiler.CommandSpec;
|
|
7 import nabble.naml.compiler.IPrintWriter;
|
|
8 import nabble.naml.compiler.Interpreter;
|
|
9 import nabble.naml.compiler.Namespace;
|
|
10 import nabble.naml.compiler.TemplateRuntimeException;
|
|
11 import nabble.view.lib.Cache;
|
|
12 import nabble.view.lib.Jtp;
|
|
13
|
|
14 import javax.servlet.http.HttpServletRequest;
|
|
15 import java.util.LinkedHashSet;
|
|
16 import java.util.Set;
|
|
17
|
|
18
|
|
19 @Namespace (
|
|
20 name = "cache",
|
|
21 global = false
|
|
22 )
|
|
23 public final class CacheNamespace {
|
|
24 static final class DontCache extends TemplateRuntimeException {}
|
|
25
|
|
26 final Set<String> events = new LinkedHashSet<String>();
|
|
27 private final Site site;
|
|
28
|
|
29 CacheNamespace() {
|
|
30 this.site = NabbleNamespace.current().site();
|
|
31 events.add( Cache.siteChangeEvent(site) );
|
|
32 }
|
|
33
|
|
34 public static final CommandSpec descendant_changes = CommandSpec.NO_OUTPUT()
|
|
35 .dotParameter("node")
|
|
36 .build()
|
|
37 ;
|
|
38
|
|
39 @Command public void descendant_changes(IPrintWriter out,Interpreter interp) {
|
|
40 Node node = site.getNode(interp.getArgAsLong("node"));
|
|
41 if (node != null)
|
|
42 events.add( Cache.descendantChangeEvent(node) );
|
|
43 }
|
|
44
|
|
45 public static final CommandSpec node_changes = CommandSpec.NO_OUTPUT()
|
|
46 .dotParameter("node")
|
|
47 .build()
|
|
48 ;
|
|
49
|
|
50 @Command public void node_changes(IPrintWriter out,Interpreter interp) {
|
|
51 Node node = site.getNode(interp.getArgAsLong("node"));
|
|
52 if (node != null)
|
|
53 events.add( Cache.nodeChangeEvent(node) );
|
|
54 }
|
|
55
|
|
56 public static final CommandSpec bread_crumb_changes = CommandSpec.NO_OUTPUT()
|
|
57 .dotParameter("node")
|
|
58 .build()
|
|
59 ;
|
|
60
|
|
61 @Command public void bread_crumb_changes(IPrintWriter out,Interpreter interp) {
|
|
62 Node node = site.getNode(interp.getArgAsLong("node"));
|
|
63 if (node != null)
|
|
64 Jtp.addBreadCrumbEvents(events, node);
|
|
65 }
|
|
66
|
|
67 public static final CommandSpec new_user = CommandSpec.NO_OUTPUT;
|
|
68
|
|
69 @Command public void new_user(IPrintWriter out,Interpreter interp) {
|
|
70 events.add( Cache.newUserEvent(site) );
|
|
71 }
|
|
72
|
|
73 public static final CommandSpec user_group_change = CommandSpec.NO_OUTPUT;
|
|
74
|
|
75 @Command public void user_group_change(IPrintWriter out,Interpreter interp) {
|
|
76 events.add( Cache.groupChangeEvent(site) );
|
|
77 }
|
|
78
|
|
79 }
|