Allow the ID of an image as input for the image link filter.
[Sone.git] / src / main / java / net / pterodactylus / sone / template / SoneAccessor.java
index 23b2227..bc72776 100644 (file)
@@ -25,6 +25,8 @@ import net.pterodactylus.sone.core.Core.SoneStatus;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.Trust;
+import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Accessor;
 import net.pterodactylus.util.template.ReflectionAccessor;
@@ -97,6 +99,8 @@ public class SoneAccessor extends ReflectionAccessor {
                        return core.isNewSone(sone.getId());
                } else if (member.equals("locked")) {
                        return core.isLocked(sone);
+               } else if (member.equals("lastUpdatedText")) {
+                       return GetTimesAjaxPage.getTime((WebInterface) templateContext.get("webInterface"), sone.getTime());
                } else if (member.equals("trust")) {
                        Sone currentSone = (Sone) templateContext.get("currentSone");
                        if (currentSone == null) {
@@ -108,6 +112,12 @@ public class SoneAccessor extends ReflectionAccessor {
                                return new Trust(null, null, null);
                        }
                        return trust;
+               } else if (member.equals("avatar")) {
+                       String avatarId = sone.getAvatar();
+                       if (avatarId == null) {
+                               return null;
+                       }
+                       return core.getImage(avatarId);
                }
                return super.get(templateContext, object, member);
        }