From: David ‘Bombe’ Roden Date: Fri, 11 Nov 2016 19:20:31 +0000 (+0100) Subject: Show linked images under posts and replies X-Git-Tag: 0.9.7^2~443 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d8bf8d6a89ce08693868fa7fac5d18d6d31256ce;p=Sone.git Show linked images under posts and replies --- diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 45b8307..046a377 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -40,6 +40,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import net.pterodactylus.sone.core.Core; +import net.pterodactylus.sone.core.ImageLoader; import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent; import net.pterodactylus.sone.core.event.ImageInsertFailedEvent; import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent; @@ -84,6 +85,7 @@ import net.pterodactylus.sone.template.IdentityAccessor; import net.pterodactylus.sone.template.ImageAccessor; import net.pterodactylus.sone.template.ImageLinkFilter; import net.pterodactylus.sone.template.JavascriptFilter; +import net.pterodactylus.sone.template.LinkedImagesFilter; import net.pterodactylus.sone.template.ParserFilter; import net.pterodactylus.sone.template.PostAccessor; import net.pterodactylus.sone.template.ProfileAccessor; @@ -256,7 +258,7 @@ public class WebInterface { * The Sone plugin */ @Inject - public WebInterface(SonePlugin sonePlugin, Loaders loaders, ListNotificationFilter listNotificationFilter, PostVisibilityFilter postVisibilityFilter, ReplyVisibilityFilter replyVisibilityFilter) { + public WebInterface(SonePlugin sonePlugin, Loaders loaders, ListNotificationFilter listNotificationFilter, PostVisibilityFilter postVisibilityFilter, ReplyVisibilityFilter replyVisibilityFilter, ImageLoader imageLoader) { this.sonePlugin = sonePlugin; this.loaders = loaders; this.listNotificationFilter = listNotificationFilter; @@ -291,6 +293,7 @@ public class WebInterface { templateContextFactory.addFilter("parse", parserFilter = new ParserFilter(getCore(), soneTextParser)); templateContextFactory.addFilter("shorten", shortenFilter = new ShortenFilter()); templateContextFactory.addFilter("render", renderFilter = new RenderFilter(getCore(), templateContextFactory)); + templateContextFactory.addFilter("linked-images", new LinkedImagesFilter(imageLoader)); templateContextFactory.addFilter("reparse", new ReparseFilter()); templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate")); templateContextFactory.addFilter("format", new FormatFilter()); diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css index 1767090..8e008c7 100644 --- a/src/main/resources/static/css/sone.css +++ b/src/main/resources/static/css/sone.css @@ -440,6 +440,21 @@ textarea { color: green; } +#sone .post .linked-images { + margin-top: 1ex; +} + +#sone .post .linked-image { + display: inline-block; + border: solid 1px black; + width: 160px; + height: 120px; + background-size: cover; + background-position: center; + margin-right: 1ex; + margin-bottom: 1ex; +} + #sone .post .replies { clear: both; padding-top: 0.2ex; @@ -496,6 +511,21 @@ textarea { font-size: inherit; } +#sone .post .reply .linked-images { + margin-top: 1ex; +} + +#sone .post .reply .linked-image { + display: inline-block; + border: solid 1px black; + width: 120px; + height: 90px; + background-size: cover; + background-position: center; + margin-right: 1ex; + margin-bottom: 1ex; +} + #sone .post .show-reply-form { display: inline; } diff --git a/src/main/resources/templates/include/viewPost.html b/src/main/resources/templates/include/viewPost.html index 7cba220..ac149f8 100644 --- a/src/main/resources/templates/include/viewPost.html +++ b/src/main/resources/templates/include/viewPost.html @@ -35,6 +35,18 @@
<% shortText>
<%if !shortText|match value=renderedText><%if !raw><%= View.Post.ShowMore|l10n|html><%/if><%/if> <%if !shortText|match value=renderedText><%if !raw><%/if><%/if> + <% parsedText|linked-images|store key==linkedImages> + <% foreach linkedImages linkedImage> + <% first> +
+ <%/first> + + + + <% last> +
+ <%/last> + <%/foreach>
diff --git a/src/main/resources/templates/include/viewReply.html b/src/main/resources/templates/include/viewReply.html index 1ef8f13..cd56e32 100644 --- a/src/main/resources/templates/include/viewReply.html +++ b/src/main/resources/templates/include/viewReply.html @@ -23,6 +23,18 @@
<% shortText>
<%if !shortText|match value=renderedText><%if !raw><%= View.Post.ShowMore|l10n|html><%/if><%/if> <%if !shortText|match value=renderedText><%if !raw><%/if><%/if> + <% parsedText|linked-images|store key==linkedImages> + <% foreach linkedImages linkedImage> + <% first> +
+ <%/first> + + + + <% last> +
+ <%/last> + <%/foreach>
<% reply.time|date format=="MMM d, yyyy, HH:mm:ss">