X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FSoneTemplatePage.java;h=3d4cb804103c7781a1a83aa08bcdd0b358d04446;hb=a474ae28d3820854e9a8d8ea5b9f3a44b06fa737;hp=9a8bd9b65969e871e46a87692d3eaaaf269d613a;hpb=0ac5c61faa54b62f29bf8c8e9903919315810c80;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 9a8bd9b..3d4cb80 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.Collection; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.sone.web.page.Page; import net.pterodactylus.sone.web.page.TemplatePage; import net.pterodactylus.util.template.Template; @@ -124,6 +125,21 @@ public class SoneTemplatePage extends TemplatePage { } /** + * Returns the currently logged in Sone. + * + * @param toadletContext + * The toadlet context + * @param create + * {@code true} to create a new session if no session exists, + * {@code false} to not create a new session + * @return The currently logged in Sone, or {@code null} if no Sone is + * currently logged in + */ + protected Sone getCurrentSone(ToadletContext toadletContext, boolean create) { + return webInterface.getCurrentSone(toadletContext, create); + } + + /** * Sets the currently logged in Sone. * * @param toadletContext @@ -171,8 +187,12 @@ public class SoneTemplatePage extends TemplatePage { @Override protected void processTemplate(Request request, Template template) throws RedirectException { super.processTemplate(request, template); - template.set("currentSone", getCurrentSone(request.getToadletContext())); + template.set("currentSone", getCurrentSone(request.getToadletContext(), false)); template.set("request", request); + template.set("currentVersion", SonePlugin.VERSION); + template.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion()); + template.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); + template.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate()); } /** @@ -180,7 +200,7 @@ public class SoneTemplatePage extends TemplatePage { */ @Override protected String getRedirectTarget(Page.Request request) { - if (requiresLogin() && (getCurrentSone(request.getToadletContext()) == null)) { + if (requiresLogin() && (getCurrentSone(request.getToadletContext(), false) == null)) { return "login.html"; } return null; @@ -192,7 +212,7 @@ public class SoneTemplatePage extends TemplatePage { @Override public boolean isEnabled(ToadletContext toadletContext) { if (requiresLogin()) { - return getCurrentSone(toadletContext) != null; + return getCurrentSone(toadletContext, false) != null; } return true; }