package net.pterodactylus.sone.template;
+import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.core.Core.SoneStatus;
import net.pterodactylus.sone.data.Profile;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.template.Accessor;
*/
public class SoneAccessor extends ReflectionAccessor {
+ /** The core. */
+ private final Core core;
+
+ /**
+ * Creates a new Sone accessor.
+ *
+ * @param core
+ * The Sone core
+ */
+ public SoneAccessor(Core core) {
+ this.core = core;
+ }
+
/**
* {@inheritDoc}
*/
return currentSone.isSoneBlocked(sone.getId());
} else if (member.equals("modified")) {
return sone.getModificationCounter() > 0;
+ } else if (member.equals("status")) {
+ return core.getSoneStatus(sone).toString();
+ } else if (member.equals("idle")) {
+ return core.getSoneStatus(sone) == SoneStatus.idle;
+ } else if (member.equals("inserting")) {
+ return core.getSoneStatus(sone) == SoneStatus.inserting;
+ } else if (member.equals("downloading")) {
+ return core.getSoneStatus(sone) == SoneStatus.downloading;
}
return super.get(dataProvider, object, member);
}
private void registerToadlets() {
DefaultTemplateFactory templateFactory = new DefaultTemplateFactory();
templateFactory.addAccessor(Object.class, new ReflectionAccessor());
- templateFactory.addAccessor(Sone.class, new SoneAccessor());
+ templateFactory.addAccessor(Sone.class, new SoneAccessor(core()));
templateFactory.addAccessor(Post.class, new PostAccessor(core()));
templateFactory.addFilter("date", new DateFilter());
templateFactory.addFilter("l10n", new L10nFilter(l10n()));