0
|
1 package nabble.modules.ad;
|
|
2
|
|
3 import nabble.model.Init;
|
|
4 import nabble.model.Site;
|
|
5 import nabble.naml.compiler.Command;
|
|
6 import nabble.naml.compiler.IPrintWriter;
|
|
7 import nabble.naml.compiler.Interpreter;
|
|
8 import nabble.naml.compiler.NamespaceExtension;
|
|
9 import nabble.view.web.template.NabbleNamespace;
|
|
10
|
|
11
|
|
12 @NamespaceExtension (
|
|
13 name = "ad",
|
|
14 target = NabbleNamespace.class
|
|
15 )
|
|
16 public final class BaseNamespaceExt {
|
|
17
|
|
18 private final Site site;
|
|
19
|
|
20 public BaseNamespaceExt(NabbleNamespace ns) {
|
|
21 this.site = ns.site();
|
|
22 }
|
|
23
|
|
24 @Command public void is_ad_safe(IPrintWriter out,Interpreter interp) {
|
|
25 Ad ad = Ad.of(site);
|
|
26 out.print( ad.isSafe() );
|
|
27 }
|
|
28
|
|
29 @Command public void current_credits(IPrintWriter out,Interpreter interp) {
|
|
30 Ad ad = Ad.of(site);
|
|
31 out.print( ad==null ? 0 : ad.getCredits() );
|
|
32 }
|
|
33
|
|
34 @Command public void ad_javascript(IPrintWriter out,Interpreter interp) {
|
|
35 out.print( Javascript.text(Ad.of(site)) );
|
|
36 }
|
|
37
|
|
38 @Command public void has_ads(IPrintWriter out,Interpreter interp) {
|
|
39 out.print(false);
|
|
40 }
|
|
41
|
|
42 @Command public void has_credits(IPrintWriter out,Interpreter interp) {
|
|
43 Ad ad = Ad.of(site);
|
|
44 out.print( ad.getCredits() > 0 );
|
|
45 }
|
|
46
|
|
47 @Command public void is_paid_site(IPrintWriter out,Interpreter interp) {
|
|
48 out.print(false);
|
|
49 }
|
|
50
|
|
51 @Command public void was_created_recently(IPrintWriter out,Interpreter interp) {
|
|
52 Ad ad = Ad.of(site);
|
|
53 out.print(ad.wasCreatedRecently());
|
|
54 }
|
|
55
|
|
56 public static String adbayesLink = Init.get("adbayesLink", null);
|
|
57
|
|
58 @Command public void adbayes_link(IPrintWriter out,Interpreter interp) {
|
|
59 out.print(adbayesLink);
|
|
60 }
|
|
61 }
|