migrated the syndie addressbook
This commit is contained in:
@ -44,6 +44,8 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
|
||||
public static final String PARAM_PROFILE_DESC = "profileDesc";
|
||||
public static final String PARAM_PROFILE_URL = "profileURL";
|
||||
public static final String PARAM_PROFILE_OTHER = "profileOther";
|
||||
|
||||
public static final String PARAM_ARCHIVE = "archiveLocation";
|
||||
|
||||
public static String getFilterByTagLink(String uri, ThreadNode node, User user, String tag, String author) {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
|
375
apps/syndie/java/src/net/i2p/syndie/web/AddressesServlet.java
Normal file
375
apps/syndie/java/src/net/i2p/syndie/web/AddressesServlet.java
Normal file
@ -0,0 +1,375 @@
|
||||
package net.i2p.syndie.web;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.client.naming.*;
|
||||
import net.i2p.data.*;
|
||||
import net.i2p.syndie.*;
|
||||
import net.i2p.syndie.data.*;
|
||||
import net.i2p.syndie.sml.*;
|
||||
|
||||
/**
|
||||
* Show the user's addressbook
|
||||
*
|
||||
*/
|
||||
public class AddressesServlet extends BaseServlet {
|
||||
public static final String PARAM_IS_PUBLIC = "addrPublic";
|
||||
public static final String PARAM_NAME = "addrName";
|
||||
public static final String PARAM_LOC = "addrLoc";
|
||||
public static final String PARAM_FAVORITE = "addrFavorite";
|
||||
public static final String PARAM_IGNORE = "addrIgnore";
|
||||
public static final String PARAM_NET = "addrNet";
|
||||
public static final String PARAM_PROTO = "addrProto";
|
||||
public static final String PARAM_SYNDICATE = "addrSyndicate";
|
||||
public static final String PARAM_ACTION = "action";
|
||||
|
||||
public static final String PROTO_BLOG = "syndieblog";
|
||||
public static final String PROTO_ARCHIVE = "syndiearchive";
|
||||
public static final String PROTO_I2PHEX = "i2phex";
|
||||
public static final String PROTO_EEPSITE = "eep";
|
||||
|
||||
public static final String NET_SYNDIE = "syndie";
|
||||
public static final String NET_I2P = "i2p";
|
||||
public static final String NET_IP = "ip";
|
||||
public static final String NET_FREENET = "freenet";
|
||||
public static final String NET_TOR = "tor";
|
||||
|
||||
public static final String ACTION_DELETE_BLOG = "Delete author";
|
||||
public static final String ACTION_UPDATE_BLOG = "Update author";
|
||||
public static final String ACTION_ADD_BLOG = "Add author";
|
||||
|
||||
public static final String ACTION_DELETE_ARCHIVE = "Delete archive";
|
||||
public static final String ACTION_UPDATE_ARCHIVE = "Update archive";
|
||||
public static final String ACTION_ADD_ARCHIVE = "Add archive";
|
||||
|
||||
public static final String ACTION_DELETE_PEER = "Delete peer";
|
||||
public static final String ACTION_UPDATE_PEER = "Update peer";
|
||||
public static final String ACTION_ADD_PEER = "Add peer";
|
||||
|
||||
public static final String ACTION_DELETE_EEPSITE = "Delete eepsite";
|
||||
public static final String ACTION_UPDATE_EEPSITE = "Update eepsite";
|
||||
public static final String ACTION_ADD_EEPSITE = "Add eepsite";
|
||||
|
||||
public static final String ACTION_DELETE_OTHER = "Delete address";
|
||||
public static final String ACTION_UPDATE_OTHER = "Update address";
|
||||
public static final String ACTION_ADD_OTHER = "Add other address";
|
||||
|
||||
protected void renderServletDetails(User user, HttpServletRequest req, PrintWriter out, ThreadIndex index,
|
||||
int threadOffset, BlogURI visibleEntry, Archive archive) throws IOException {
|
||||
if (!user.getAuthenticated()) {
|
||||
out.write("<tr><td colspan=\"3\">You must log in to view your addressbook</d></tr>\n");
|
||||
} else {
|
||||
PetNameDB db = user.getPetNameDB();
|
||||
String uri = req.getRequestURI();
|
||||
|
||||
PetName pn = buildNewName(req, PROTO_BLOG);
|
||||
renderBlogs(user, db, uri, pn, out);
|
||||
pn = buildNewName(req, PROTO_ARCHIVE);
|
||||
renderArchives(user, db, uri, pn, out);
|
||||
pn = buildNewName(req, PROTO_I2PHEX);
|
||||
renderI2Phex(user, db, uri, pn, out);
|
||||
pn = buildNewName(req, PROTO_EEPSITE);
|
||||
renderEepsites(user, db, uri, pn, out);
|
||||
pn = buildNewName(req);
|
||||
renderOther(user, db, uri, pn, out);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderBlogs(User user, PetNameDB db, String baseURI, PetName newName, PrintWriter out) throws IOException {
|
||||
TreeSet names = new TreeSet();
|
||||
for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
PetName pn = db.getByName(name);
|
||||
if (PROTO_BLOG.equals(pn.getProtocol()))
|
||||
names.add(name);
|
||||
}
|
||||
out.write("<tr><td colspan=\"3\"><b>Syndie authors</b></td></tr>\n");
|
||||
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
|
||||
PetName pn = db.getByName((String)iter.next());
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_PROTO + "\" value=\"" + PROTO_BLOG + "\" />");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_NET + "\" value=\"" + NET_SYNDIE + "\" />");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (pn.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Name: <input type=\"hidden\" name=\"" + PARAM_NAME + "\" value=\"" + pn.getName() + "\" />" + pn.getName() + " ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"3\" value=\"" + pn.getLocation() + "\" /> ");
|
||||
if (pn.isMember(FilteredThreadIndex.GROUP_FAVORITE))
|
||||
out.write("Favorite? <input type=\"checkbox\" name=\"" + PARAM_FAVORITE + "\" checked=\"true\" value=\"true\" /> ");
|
||||
else
|
||||
out.write("Favorite? <input type=\"checkbox\" name=\"" + PARAM_FAVORITE + "\" value=\"true\" /> ");
|
||||
|
||||
if (pn.isMember(FilteredThreadIndex.GROUP_IGNORE)) {
|
||||
out.write("Ignored? <input type=\"checkbox\" name=\"" + PARAM_IGNORE + "\" checked=\"true\" value=\"true\" /> ");
|
||||
} else {
|
||||
out.write("Ignored? <input type=\"checkbox\" name=\"" + PARAM_IGNORE + "\" value=\"true\" /> ");
|
||||
out.write("<a href=\"" + getControlTarget() + "?" + ThreadedHTMLRenderer.PARAM_AUTHOR + '='
|
||||
+ pn.getLocation() + "\" title=\"View threads by the given author\">View posts</a> ");
|
||||
}
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_DELETE_BLOG + "\" /> ");
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_UPDATE_BLOG + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
}
|
||||
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_PROTO + "\" value=\"" + PROTO_BLOG + "\" />");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_NET + "\" value=\"" + NET_SYNDIE + "\" />");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (newName.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Name: <input type=\"text\" name=\"" + PARAM_NAME + "\" size=\"10\" value=\"" + newName.getName() + "\" /> ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"3\" value=\"" + newName.getLocation() + "\" /> ");
|
||||
if (newName.isMember(FilteredThreadIndex.GROUP_FAVORITE))
|
||||
out.write("Favorite? <input type=\"checkbox\" name=\"" + PARAM_FAVORITE + "\" checked=\"true\" value=\"true\" /> ");
|
||||
else
|
||||
out.write("Favorite? <input type=\"checkbox\" name=\"" + PARAM_FAVORITE + "\" value=\"true\" /> ");
|
||||
|
||||
if (newName.isMember(FilteredThreadIndex.GROUP_IGNORE)) {
|
||||
out.write("Ignored? <input type=\"checkbox\" name=\"" + PARAM_IGNORE + "\" checked=\"true\" value=\"true\" /> ");
|
||||
} else {
|
||||
out.write("Ignored? <input type=\"checkbox\" name=\"" + PARAM_IGNORE + "\" value=\"true\" /> ");
|
||||
}
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_ADD_BLOG + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
|
||||
out.write("<tr><td colspan=\"3\"><hr /></td></tr>\n");
|
||||
}
|
||||
|
||||
private void renderArchives(User user, PetNameDB db, String baseURI, PetName newName, PrintWriter out) throws IOException {
|
||||
TreeSet names = new TreeSet();
|
||||
for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
PetName pn = db.getByName(name);
|
||||
if (PROTO_ARCHIVE.equals(pn.getProtocol()))
|
||||
names.add(name);
|
||||
}
|
||||
out.write("<tr><td colspan=\"3\"><b>Syndie archives</b></td></tr>\n");
|
||||
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
|
||||
PetName pn = db.getByName((String)iter.next());
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_PROTO + "\" value=\"" + PROTO_ARCHIVE + "\" />");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_NET + "\" value=\"" + NET_SYNDIE + "\" />");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (pn.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Name: <input type=\"hidden\" name=\"" + PARAM_NAME + "\" size=\"10\" value=\"" + pn.getName() + "\" />" + pn.getName() + " ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"20\" value=\"" + pn.getLocation() + "\" /> ");
|
||||
if (BlogManager.instance().syndicationScheduled(pn.getLocation()))
|
||||
out.write("Syndicate? <input type=\"checkbox\" name=\"" + PARAM_SYNDICATE + "\" checked=\"true\" value=\"true\" />");
|
||||
else
|
||||
out.write("Syndicate? <input type=\"checkbox\" name=\"" + PARAM_SYNDICATE + "\" value=\"true\" />");
|
||||
|
||||
out.write("<a href=\"" + getSyndicateLink(user, pn.getName())
|
||||
+ "\" title=\"Synchronize manually with the peer\">Sync manually</a> ");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_DELETE_ARCHIVE + "\" /> ");
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_UPDATE_ARCHIVE + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
}
|
||||
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_PROTO + "\" value=\"" + PROTO_ARCHIVE + "\" />");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_NET + "\" value=\"" + NET_SYNDIE + "\" />");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (newName.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Name: <input type=\"text\" name=\"" + PARAM_NAME + "\" size=\"10\" value=\"" + newName.getName() + "\" /> ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"20\" value=\"" + newName.getLocation() + "\" /> ");
|
||||
if (BlogManager.instance().syndicationScheduled(newName.getLocation()))
|
||||
out.write("Syndicate? <input type=\"checkbox\" name=\"" + PARAM_SYNDICATE + "\" checked=\"true\" value=\"true\" />");
|
||||
else
|
||||
out.write("Syndicate? <input type=\"checkbox\" name=\"" + PARAM_SYNDICATE + "\" value=\"true\" />");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_ADD_ARCHIVE + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
|
||||
out.write("<tr><td colspan=\"3\"><hr /></td></tr>\n");
|
||||
}
|
||||
|
||||
private void renderI2Phex(User user, PetNameDB db, String baseURI, PetName newName, PrintWriter out) throws IOException {
|
||||
TreeSet names = new TreeSet();
|
||||
for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
PetName pn = db.getByName(name);
|
||||
if (PROTO_I2PHEX.equals(pn.getProtocol()))
|
||||
names.add(name);
|
||||
}
|
||||
out.write("<tr><td colspan=\"3\"><b>I2Phex peers</b></td></tr>\n");
|
||||
|
||||
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
|
||||
PetName pn = db.getByName((String)iter.next());
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_PROTO + "\" value=\"" + PROTO_I2PHEX + "\" />");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_NET + "\" value=\"" + NET_I2P + "\" />");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (pn.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Name: <input type=\"hidden\" name=\"" + PARAM_NAME + "\" value=\"" + pn.getName() + "\" />" + pn.getName() + " ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"3\" value=\"" + pn.getLocation() + "\" /> ");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_DELETE_PEER + "\" /> ");
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_UPDATE_PEER + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
}
|
||||
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_PROTO + "\" value=\"" + PROTO_I2PHEX + "\" />");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_NET + "\" value=\"" + NET_I2P + "\" />");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (newName.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Name: <input type=\"text\" name=\"" + PARAM_NAME + "\" size=\"10\" value=\"" + newName.getName() + "\" /> ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"3\" value=\"" + newName.getLocation() + "\" /> ");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_ADD_PEER + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
|
||||
out.write("<tr><td colspan=\"3\"><hr /></td></tr>\n");
|
||||
}
|
||||
private void renderEepsites(User user, PetNameDB db, String baseURI, PetName newName, PrintWriter out) throws IOException {
|
||||
TreeSet names = new TreeSet();
|
||||
for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
PetName pn = db.getByName(name);
|
||||
if (PROTO_EEPSITE.equals(pn.getProtocol()))
|
||||
names.add(name);
|
||||
}
|
||||
out.write("<tr><td colspan=\"3\"><b>Eepsites</b></td></tr>\n");
|
||||
|
||||
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
|
||||
PetName pn = db.getByName((String)iter.next());
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_PROTO + "\" value=\"" + PROTO_EEPSITE + "\" />");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_NET + "\" value=\"" + NET_I2P + "\" />");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (pn.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Name: <input type=\"hidden\" name=\"" + PARAM_NAME + "\" value=\"" + pn.getName() + "\" />" + pn.getName() + " ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"3\" value=\"" + pn.getLocation() + "\" /> ");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_DELETE_EEPSITE + "\" /> ");
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_UPDATE_EEPSITE + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
}
|
||||
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_PROTO + "\" value=\"" + PROTO_EEPSITE + "\" />");
|
||||
out.write("<input type=\"hidden\" name=\"" + PARAM_NET + "\" value=\"" + NET_I2P + "\" />");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (newName.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Name: <input type=\"text\" name=\"" + PARAM_NAME + "\" size=\"10\" value=\"" + newName.getName() + "\" /> ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"3\" value=\"" + newName.getLocation() + "\" /> ");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_ADD_EEPSITE + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
|
||||
out.write("<tr><td colspan=\"3\"><hr /></td></tr>\n");
|
||||
}
|
||||
private void renderOther(User user, PetNameDB db, String baseURI, PetName newName, PrintWriter out) throws IOException {
|
||||
TreeSet names = new TreeSet();
|
||||
for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
PetName pn = db.getByName(name);
|
||||
if (isRightProtocol(pn.getProtocol()))
|
||||
names.add(name);
|
||||
}
|
||||
out.write("<tr><td colspan=\"3\"><b>Other addresses</b></td></tr>\n");
|
||||
|
||||
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
|
||||
PetName pn = db.getByName((String)iter.next());
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (pn.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Network: <input type=\"text\" name=\"" + PARAM_NET + "\" value=\"" + pn.getNetwork() + "\" /> ");
|
||||
out.write("Protocol: <input type=\"text\" name=\"" + PARAM_PROTO + "\" value=\"" + pn.getProtocol() + "\" /> ");
|
||||
out.write("Name: <input type=\"hidden\" name=\"" + PARAM_NAME + "\" value=\"" + pn.getName() + "\" />" + pn.getName() +" ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"3\" value=\"" + pn.getLocation() + "\" /> ");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_DELETE_OTHER + "\" /> ");
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_UPDATE_OTHER + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
}
|
||||
|
||||
out.write("<form action=\"" + baseURI + "\" method=\"POST\">");
|
||||
|
||||
out.write("<tr><td colspan=\"3\">");
|
||||
out.write("<input type=\"checkbox\" name=\"" + PARAM_IS_PUBLIC + "\" value=\"true\" " + (newName.getIsPublic() ? " checked=\"true\" " : "") + " />\n");
|
||||
out.write("Network: <input type=\"text\" name=\"" + PARAM_NET + "\" value=\"" + newName.getNetwork() + "\" /> ");
|
||||
out.write("Protocol: <input type=\"text\" name=\"" + PARAM_PROTO + "\" value=\"" + newName.getProtocol() + "\" /> ");
|
||||
out.write("Name: <input type=\"text\" name=\"" + PARAM_NAME + "\" size=\"10\" value=\"" + newName.getName() + "\" /> ");
|
||||
out.write("Location: <input type=\"text\" name=\"" + PARAM_LOC + "\" size=\"3\" value=\"" + newName.getLocation() + "\" /> ");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"" + PARAM_ACTION + "\" value=\"" + ACTION_ADD_OTHER + "\" /> ");
|
||||
out.write("</td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
|
||||
out.write("<tr><td colspan=\"3\"><hr /></td></tr>\n");
|
||||
}
|
||||
|
||||
/** build the 'other' name passed in */
|
||||
private PetName buildNewName(HttpServletRequest req) { return buildNewName(req, null); }
|
||||
/** build a petname based by the request passed in, if the new entry is of the given protocol */
|
||||
private PetName buildNewName(HttpServletRequest req, String protocol) {
|
||||
PetName pn = new PetName();
|
||||
if (!isRightProtocol(req, protocol)) {
|
||||
pn.setIsPublic(true);
|
||||
pn.setName("");
|
||||
pn.setLocation("");
|
||||
if (protocol == null)
|
||||
pn.setProtocol("");
|
||||
else
|
||||
pn.setProtocol(protocol);
|
||||
pn.setNetwork("");
|
||||
return pn;
|
||||
} else {
|
||||
pn = buildNewAddress(req);
|
||||
pn.setProtocol(protocol);
|
||||
}
|
||||
return pn;
|
||||
}
|
||||
|
||||
private String getParam(HttpServletRequest req, String param) {
|
||||
if (empty(req, param)) {
|
||||
return "";
|
||||
} else {
|
||||
String val = req.getParameter(param);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isRightProtocol(HttpServletRequest req, String protocol) {
|
||||
// if they hit submit, they are actually updating stuff, so don't include a 'new' one
|
||||
if (!empty(req, PARAM_ACTION))
|
||||
return false;
|
||||
|
||||
return isRightProtocol(protocol, req.getParameter(PARAM_PROTO));
|
||||
}
|
||||
private boolean isRightProtocol(String proto) { return isRightProtocol((String)null, proto); }
|
||||
private boolean isRightProtocol(String proto, String reqProto) {
|
||||
if (empty(reqProto))
|
||||
return false;
|
||||
if (proto == null) {
|
||||
if (PROTO_ARCHIVE.equals(reqProto) ||
|
||||
PROTO_BLOG.equals(reqProto) ||
|
||||
PROTO_EEPSITE.equals(reqProto) ||
|
||||
PROTO_I2PHEX.equals(reqProto))
|
||||
return false;
|
||||
else // its something other than the four default types
|
||||
return true;
|
||||
} else {
|
||||
return proto.equals(reqProto);
|
||||
}
|
||||
}
|
||||
}
|
@ -60,6 +60,7 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
|
||||
req.getSession().setAttribute("user", user);
|
||||
|
||||
forceNewIndex = handleAddressbook(user, req) || forceNewIndex;
|
||||
forceNewIndex = handleBookmarking(user, req) || forceNewIndex;
|
||||
handleUpdateProfile(user, req);
|
||||
|
||||
@ -148,6 +149,123 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
return rv;
|
||||
}
|
||||
|
||||
private boolean handleAddressbook(User user, HttpServletRequest req) {
|
||||
if ( (!user.getAuthenticated()) || (empty(AddressesServlet.PARAM_ACTION)) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String action = req.getParameter(AddressesServlet.PARAM_ACTION);
|
||||
|
||||
if ( (AddressesServlet.ACTION_ADD_ARCHIVE.equals(action)) ||
|
||||
(AddressesServlet.ACTION_ADD_BLOG.equals(action)) ||
|
||||
(AddressesServlet.ACTION_ADD_EEPSITE.equals(action)) ||
|
||||
(AddressesServlet.ACTION_ADD_OTHER.equals(action)) ||
|
||||
(AddressesServlet.ACTION_ADD_PEER.equals(action)) ) {
|
||||
PetName pn = buildNewAddress(req);
|
||||
if ( (pn != null) && (pn.getName() != null) && (pn.getLocation() != null) &&
|
||||
(!user.getPetNameDB().containsName(pn.getName())) ) {
|
||||
user.getPetNameDB().add(pn);
|
||||
BlogManager.instance().saveUser(user);
|
||||
|
||||
updateSyndication(user, pn.getLocation(), !empty(req, AddressesServlet.PARAM_SYNDICATE));
|
||||
|
||||
if (pn.isMember(FilteredThreadIndex.GROUP_FAVORITE) ||
|
||||
pn.isMember(FilteredThreadIndex.GROUP_IGNORE))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} else {
|
||||
// not valid, ignore
|
||||
return false;
|
||||
}
|
||||
} else if ( (AddressesServlet.ACTION_UPDATE_ARCHIVE.equals(action)) ||
|
||||
(AddressesServlet.ACTION_UPDATE_BLOG.equals(action)) ||
|
||||
(AddressesServlet.ACTION_UPDATE_EEPSITE.equals(action)) ||
|
||||
(AddressesServlet.ACTION_UPDATE_OTHER.equals(action)) ||
|
||||
(AddressesServlet.ACTION_UPDATE_PEER.equals(action)) ) {
|
||||
return updateAddress(user, req);
|
||||
} else if ( (AddressesServlet.ACTION_DELETE_ARCHIVE.equals(action)) ||
|
||||
(AddressesServlet.ACTION_DELETE_BLOG.equals(action)) ||
|
||||
(AddressesServlet.ACTION_DELETE_EEPSITE.equals(action)) ||
|
||||
(AddressesServlet.ACTION_DELETE_OTHER.equals(action)) ||
|
||||
(AddressesServlet.ACTION_DELETE_PEER.equals(action)) ) {
|
||||
PetName pn = user.getPetNameDB().getByName(req.getParameter(AddressesServlet.PARAM_NAME));
|
||||
if (pn != null) {
|
||||
user.getPetNameDB().remove(pn);
|
||||
BlogManager.instance().saveUser(user);
|
||||
updateSyndication(user, pn.getLocation(), false);
|
||||
if (pn.isMember(FilteredThreadIndex.GROUP_FAVORITE) ||
|
||||
pn.isMember(FilteredThreadIndex.GROUP_IGNORE))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// not an addressbook op
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean updateAddress(User user, HttpServletRequest req) {
|
||||
PetName pn = user.getPetNameDB().getByName(req.getParameter(AddressesServlet.PARAM_NAME));
|
||||
if (pn != null) {
|
||||
boolean wasIgnored = pn.isMember(FilteredThreadIndex.GROUP_IGNORE);
|
||||
boolean wasFavorite = pn.isMember(FilteredThreadIndex.GROUP_FAVORITE);
|
||||
|
||||
pn.setIsPublic(!empty(req, AddressesServlet.PARAM_IS_PUBLIC));
|
||||
pn.setLocation(req.getParameter(AddressesServlet.PARAM_LOC));
|
||||
pn.setNetwork(req.getParameter(AddressesServlet.PARAM_NET));
|
||||
pn.setProtocol(req.getParameter(AddressesServlet.PARAM_PROTO));
|
||||
if (empty(req, AddressesServlet.PARAM_FAVORITE))
|
||||
pn.removeGroup(FilteredThreadIndex.GROUP_FAVORITE);
|
||||
else
|
||||
pn.addGroup(FilteredThreadIndex.GROUP_FAVORITE);
|
||||
if (empty(req, AddressesServlet.PARAM_IGNORE))
|
||||
pn.removeGroup(FilteredThreadIndex.GROUP_IGNORE);
|
||||
else
|
||||
pn.addGroup(FilteredThreadIndex.GROUP_IGNORE);
|
||||
|
||||
BlogManager.instance().saveUser(user);
|
||||
|
||||
if (AddressesServlet.PROTO_ARCHIVE.equals(pn.getProtocol()))
|
||||
updateSyndication(user, pn.getLocation(), !empty(req, AddressesServlet.PARAM_SYNDICATE));
|
||||
|
||||
return (wasIgnored != pn.isMember(FilteredThreadIndex.GROUP_IGNORE)) ||
|
||||
(wasFavorite != pn.isMember(FilteredThreadIndex.GROUP_IGNORE));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateSyndication(User user, String loc, boolean shouldAutomate) {
|
||||
if (BlogManager.instance().authorizeRemote(user)) {
|
||||
if (shouldAutomate)
|
||||
BlogManager.instance().scheduleSyndication(loc);
|
||||
else
|
||||
BlogManager.instance().unscheduleSyndication(loc);
|
||||
}
|
||||
}
|
||||
|
||||
protected PetName buildNewAddress(HttpServletRequest req) {
|
||||
PetName pn = new PetName();
|
||||
pn.setName(req.getParameter(AddressesServlet.PARAM_NAME));
|
||||
pn.setIsPublic(!empty(req, AddressesServlet.PARAM_IS_PUBLIC));
|
||||
pn.setLocation(req.getParameter(AddressesServlet.PARAM_LOC));
|
||||
pn.setNetwork(req.getParameter(AddressesServlet.PARAM_NET));
|
||||
pn.setProtocol(req.getParameter(AddressesServlet.PARAM_PROTO));
|
||||
if (empty(req, AddressesServlet.PARAM_FAVORITE))
|
||||
pn.removeGroup(FilteredThreadIndex.GROUP_FAVORITE);
|
||||
else
|
||||
pn.addGroup(FilteredThreadIndex.GROUP_FAVORITE);
|
||||
if (empty(req, AddressesServlet.PARAM_IGNORE))
|
||||
pn.removeGroup(FilteredThreadIndex.GROUP_IGNORE);
|
||||
else
|
||||
pn.addGroup(FilteredThreadIndex.GROUP_IGNORE);
|
||||
return pn;
|
||||
}
|
||||
|
||||
protected void handleUpdateProfile(User user, HttpServletRequest req) {
|
||||
if ( (user == null) || (!user.getAuthenticated()) || (user.getBlog() == null) )
|
||||
return;
|
||||
@ -261,6 +379,7 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
out.write("</a>\n");
|
||||
out.write("(<a href=\"switchuser.jsp\" title=\"Log in as another user\">switch</a>)\n");
|
||||
out.write("<a href=\"post.jsp\" title=\"Post a new thread\">Post a new thread</a>\n");
|
||||
out.write("<a href=\"addresses.jsp\" title=\"View your addressbook\">Addressbook</a>\n");
|
||||
} else {
|
||||
out.write("<form action=\"" + req.getRequestURI() + "\" method=\"GET\">\n");
|
||||
out.write("Login: <input type=\"text\" name=\"login\" />\n");
|
||||
@ -270,13 +389,22 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
//out.write("</td><td class=\"topNav_admin\">\n");
|
||||
out.write("</span><span class=\"topNav_admin\">\n");
|
||||
if (BlogManager.instance().authorizeRemote(user)) {
|
||||
out.write("<a href=\"syndicate.jsp\" title=\"Syndicate data between other Syndie nodes\">Syndicate</a>\n");
|
||||
out.write("<a href=\"" + getSyndicateLink(user, null) + "\" title=\"Syndicate data between other Syndie nodes\">Syndicate</a>\n");
|
||||
out.write("<a href=\"importfeed.jsp\" title=\"Import RSS/Atom data\">Import RSS/Atom</a>\n");
|
||||
out.write("<a href=\"admin.jsp\" title=\"Configure this Syndie node\">Admin</a>\n");
|
||||
}
|
||||
out.write("</span><!-- nav bar end -->\n</td></tr>\n");
|
||||
}
|
||||
|
||||
protected String getSyndicateLink(User user, String archiveName) {
|
||||
if ( (user != null) && (archiveName != null) ) {
|
||||
PetName pn = user.getPetNameDB().getByName(archiveName);
|
||||
if (pn != null)
|
||||
return "syndicate.jsp?" + ThreadedHTMLRenderer.PARAM_ARCHIVE + "=" + pn.getLocation();
|
||||
}
|
||||
return "syndicate.jsp";
|
||||
}
|
||||
|
||||
protected static final ArrayList SKIP_TAGS = new ArrayList();
|
||||
static {
|
||||
SKIP_TAGS.add("action");
|
||||
@ -317,7 +445,7 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
out.write("<input type=\"hidden\" name=\"" + param + "\" value=\"" + val + "\" />\n");
|
||||
}
|
||||
}
|
||||
out.write("<tr class=\"controlBar\"><td colspan=\"2\">\n");
|
||||
out.write("<tr class=\"controlBar\"><td colspan=\"2\" width=\"99%\">\n");
|
||||
out.write("<!-- control bar begin -->\n");
|
||||
out.write("Filter: <select name=\"" + ThreadedHTMLRenderer.PARAM_AUTHOR + "\">\n");
|
||||
|
||||
@ -346,7 +474,7 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
out.write("Tags: <input type=\"text\" name=\"" + ThreadedHTMLRenderer.PARAM_TAGS + "\" size=\"10\" value=\"" + tags + "\" />\n");
|
||||
|
||||
out.write("<input type=\"submit\" name=\"action\" value=\"Go\" />\n");
|
||||
out.write("</td><td class=\"controlBarRight\"><a href=\"#threads\" title=\"Jump to the thread navigation\">Threads</a></td>\n");
|
||||
out.write("</td><td class=\"controlBarRight\" width=\"1%\"><a href=\"#threads\" title=\"Jump to the thread navigation\">Threads</a></td>\n");
|
||||
out.write("<!-- control bar end -->\n");
|
||||
out.write("</tr>\n");
|
||||
out.write("</form>\n");
|
||||
|
@ -135,22 +135,22 @@ public class ProfileServlet extends BaseServlet {
|
||||
out.write("<tr><td colspan=\"3\">Currently ignored - threads they create are hidden.</td></tr>\n");
|
||||
String remIgnore = getRemoveFromGroupLink(user, pn.getName(), FilteredThreadIndex.GROUP_IGNORE,
|
||||
baseURI, "", "", "", "", "", author.toBase64());
|
||||
out.write("<tr><td></td><td colspan=\"2\"><a href=\"" + remIgnore + "\">Unignore " + pn.getName() + "</a></td></tr>\n");
|
||||
out.write("<tr><td colspan=\"3\"><a href=\"" + remIgnore + "\">Unignore " + pn.getName() + "</a></td></tr>\n");
|
||||
String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "",
|
||||
baseURI, "", "", "", "", "", author.toBase64());
|
||||
out.write("<tr><td></td><td colspan=\"2\"><a href=\"" + remCompletely + "\">Forget about " + pn.getName() + " entirely</a></td></tr>\n");
|
||||
out.write("<tr><td colspan=\"3\"><a href=\"" + remCompletely + "\">Forget about " + pn.getName() + " entirely</a></td></tr>\n");
|
||||
} else if (pn.isMember(FilteredThreadIndex.GROUP_FAVORITE)) {
|
||||
out.write("<tr><td colspan=\"3\">Currently marked as a favorite author - threads they participate in " +
|
||||
"are highlighted.</td></tr>\n");
|
||||
String remIgnore = getRemoveFromGroupLink(user, pn.getName(), FilteredThreadIndex.GROUP_FAVORITE,
|
||||
baseURI, "", "", "", "", "", author.toBase64());
|
||||
out.write("<tr><td></td><td colspan=\"2\"><a href=\"" + remIgnore + "\">Remove " + pn.getName() + " from the list of favorite authors</a></td></tr>\n");
|
||||
out.write("<tr><td colspan=\"3\"><a href=\"" + remIgnore + "\">Remove " + pn.getName() + " from the list of favorite authors</a></td></tr>\n");
|
||||
String addIgnore = getAddToGroupLink(user, author, FilteredThreadIndex.GROUP_IGNORE,
|
||||
baseURI, "", "", "", "", "", author.toBase64());
|
||||
out.write("<tr><td></td><td colspan=\"2\"><a href=\"" + addIgnore + "\" title=\"Threads by ignored authors are hidden from view\">Ignore the author</a></td></tr>");
|
||||
out.write("<tr><td colspan=\"3\"><a href=\"" + addIgnore + "\" title=\"Threads by ignored authors are hidden from view\">Ignore the author</a></td></tr>");
|
||||
String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "",
|
||||
baseURI, "", "", "", "", "", author.toBase64());
|
||||
out.write("<tr><td></td><td colspan=\"2\"><a href=\"" + remCompletely + "\">Forget about " + pn.getName() + " entirely</a></td></tr>\n");
|
||||
out.write("<tr><td colspan=\"3\"><a href=\"" + remCompletely + "\">Forget about " + pn.getName() + " entirely</a></td></tr>\n");
|
||||
} else {
|
||||
out.write("<tr><td colspan=\"3\">Currently bookmarked. Add them to your ");
|
||||
String addFav = getAddToGroupLink(user, author, FilteredThreadIndex.GROUP_FAVORITE,
|
||||
@ -161,7 +161,7 @@ public class ProfileServlet extends BaseServlet {
|
||||
out.write("<a href=\"" + addIgnore + "\" title=\"Threads by ignored authors are hidden from view\">ignored</a> list</td></tr>");
|
||||
String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "",
|
||||
baseURI, "", "", "", "", "", author.toBase64());
|
||||
out.write("<tr><td></td><td colspan=\"2\"><a href=\"" + remCompletely + "\">Forget about " + pn.getName() + " entirely</a></td></tr>\n");
|
||||
out.write("<tr><td colspan=\"3\"><a href=\"" + remCompletely + "\">Forget about " + pn.getName() + " entirely</a></td></tr>\n");
|
||||
}
|
||||
|
||||
if (info != null) {
|
||||
|
@ -1,231 +0,0 @@
|
||||
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="net.i2p.data.Base64, net.i2p.syndie.web.*, net.i2p.syndie.sml.*, net.i2p.syndie.data.*, net.i2p.syndie.*, net.i2p.client.naming.PetName, net.i2p.client.naming.PetNameDB, org.mortbay.servlet.MultiPartRequest, java.util.*, java.io.*" %><%
|
||||
request.setCharacterEncoding("UTF-8"); %><jsp:useBean scope="session" class="net.i2p.syndie.User" id="user"
|
||||
/><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>SyndieMedia addressbook</title>
|
||||
<link href="style.jsp" rel="stylesheet" type="text/css" >
|
||||
</head>
|
||||
<body><!-- auth? <%=user.getAuthenticated()%> remote? <%=user.getAllowAccessRemote()%> sched? <%=request.getParameter("scheduleSyndication")%> -->
|
||||
<table border="1" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr class="b_toplogo"><td colspan="5" valign="top" align="left" class="b_toplogo"><jsp:include page="_toplogo.jsp" /></td></tr>
|
||||
<tr><td valign="top" align="left" rowspan="2" class="b_leftnav"><jsp:include page="_leftnav.jsp" /></td>
|
||||
<jsp:include page="_topnav.jsp" />
|
||||
<td valign="top" align="left" rowspan="2" class="b_rightnav"><jsp:include page="_rightnav.jsp" /></td></tr>
|
||||
<tr class="b_content"><td valign="top" align="left" colspan="3" class="b_content"><%
|
||||
if (!user.getAuthenticated()) {
|
||||
%><span class="b_addrMsgErr">You must log in to view your addressbook</span><%
|
||||
} else {
|
||||
PetNameDB names = user.getPetNameDB();
|
||||
String action = request.getParameter("action");
|
||||
if ( (action != null) && ("Change".equals(action)) ) {
|
||||
String oldPetname = request.getParameter("petname");
|
||||
PetName cur = names.getByName(oldPetname);
|
||||
if (cur != null) {
|
||||
cur.setName(request.getParameter("name"));
|
||||
cur.setNetwork(request.getParameter("network"));
|
||||
cur.setProtocol(request.getParameter("protocol"));
|
||||
cur.setIsPublic(null != request.getParameter("isPublic"));
|
||||
cur.setLocation(request.getParameter("location"));
|
||||
cur.setGroups(request.getParameter("groups"));
|
||||
names.removeName(oldPetname);
|
||||
names.add(cur);
|
||||
names.store(user.getAddressbookLocation());
|
||||
if ( ("syndiearchive".equals(cur.getProtocol())) && (BlogManager.instance().authorizeRemote(user)) ) {
|
||||
if (null != request.getParameter("scheduleSyndication")) {
|
||||
BlogManager.instance().scheduleSyndication(cur.getLocation());
|
||||
BlogManager.instance().writeConfig();
|
||||
} else {
|
||||
BlogManager.instance().unscheduleSyndication(cur.getLocation());
|
||||
BlogManager.instance().writeConfig();
|
||||
}
|
||||
}
|
||||
%><span class="b_addrMsgOk">Address updated</span><%
|
||||
}
|
||||
} else if ( (action != null) && ("Add".equals(action)) ) {
|
||||
PetName cur = names.getByName(request.getParameter("name"));
|
||||
if (cur != null) { %><span class="b_addrMsgErr">Address already exists</span><% } else {
|
||||
cur = new PetName();
|
||||
cur.setName(request.getParameter("name"));
|
||||
cur.setNetwork(request.getParameter("network"));
|
||||
cur.setProtocol(request.getParameter("protocol"));
|
||||
cur.setIsPublic(null != request.getParameter("isPublic"));
|
||||
cur.setLocation(request.getParameter("location"));
|
||||
cur.setGroups(request.getParameter("groups"));
|
||||
names.add(cur);
|
||||
names.store(user.getAddressbookLocation());
|
||||
if ( ("syndiearchive".equals(cur.getProtocol())) && (BlogManager.instance().authorizeRemote(user)) ) {
|
||||
if (null != request.getParameter("scheduleSyndication")) {
|
||||
BlogManager.instance().scheduleSyndication(cur.getLocation());
|
||||
BlogManager.instance().writeConfig();
|
||||
}
|
||||
}
|
||||
%><span class="b_addrMsgOk">Address added</span><%
|
||||
}
|
||||
} else if ( (action != null) && ("Delete".equals(action)) ) {
|
||||
PetName cur = names.getByName(request.getParameter("name"));
|
||||
if (cur != null) {
|
||||
if ( ("syndiearchive".equals(cur.getProtocol())) && (BlogManager.instance().authorizeRemote(user)) ) {
|
||||
BlogManager.instance().unscheduleSyndication(cur.getLocation());
|
||||
BlogManager.instance().writeConfig();
|
||||
}
|
||||
names.removeName(cur.getName());
|
||||
names.store(user.getAddressbookLocation());
|
||||
%><span class="b_addrMsgOk">Address removed</span><%
|
||||
}
|
||||
} else if ( (action != null) && ("Export".equals(action)) ) {
|
||||
%><%=BlogManager.instance().exportHosts(user)%><%
|
||||
}
|
||||
TreeSet sorted = new TreeSet(names.getNames());
|
||||
%><table border="0" width="100%" class="b_addr">
|
||||
<tr class="b_addrHeader">
|
||||
<td class="b_addrHeader"><em class="b_addrHeader">Name</em></td>
|
||||
<td class="b_addrHeader"><em class="b_addrHeader">Network</em></td>
|
||||
<td class="b_addrHeader"><em class="b_addrHeader">Protocol</em></td>
|
||||
<td class="b_addrHeader"><em class="b_addrHeader">Location</em></td>
|
||||
<td class="b_addrHeader"><em class="b_addrHeader">Public?</em></td>
|
||||
<td class="b_addrHeader"><em class="b_addrHeader">Automated?</em></td>
|
||||
<td class="b_addrHeader"><em class="b_addrHeader">Groups</em></td>
|
||||
<td class="b_addrHeader"> </td></tr>
|
||||
<%
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
|
||||
PetName name = names.getByName((String)iter.next());
|
||||
buf.append("<tr class=\"b_addrDetail\"><form action=\"addresses.jsp\" method=\"POST\">");
|
||||
buf.append("<input type=\"hidden\" name=\"petname\" value=\"").append(name.getName()).append("\" />");
|
||||
buf.append("<td class=\"b_addrName\"><input class=\"b_addrName\" type=\"text\" size=\"20\" name=\"name\" value=\"").append(name.getName()).append("\" /></td>");
|
||||
buf.append("<td class=\"b_addrNet\"><select class=\"b_addrNet\" name=\"network\">");
|
||||
String net = name.getNetwork();
|
||||
if (net == null) net = "";
|
||||
buf.append("<option value=\"i2p\" ");
|
||||
if ("i2p".equals(net))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>I2P</option>");
|
||||
|
||||
buf.append("<option value=\"syndie\" ");
|
||||
if ( ("syndie".equals(net)) || ("".equals(net)) )
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>Syndie</option>");
|
||||
|
||||
buf.append("<option value=\"tor\" ");
|
||||
if ("tor".equals(net))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>TOR</option>");
|
||||
|
||||
buf.append("<option value=\"freenet\" ");
|
||||
if ("freenet".equals(net))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>Freenet</option>");
|
||||
|
||||
buf.append("<option value=\"internet\" ");
|
||||
if ("internet".equals(net))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>Internet</option>");
|
||||
|
||||
buf.append("</select></td>");
|
||||
|
||||
buf.append("<td class=\"b_addrProto\"><select class=\"b_addrProto\" name=\"protocol\">");
|
||||
String proto = name.getProtocol();
|
||||
if (proto == null) proto = "";
|
||||
|
||||
buf.append("<option value=\"http\" ");
|
||||
if ("http".equals(proto))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>HTTP</option>");
|
||||
|
||||
buf.append("<option value=\"irc\" ");
|
||||
if ("irc".equals(proto))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>IRC</option>");
|
||||
|
||||
buf.append("<option value=\"i2phex\" ");
|
||||
if ("i2phex".equals(proto))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>I2Phex</option>");
|
||||
|
||||
buf.append("<option value=\"syndiearchive\" ");
|
||||
if ("syndiearchive".equals(proto))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>Syndie archive</option>");
|
||||
|
||||
buf.append("<option value=\"syndieblog\" ");
|
||||
if ("syndieblog".equals(proto))
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append("/>Syndie blog</option>");
|
||||
|
||||
buf.append("</select></td>");
|
||||
|
||||
buf.append("<td class=\"b_addrLoc\">");
|
||||
if (name.getLocation() != null)
|
||||
buf.append("<input class=\"b_addrLoc\" name=\"location\" size=\"50\" value=\"").append(name.getLocation()).append("\" />");
|
||||
else
|
||||
buf.append("<input class=\"b_addrLoc\" name=\"location\" size=\"50\" value=\"\" />");
|
||||
|
||||
buf.append("</td>");
|
||||
buf.append("<td class=\"b_addrPublic\"><input class=\"b_addrPublic\" type=\"checkbox\" name=\"isPublic\" ");
|
||||
if (name.getIsPublic())
|
||||
buf.append("checked=\"true\" ");
|
||||
buf.append(" /></td>");
|
||||
if (BlogManager.instance().authorizeRemote(user)) {
|
||||
buf.append("<td class=\"b_scheduled\"><input class=\"b_scheduled\" type=\"checkbox\" name=\"scheduleSyndication\" value=\"true\" ");
|
||||
if (BlogManager.instance().syndicationScheduled(name.getLocation()))
|
||||
buf.append("checked=\"true\" ");
|
||||
buf.append(" /></td>");
|
||||
} else {
|
||||
buf.append("<td class=\"b_scheduled\"><input class=\"b_scheduled\" type=\"checkbox\" name=\"scheduleSyndication\" value=\"false\" disabled=\"true\" /></td>\n");
|
||||
}
|
||||
buf.append("<td class=\"b_addrGroup\"><input class=\"b_addrGroup\" type=\"text\" name=\"groups\" size=\"10\" value=\"");
|
||||
for (int j = 0; j < name.getGroupCount(); j++) {
|
||||
buf.append(HTMLRenderer.sanitizeTagParam(name.getGroup(j)));
|
||||
if (j + 1 < name.getGroupCount())
|
||||
buf.append(',');
|
||||
}
|
||||
buf.append("\" /></td><td class=\"b_addrDetail\" nowrap=\"nowrap\">");
|
||||
buf.append("<input class=\"b_addrChange\" type=\"submit\" name=\"action\" value=\"Change\" /> <input class=\"b_addrDelete\" type=\"submit\" name=\"action\" value=\"Delete\" />");
|
||||
buf.append("</td></form></tr>");
|
||||
out.write(buf.toString());
|
||||
buf.setLength(0);
|
||||
}
|
||||
|
||||
String net = request.getParameter("network");
|
||||
String proto = request.getParameter("protocol");
|
||||
String name = request.getParameter("name");
|
||||
String loc = request.getParameter("location");
|
||||
boolean active = (request.getParameter("action") != null);
|
||||
if (net == null || active) net = "";
|
||||
if (proto == null || active) proto = "";
|
||||
if (name == null || active) name = "";
|
||||
if (loc == null || active) loc= "";
|
||||
%>
|
||||
<tr class="b_addrDetail"><form action="addresses.jsp" method="POST">
|
||||
<td class="b_addrName"><input class="b_addrName" type="text" name="name" size="20" value="<%=name%>" /></td>
|
||||
<td class="b_addrNet"><select class="b_addrNet" name="network">
|
||||
<option value="i2p" <%="i2p".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>I2P</option>
|
||||
<option value="syndie" <%="syndie".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>Syndie</option>
|
||||
<option value="tor" <%="tor".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>Tor</option>
|
||||
<option value="freenet" <%="freenet".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>Freenet</option>
|
||||
<option value="internet" <%="internet".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>Internet</option></select></td>
|
||||
<td class="b_addrProto"><select class="b_addrProto" name="protocol">
|
||||
<option value="http" <%="http".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>HTTP</option>
|
||||
<option value="irc" <%="irc".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>IRC</option>
|
||||
<option value="i2phex" <%="i2phex".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>I2Phex</option>
|
||||
<option value="syndiearchive" <%="syndiearchive".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>Syndie archive</option>
|
||||
<option value="syndieblog" <%="syndieblog".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>Syndie blog</option></select></td>
|
||||
<td class="b_addrLoc"><input class="b_addrLoc" type="text" size="50" name="location" value="<%=loc%>" /></td>
|
||||
<td class="b_addrPublic"><input class="b_addrPublic" type="checkbox" name="isPublic" /></td>
|
||||
<td class="b_scheduled"><input class="b_sheduled" type="checkbox" name="scheduleSyndication" value="true" /></td>
|
||||
<td class="b_addrGroup"><input class="b_addrGroup" type="text" name="groups" size="10" /></td>
|
||||
<td class="b_addrDetail"><input class="b_addrAdd" type="submit" name="action" value="Add" /></td>
|
||||
</form></tr>
|
||||
<tr class="b_addrExport"><form action="addresses.jsp" method="POST">
|
||||
<td class="b_addrExport" colspan="7">
|
||||
<span class="b_addrExport">Export the eepsites to your router's petname db</span>
|
||||
<input class="b_addrExportSubmit" type="submit" name="action" value="Export" /></td>
|
||||
</form></tr>
|
||||
</table>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</td></tr>
|
||||
</table>
|
||||
</body>
|
@ -24,6 +24,16 @@
|
||||
<servlet-class>net.i2p.syndie.web.ProfileServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>net.i2p.syndie.web.SwitchServlet</servlet-name>
|
||||
<servlet-class>net.i2p.syndie.web.SwitchServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>net.i2p.syndie.web.AddressesServlet</servlet-name>
|
||||
<servlet-class>net.i2p.syndie.web.AddressesServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>net.i2p.syndie.UpdaterServlet</servlet-name>
|
||||
<servlet-class>net.i2p.syndie.UpdaterServlet</servlet-class>
|
||||
@ -54,6 +64,14 @@
|
||||
<servlet-name>net.i2p.syndie.web.ProfileServlet</servlet-name>
|
||||
<url-pattern>/profile.jsp</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>net.i2p.syndie.web.SwitchServlet</servlet-name>
|
||||
<url-pattern>/switchuser.jsp</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>net.i2p.syndie.web.AddressesServlet</servlet-name>
|
||||
<url-pattern>/addresses.jsp</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
|
Reference in New Issue
Block a user