From b90831223c33e2284b409f9745151363e61f16aa Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 21 Jun 2011 12:21:41 +0200 Subject: [PATCH] Store the core in all template contexts. --- src/main/java/net/pterodactylus/sone/core/SoneInserter.java | 1 + src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java | 1 + .../java/net/pterodactylus/sone/web/ajax/GetNotificationAjaxPage.java | 1 + src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java | 1 + src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java | 1 + 5 files changed, 5 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index cc5f689..aa2062c 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -347,6 +347,7 @@ public class SoneInserter extends AbstractService { } TemplateContext templateContext = templateContextFactory.createTemplateContext(); + templateContext.set("core", core); templateContext.set("currentSone", soneProperties); templateContext.set("currentEdition", core.getUpdateChecker().getLatestEdition()); templateContext.set("version", SonePlugin.VERSION); diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index a0174a9..b7e36f4 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -250,6 +250,7 @@ public class SoneTemplatePage extends FreenetTemplatePage { protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); Sone currentSone = getCurrentSone(request.getToadletContext(), false); + templateContext.set("core", webInterface.getCore()); templateContext.set("currentSone", currentSone); templateContext.set("localSones", webInterface.getCore().getLocalSones()); templateContext.set("request", request); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationAjaxPage.java index 1406c3a..03cecee 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationAjaxPage.java @@ -115,6 +115,7 @@ public class GetNotificationAjaxPage extends JsonPage { try { if (notification instanceof TemplateNotification) { TemplateContext templateContext = webInterface.getTemplateContextFactory().createTemplateContext().mergeContext(((TemplateNotification) notification).getTemplateContext()); + templateContext.set("core", webInterface.getCore()); templateContext.set("currentSone", webInterface.getCurrentSone(request.getToadletContext(), false)); templateContext.set("localSones", webInterface.getCore().getLocalSones()); templateContext.set("request", request); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java index f46ec6b..f56c5b7 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java @@ -97,6 +97,7 @@ public class GetPostAjaxPage extends JsonPage { jsonPost.put("time", post.getTime()); StringWriter stringWriter = new StringWriter(); TemplateContext templateContext = webInterface.getTemplateContextFactory().createTemplateContext(); + templateContext.set("core", webInterface.getCore()); templateContext.set("request", request); templateContext.set("post", post); templateContext.set("currentSone", currentSone); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java index 24bbbe2..6cc7d47 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java @@ -99,6 +99,7 @@ public class GetReplyAjaxPage extends JsonPage { jsonReply.put("time", reply.getTime()); StringWriter stringWriter = new StringWriter(); TemplateContext templateContext = webInterface.getTemplateContextFactory().createTemplateContext(); + templateContext.set("core", webInterface.getCore()); templateContext.set("request", request); templateContext.set("reply", reply); templateContext.set("currentSone", currentSone); -- 2.7.4