package net.pterodactylus.wotns.ui.web;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.wotns.freenet.wot.IdentityManager;
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
-
- List<OwnIdentity> ownIdentities = new ArrayList<OwnIdentity>(webInterface.getWoTNSPlugin().getIdentityManager().getAllOwnIdentities());
- Collections.sort(ownIdentities, new Comparator<OwnIdentity>() {
-
- @Override
- public int compare(OwnIdentity leftOwnIdentity, OwnIdentity rightOwnIdentity) {
- return leftOwnIdentity.getNickname().compareTo(rightOwnIdentity.getNickname());
- }
- });
-
- templateContext.set("ownIdentities", ownIdentities);
+ templateContext.set("ownIdentities", identityManager.getAllOwnIdentities());
templateContext.set("formPassword", webInterface.getWoTNSPlugin().getToadletContainer().getFormPassword());
}
}
import java.util.ArrayList;
import java.util.List;
+import net.pterodactylus.util.template.CollectionSortFilter;
import net.pterodactylus.util.template.HtmlFilter;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContextFactory;
import net.pterodactylus.util.template.TemplateParser;
import net.pterodactylus.wotns.freenet.wot.Identity;
+import net.pterodactylus.wotns.main.IdentityComparator;
import net.pterodactylus.wotns.main.WoTNSPlugin;
import net.pterodactylus.wotns.template.IdentityAccessor;
import net.pterodactylus.wotns.web.PageToadlet;
templateContextFactory.addAccessor(Object.class, new ReflectionAccessor());
templateContextFactory.addAccessor(Identity.class, new IdentityAccessor());
templateContextFactory.addFilter("html", new HtmlFilter());
+ CollectionSortFilter sortFilter = new CollectionSortFilter();
+ sortFilter.addComparator(Identity.class, IdentityComparator.NAME);
+ templateContextFactory.addFilter("sort", sortFilter);
}
//