projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow filtering notifications without a current Sone.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
template
/
SoneAccessor.java
diff --git
a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
index
ef71a96
..
76fdcc1
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
@@
-25,10
+25,12
@@
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.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.logging.Logging;
import net.pterodactylus.util.template.Accessor;
-import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.ReflectionAccessor;
+import net.pterodactylus.util.template.TemplateContext;
/**
* {@link Accessor} for {@link Sone}s that adds a couple of properties to Sones.
/**
* {@link Accessor} for {@link Sone}s that adds a couple of properties to Sones.
@@
-39,7
+41,7
@@
import net.pterodactylus.util.template.ReflectionAccessor;
* <dt>friend</dt>
* <dd>Will return {@code true} if the sone in question is a friend of the
* currently logged in Sone (as determined by accessing the “currentSone”
* <dt>friend</dt>
* <dd>Will return {@code true} if the sone in question is a friend of the
* currently logged in Sone (as determined by accessing the “currentSone”
- * variable of the given {@link
DataProvider
}).</dd>
+ * variable of the given {@link
TemplateContext
}).</dd>
* <dt>current</dt>
* <dd>Will return {@code true} if the sone in question is the currently logged
* in Sone.</dd>
* <dt>current</dt>
* <dd>Will return {@code true} if the sone in question is the currently logged
* in Sone.</dd>
@@
-69,17
+71,17
@@
public class SoneAccessor extends ReflectionAccessor {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- public Object get(
DataProvider dataProvider
, Object object, String member) {
+ public Object get(
TemplateContext templateContext
, Object object, String member) {
Sone sone = (Sone) object;
if (member.equals("niceName")) {
return getNiceName(sone);
} else if (member.equals("local")) {
Sone sone = (Sone) object;
if (member.equals("niceName")) {
return getNiceName(sone);
} else if (member.equals("local")) {
- return
sone.getInsertUri() != null
;
+ return
core.isLocalSone(sone)
;
} else if (member.equals("friend")) {
} else if (member.equals("friend")) {
- Sone currentSone = (Sone)
dataProvider
.get("currentSone");
+ Sone currentSone = (Sone)
templateContext
.get("currentSone");
return (currentSone != null) && currentSone.hasFriend(sone.getId());
} else if (member.equals("current")) {
return (currentSone != null) && currentSone.hasFriend(sone.getId());
} else if (member.equals("current")) {
- Sone currentSone = (Sone)
dataProvider
.get("currentSone");
+ Sone currentSone = (Sone)
templateContext
.get("currentSone");
return (currentSone != null) && currentSone.equals(sone);
} else if (member.equals("modified")) {
return core.isModifiedSone(sone);
return (currentSone != null) && currentSone.equals(sone);
} else if (member.equals("modified")) {
return core.isModifiedSone(sone);
@@
-94,11
+96,13
@@
public class SoneAccessor extends ReflectionAccessor {
} else if (member.equals("downloading")) {
return core.getSoneStatus(sone) == SoneStatus.downloading;
} else if (member.equals("new")) {
} else if (member.equals("downloading")) {
return core.getSoneStatus(sone) == SoneStatus.downloading;
} else if (member.equals("new")) {
- return core.isNewSone(sone);
+ return core.isNewSone(sone
.getId()
);
} else if (member.equals("locked")) {
return core.isLocked(sone);
} else if (member.equals("locked")) {
return core.isLocked(sone);
+ } else if (member.equals("lastUpdatedText")) {
+ return GetTimesAjaxPage.getTime((WebInterface) templateContext.get("webInterface"), System.currentTimeMillis() - sone.getTime());
} else if (member.equals("trust")) {
} else if (member.equals("trust")) {
- Sone currentSone = (Sone)
dataProvider
.get("currentSone");
+ Sone currentSone = (Sone)
templateContext
.get("currentSone");
if (currentSone == null) {
return null;
}
if (currentSone == null) {
return null;
}
@@
-107,8
+111,9
@@
public class SoneAccessor extends ReflectionAccessor {
if (trust == null) {
return new Trust(null, null, null);
}
if (trust == null) {
return new Trust(null, null, null);
}
+ return trust;
}
}
- return super.get(
dataProvider
, object, member);
+ return super.get(
templateContext
, object, member);
}
//
}
//