projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
0ebf4a7
)
Parse descriptions of albums and images.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 12 Nov 2011 10:54:34 +0000
(11:54 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 12 Nov 2011 10:54:34 +0000
(11:54 +0100)
src/main/java/net/pterodactylus/sone/web/WebInterface.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java
patch
|
blob
|
history
src/main/resources/templates/imageBrowser.html
patch
|
blob
|
history
src/main/resources/templates/include/browseAlbums.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
7320ad5
..
4c41581
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
+++ b/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
@@
-170,6
+170,9
@@
public class WebInterface implements CoreListener {
/** The Sone text parser. */
private final SoneTextParser soneTextParser;
/** The Sone text parser. */
private final SoneTextParser soneTextParser;
+ /** The parser filter. */
+ private final ParserFilter parserFilter;
+
/** The “new Sone” notification. */
private final ListNotification<Sone> newSoneNotification;
/** The “new Sone” notification. */
private final ListNotification<Sone> newSoneNotification;
@@
-242,7
+245,7
@@
public class WebInterface implements CoreListener {
templateContextFactory.addFilter("match", new MatchFilter());
templateContextFactory.addFilter("css", new CssClassNameFilter());
templateContextFactory.addFilter("js", new JavascriptFilter());
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());
templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate"));
templateContextFactory.addFilter("format", new FormatFilter());
templateContextFactory.addFilter("sort", new CollectionSortFilter());
@@
-668,7
+671,7
@@
public class WebInterface implements CoreListener {
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 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)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustAjaxPage(this)));
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
..
3c4de8e
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java
@@
-18,10
+18,13
@@
package net.pterodactylus.sone.web.ajax;
import net.pterodactylus.sone.data.Image;
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.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.json.JsonObject;
+import net.pterodactylus.util.template.TemplateContext;
/**
* Page that stores a user’s image modifications.
/**
* Page that stores a user’s image modifications.
@@
-30,14
+33,20
@@
import net.pterodactylus.util.json.JsonObject;
*/
public class EditImageAjaxPage extends JsonPage {
*/
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
/**
* 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);
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();
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()))
;
}
}
}
}
diff --git
a/src/main/resources/templates/imageBrowser.html
b/src/main/resources/templates/imageBrowser.html
index
d97fc25
..
1da99ff
100644
(file)
--- a/
src/main/resources/templates/imageBrowser.html
+++ b/
src/main/resources/templates/imageBrowser.html
@@
-118,9
+118,9
@@
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);
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.d
escription);
+ getImage(data.imageId).find(".image-description").
html(data.parsedD
escription);
getImage(data.imageId).find(":input[name='title']").attr("defaultValue", title);
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", d
ata.d
escription);
cancelImageEditing();
}
});
cancelImageEditing();
}
});
@@
-322,7
+322,7
@@
<%/foreach>
</div>
<%/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>
<%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>
@@
-378,7
+378,7
@@
</div>
<div class="show-data">
<div class="image-title"><% image.title|html></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>
<%if album.sone.local>
<form class="edit-image" action="editImage.html" method="post">
diff --git
a/src/main/resources/templates/include/browseAlbums.html
b/src/main/resources/templates/include/browseAlbums.html
index
d925a3c
..
1fddebd
100644
(file)
--- a/
src/main/resources/templates/include/browseAlbums.html
+++ b/
src/main/resources/templates/include/browseAlbums.html
@@
-14,7
+14,7
@@
</div>
<div class="show-data">
<div class="album-title"><% album.title|html> (<%= View.Sone.Stats.Images|l10n 0=album.images.size>)</div>
</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">
</div>
<%if album.sone.local>
<form class="edit-album" action="editAlbum.html" method="post">