/** The Sone text parser. */
private final SoneTextParser soneTextParser;
+ /** The parser filter. */
+ private final ParserFilter parserFilter;
+
/** The “new Sone” notification. */
private final ListNotification<Sone> newSoneNotification;
templateContextFactory.addFilter("match", new MatchFilter());
templateContextFactory.addFilter("css", new CssClassNameFilter());
templateContextFactory.addFilter("js", new JavascriptFilter());
- templateContextFactory.addFilter("parse", new ParserFilter(getCore(), templateContextFactory, soneTextParser));
+ templateContextFactory.addFilter("parse", parserFilter = new ParserFilter(getCore(), templateContextFactory, soneTextParser));
templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate"));
templateContextFactory.addFilter("format", new FormatFilter());
templateContextFactory.addFilter("sort", new CollectionSortFilter());
pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumAjaxPage(this)));
- pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImageAjaxPage(this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImageAjaxPage(this, parserFilter)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustAjaxPage(this)));
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.
*/
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;
}
//
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<String, String>().put("sone", image.getSone().getId()).get()));
}
}
ajaxGet("editImage.ajax", { "formPassword": getFormPassword(), "image": imageId, "title": title, "description": description }, function(data) {
if (data && data.success) {
getImage(data.imageId).find(".image-title").text(data.title);
- getImage(data.imageId).find(".image-description").text(data.description);
+ getImage(data.imageId).find(".image-description").html(data.parsedDescription);
getImage(data.imageId).find(":input[name='title']").attr("defaultValue", title);
- getImage(data.imageId).find(":input[name='description']").attr("defaultValue", description);
+ getImage(data.imageId).find(":input[name='description']").attr("defaultValue", data.description);
cancelImageEditing();
}
});
<%/foreach>
</div>
- <p id="description"><% album.description|html></p>
+ <p id="description"><% album.description|parse sone=album.sone></p>
<%if album.sone.local>
<div class="show-edit-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
</div>
<div class="show-data">
<div class="image-title"><% image.title|html></div>
- <div class="image-description"><% image.description|html></div>
+ <div class="image-description"><% image.description|parse sone=image.sone></div>
</div>
<%if album.sone.local>
<form class="edit-image" action="editImage.html" method="post">
</div>
<div class="show-data">
<div class="album-title"><% album.title|html> (<%= View.Sone.Stats.Images|l10n 0=album.images.size>)</div>
- <div class="album-description"><% album.description|html></div>
+ <div class="album-description"><% album.description|parse sone=album.sone></div>
</div>
<%if album.sone.local>
<form class="edit-album" action="editAlbum.html" method="post">