+ protected final void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
+ super.processTemplate(request, templateContext);
+ Sone currentSone = getCurrentSoneWithoutCreatingSession(request.getToadletContext());
+ templateContext.set("preferences", webInterface.getCore().getPreferences());
+ templateContext.set("currentSone", currentSone);
+ templateContext.set("localSones", webInterface.getCore().getLocalSones());
+ templateContext.set("request", request);
+ templateContext.set("currentVersion", SonePlugin.getPluginVersion());
+ templateContext.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion());
+ templateContext.set("latestEdition", webInterface.getCore().getUpdateChecker().getLatestEdition());
+ templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion());
+ templateContext.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate());
+ List<Notification> notifications = new ArrayList<Notification>(webInterface.getNotifications(currentSone));
+ Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
+ templateContext.set("notifications", notifications);
+ templateContext.set("notificationHash", notifications.hashCode());
+ handleRequest(request, templateContext);
+ }
+
+ protected void handleRequest(@Nonnull FreenetRequest request, @Nonnull TemplateContext templateContext) throws RedirectException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getRedirectTarget(FreenetRequest request) {
+ if (requiresLogin() && (getCurrentSoneWithoutCreatingSession(request.getToadletContext()) == null)) {
+ HTTPRequest httpRequest = request.getHttpRequest();
+ String originalUrl = httpRequest.getPath();
+ if (httpRequest.hasParameters()) {
+ StringBuilder requestParameters = new StringBuilder();
+ for (String parameterName : httpRequest.getParameterNames()) {
+ if (requestParameters.length() > 0) {
+ requestParameters.append("&");
+ }
+ String[] parameterValues = httpRequest.getMultipleParam(parameterName);
+ for (String parameterValue : parameterValues) {
+ requestParameters.append(urlEncode(parameterName)).append("=").append(urlEncode(parameterValue));
+ }
+ }
+ originalUrl += "?" + requestParameters.toString();
+ }
+ return "login.html?target=" + urlEncode(originalUrl);