projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8ac7345
)
Parse album descriptions after editing
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 25 Jul 2015 16:09:56 +0000
(18:09 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 25 Jul 2015 16:09:56 +0000
(18:09 +0200)
src/main/java/net/pterodactylus/sone/web/WebInterface.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java
patch
|
blob
|
history
src/main/resources/templates/imageBrowser.html
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/web/WebInterface.java
b/src/main/java/net/pterodactylus/sone/web/WebInterface.java
index
c1fae80
..
974299d
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
+++ b/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
@@
-726,7
+726,7
@@
public class WebInterface {
pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
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 EditAlbumAjaxPage(this
, parserFilter, renderFilter
)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImageAjaxPage(this, parserFilter, renderFilter)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImageAjaxPage(this, parserFilter, renderFilter)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustAjaxPage(this)));
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java
index
570d027
..
6fe06bc
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java
@@
-17,12
+17,20
@@
package net.pterodactylus.sone.web.ajax;
package net.pterodactylus.sone.web.ajax;
+import java.util.Collections;
+
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Album;
+import net.pterodactylus.sone.data.Image;
+import net.pterodactylus.sone.template.ParserFilter;
+import net.pterodactylus.sone.template.RenderFilter;
+import net.pterodactylus.sone.text.Part;
import net.pterodactylus.sone.text.TextFilter;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.sone.text.TextFilter;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import net.pterodactylus.util.template.TemplateContext;
import com.google.common.base.Optional;
import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
/**
* Page that stores a user’s album modifications.
/**
* Page that stores a user’s album modifications.
@@
-31,14
+39,13
@@
import com.google.common.base.Optional;
*/
public class EditAlbumAjaxPage extends JsonPage {
*/
public class EditAlbumAjaxPage extends JsonPage {
- /**
- * Creates a new edit album AJAX page.
- *
- * @param webInterface
- * The Sone web interface
- */
- public EditAlbumAjaxPage(WebInterface webInterface) {
+ private final ParserFilter parserFilter;
+ private final RenderFilter renderFilter;
+
+ public EditAlbumAjaxPage(WebInterface webInterface, ParserFilter parserFilter, RenderFilter renderFilter) {
super("editAlbum.ajax", webInterface);
super("editAlbum.ajax", webInterface);
+ this.parserFilter = parserFilter;
+ this.renderFilter = renderFilter;
}
//
}
//
@@
-73,10
+80,16
@@
public class EditAlbumAjaxPage extends JsonPage {
try {
album.get().modify().setTitle(title).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)).update();
webInterface.getCore().touchConfiguration();
try {
album.get().modify().setTitle(title).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)).update();
webInterface.getCore().touchConfiguration();
- return createSuccessJsonObject().put("albumId", album.get().getId()).put("title", album.get().getTitle()).put("description",
album.get().getDescription(
));
+ return createSuccessJsonObject().put("albumId", album.get().getId()).put("title", album.get().getTitle()).put("description",
parseDescription(album.get()
));
} catch (IllegalStateException e) {
return createErrorJsonObject("invalid-album-title");
}
}
} catch (IllegalStateException e) {
return createErrorJsonObject("invalid-album-title");
}
}
+ private String parseDescription(Album album) {
+ Iterable<Part> parts = (Iterable<Part>) parserFilter.format(new TemplateContext(), album.getDescription(),
+ ImmutableMap.<String, Object>builder().put("sone", album.getSone()).build());
+ return (String) renderFilter.format(new TemplateContext(), parts, Collections.<String, Object>emptyMap());
+ }
+
}
}
diff --git
a/src/main/resources/templates/imageBrowser.html
b/src/main/resources/templates/imageBrowser.html
index
d399862
..
a237c7f
100644
(file)
--- a/
src/main/resources/templates/imageBrowser.html
+++ b/
src/main/resources/templates/imageBrowser.html
@@
-244,7
+244,7
@@
var albumDescriptionField = getAlbum(data.albumId).find(".album-description");
if (data.success) {
albumTitleField.text(data.title);
var albumDescriptionField = getAlbum(data.albumId).find(".album-description");
if (data.success) {
albumTitleField.text(data.title);
- albumDescriptionField.
text
(data.description);
+ albumDescriptionField.
html
(data.description);
getAlbum(data.albumId).find(":input[name='title']").attr("defaultValue", title);
getAlbum(data.albumId).find(":input[name='description']").attr("defaultValue", description);
} else {
getAlbum(data.albumId).find(":input[name='title']").attr("defaultValue", title);
getAlbum(data.albumId).find(":input[name='description']").attr("defaultValue", description);
} else {