Insert a root album into all Sones to get rid of album manipulation in the Sone.
[Sone.git] / src / main / java / net / pterodactylus / sone / template / SoneAccessor.java
index 9d4bdc8..ab872d9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - SoneAccessor.java - Copyright © 2010–2012 David Roden
+ * Sone - SoneAccessor.java - Copyright © 2010–2013 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
 
 package net.pterodactylus.sone.template;
 
+import static com.google.common.collect.FluentIterable.from;
+import static java.util.Arrays.asList;
+import static net.pterodactylus.sone.data.Album.FLATTENER;
+import static net.pterodactylus.sone.data.Album.IMAGES;
+
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -111,6 +116,8 @@ public class SoneAccessor extends ReflectionAccessor {
                                return new Trust(null, null, null);
                        }
                        return trust;
+               } else if (member.equals("allImages")) {
+                       return from(asList(sone.getRootAlbum())).transformAndConcat(FLATTENER).transformAndConcat(IMAGES);
                }
                return super.get(templateContext, object, member);
        }