X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FEditImageAjaxPage.java;h=9e04a302e890cd4ffe5982b5f4b811d5bd72bf76;hp=3bef432253e8bd819691c2f69864de175d374de9;hb=a47643aed43d118ca68044f95451bb5374cdb332;hpb=0ebf4a7e60e64c6f1ebfdae0ffe169988a687468 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java index 3bef432..9e04a30 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - EditImageAjaxPage.java - Copyright © 2011 David Roden + * Sone - EditImageAjaxPage.java - Copyright © 2011–2012 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,10 +18,13 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.data.Image; +import net.pterodactylus.sone.template.ParserFilter; import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; +import net.pterodactylus.util.collection.MapBuilder; import net.pterodactylus.util.json.JsonObject; +import net.pterodactylus.util.template.TemplateContext; /** * Page that stores a user’s image modifications. @@ -30,14 +33,20 @@ import net.pterodactylus.util.json.JsonObject; */ public class EditImageAjaxPage extends JsonPage { + /** Parser for image descriptions. */ + private final ParserFilter parserFilter; + /** * Creates a new edit image AJAX page. * * @param webInterface * The Sone web interface + * @param parserFilter + * The parser filter for image descriptions */ - public EditImageAjaxPage(WebInterface webInterface) { + public EditImageAjaxPage(WebInterface webInterface, ParserFilter parserFilter) { super("editImage.ajax", webInterface); + this.parserFilter = parserFilter; } // @@ -71,7 +80,7 @@ public class EditImageAjaxPage extends JsonPage { String description = request.getHttpRequest().getParam("description").trim(); image.setTitle(title).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)); webInterface.getCore().touchConfiguration(); - return createSuccessJsonObject().put("imageId", image.getId()).put("title", image.getTitle()).put("description", image.getDescription()); + return createSuccessJsonObject().put("imageId", image.getId()).put("title", image.getTitle()).put("description", image.getDescription()).put("parsedDescription", (String) parserFilter.format(new TemplateContext(), image.getDescription(), new MapBuilder().put("sone", image.getSone().getId()).get())); } }