X-Git-Url: https://git.pterodactylus.net/?p=WoTNS.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fwotns%2Fui%2Fweb%2FBasicPage.java;h=85ad8b1199e52cf23bac0a6f69db594bc5546245;hp=f8ba13187df7b5eb14726d7f48034a38f6a4f51a;hb=e17750852b6d02aeb6270f6a7e2619ced1f4f9b7;hpb=1e65f6a661aabd7342c2a5f1bac6b65625c5f607 diff --git a/src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java b/src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java index f8ba131..85ad8b1 100644 --- a/src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java +++ b/src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java @@ -17,8 +17,12 @@ package net.pterodactylus.wotns.ui.web; +import java.util.Arrays; +import java.util.Collection; + import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.web.Method; import net.pterodactylus.wotns.freenet.wot.IdentityManager; import net.pterodactylus.wotns.freenet.wot.OwnIdentity; import net.pterodactylus.wotns.web.FreenetRequest; @@ -32,25 +36,62 @@ import net.pterodactylus.wotns.web.FreenetTemplatePage; public class BasicPage extends FreenetTemplatePage { protected final WebInterface webInterface; + protected final IdentityManager identityManager; - public BasicPage(WebInterface webInterface, String path, Template template) { + private final String title; + + public BasicPage(WebInterface webInterface, String path, String title, Template template) { super(path, webInterface.getTemplateContextFactory(), template, "noPermission.html"); this.webInterface = webInterface; this.identityManager = webInterface.getWoTNSPlugin().getIdentityManager(); + this.title = title; } // // PROTECTED METHODS // + protected OwnIdentity getOwnIdentity(FreenetRequest request) { + if (request.getMethod() == Method.POST) { + String ownIdentityId = request.getHttpRequest().getPartAsStringFailsafe("ownIdentity", 43); + return identityManager.getOwnIdentity(ownIdentityId); + } else if (request.getMethod() == Method.GET) { + String ownIdentityId = request.getHttpRequest().getParam("ownIdentity"); + return identityManager.getOwnIdentity(ownIdentityId); + } + return null; + } + + // + // FREENETTEMPLATEPAGE METHODS + // + + /** + * {@inheritDoc} + */ + @Override + protected String getPageTitle(FreenetRequest request) { + return title; + } + + /** + * {@inheritDoc} + */ + @Override + protected Collection getStyleSheets() { + return Arrays.asList("css/main.css"); + } + /** * {@inheritDoc} */ @Override protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); + templateContext.set("request", request.getHttpRequest()); templateContext.set("ownIdentities", identityManager.getAllOwnIdentities()); templateContext.set("formPassword", webInterface.getWoTNSPlugin().getToadletContainer().getFormPassword()); } + }