X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FSoneAccessor.java;h=06922fc8678a40066e251b24abf3d602997eab4b;hb=5473139d890c40c85712f59ba534583961c2772e;hp=4bb78af9c9715eea7691082ef54b613c92e2db49;hpb=1e9a08c2b73b16dc178437eb8c8025aaa083fcca;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java index 4bb78af..06922fc 100644 --- a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - SoneAccessor.java - Copyright © 2010–2015 David Roden + * Sone - SoneAccessor.java - Copyright © 2010–2020 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,10 +17,8 @@ package net.pterodactylus.sone.template; -import static com.google.common.collect.FluentIterable.from; -import static java.util.Arrays.asList; import static java.util.logging.Logger.getLogger; -import static net.pterodactylus.sone.data.Album.FLATTENER; +import static java.util.stream.Collectors.toList; import static net.pterodactylus.sone.data.Album.IMAGES; import java.util.logging.Level; @@ -30,10 +28,10 @@ import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.Sone.SoneStatus; +import net.pterodactylus.sone.data.SoneKt; import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.sone.freenet.wot.Trust; -import net.pterodactylus.sone.web.WebInterface; -import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage; +import net.pterodactylus.sone.text.TimeTextConverter; import net.pterodactylus.util.template.Accessor; import net.pterodactylus.util.template.ReflectionAccessor; import net.pterodactylus.util.template.TemplateContext; @@ -52,8 +50,6 @@ import net.pterodactylus.util.template.TemplateContext; *
Will return {@code true} if the sone in question is the currently logged * in Sone.
* - * - * @author David ‘Bombe’ Roden */ public class SoneAccessor extends ReflectionAccessor { @@ -62,6 +58,7 @@ public class SoneAccessor extends ReflectionAccessor { /** The core. */ private final Core core; + private final TimeTextConverter timeTextConverter; /** * Creates a new Sone accessor. @@ -69,8 +66,9 @@ public class SoneAccessor extends ReflectionAccessor { * @param core * The Sone core */ - public SoneAccessor(Core core) { + public SoneAccessor(Core core, TimeTextConverter timeTextConverter) { this.core = core; + this.timeTextConverter = timeTextConverter; } /** @@ -104,7 +102,7 @@ public class SoneAccessor extends ReflectionAccessor { } else if (member.equals("locked")) { return core.isLocked(sone); } else if (member.equals("lastUpdatedText")) { - return GetTimesAjaxPage.getTime((WebInterface) templateContext.get("webInterface"), sone.getTime()); + return timeTextConverter.getTimeText(sone.getTime()).getL10nText(); } else if (member.equals("trust")) { Sone currentSone = (Sone) templateContext.get("currentSone"); if (currentSone == null) { @@ -117,7 +115,7 @@ public class SoneAccessor extends ReflectionAccessor { } return trust; } else if (member.equals("allImages")) { - return from(asList(sone.getRootAlbum())).transformAndConcat(FLATTENER).transformAndConcat(IMAGES); + return SoneKt.getAllAlbums(sone).stream().flatMap(a -> IMAGES.apply(a).stream()).collect(toList()); } else if (member.equals("albums")) { return sone.getRootAlbum().getAlbums(); }