diff --git a/apps/syndie/java/src/net/i2p/syndie/sml/ThreadedHTMLRenderer.java b/apps/syndie/java/src/net/i2p/syndie/sml/ThreadedHTMLRenderer.java index 38da0529f..179324fe9 100644 --- a/apps/syndie/java/src/net/i2p/syndie/sml/ThreadedHTMLRenderer.java +++ b/apps/syndie/java/src/net/i2p/syndie/sml/ThreadedHTMLRenderer.java @@ -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); diff --git a/apps/syndie/java/src/net/i2p/syndie/web/AddressesServlet.java b/apps/syndie/java/src/net/i2p/syndie/web/AddressesServlet.java new file mode 100644 index 000000000..56dfd7ded --- /dev/null +++ b/apps/syndie/java/src/net/i2p/syndie/web/AddressesServlet.java @@ -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("You must log in to view your addressbook\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("Syndie authors\n"); + for (Iterator iter = names.iterator(); iter.hasNext(); ) { + PetName pn = db.getByName((String)iter.next()); + out.write("
"); + out.write(""); + out.write(""); + out.write(""); + out.write("\n"); + out.write("Name: " + pn.getName() + " "); + out.write("Location: "); + if (pn.isMember(FilteredThreadIndex.GROUP_FAVORITE)) + out.write("Favorite? "); + else + out.write("Favorite? "); + + if (pn.isMember(FilteredThreadIndex.GROUP_IGNORE)) { + out.write("Ignored? "); + } else { + out.write("Ignored? "); + out.write("\n"); out.write("(switch)\n"); out.write("Post a new thread\n"); + out.write("Addressbook\n"); } else { out.write("\n"); out.write("Login: \n"); @@ -270,13 +389,22 @@ public abstract class BaseServlet extends HttpServlet { //out.write("\n"); out.write("\n"); if (BlogManager.instance().authorizeRemote(user)) { - out.write("Syndicate\n"); + out.write("Syndicate\n"); out.write("Import RSS/Atom\n"); out.write("Admin\n"); } out.write("\n\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("\n"); } } - out.write("\n"); + out.write("\n"); out.write("\n"); out.write("Filter: \n"); out.write("\n"); - out.write("Threads\n"); + out.write("Threads\n"); out.write("\n"); out.write("\n"); out.write("
\n"); diff --git a/apps/syndie/java/src/net/i2p/syndie/web/ProfileServlet.java b/apps/syndie/java/src/net/i2p/syndie/web/ProfileServlet.java index 7ddbfc9b3..7aed5bc24 100644 --- a/apps/syndie/java/src/net/i2p/syndie/web/ProfileServlet.java +++ b/apps/syndie/java/src/net/i2p/syndie/web/ProfileServlet.java @@ -135,22 +135,22 @@ public class ProfileServlet extends BaseServlet { out.write("Currently ignored - threads they create are hidden.\n"); String remIgnore = getRemoveFromGroupLink(user, pn.getName(), FilteredThreadIndex.GROUP_IGNORE, baseURI, "", "", "", "", "", author.toBase64()); - out.write("Unignore " + pn.getName() + "\n"); + out.write("Unignore " + pn.getName() + "\n"); String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "", baseURI, "", "", "", "", "", author.toBase64()); - out.write("Forget about " + pn.getName() + " entirely\n"); + out.write("Forget about " + pn.getName() + " entirely\n"); } else if (pn.isMember(FilteredThreadIndex.GROUP_FAVORITE)) { out.write("Currently marked as a favorite author - threads they participate in " + "are highlighted.\n"); String remIgnore = getRemoveFromGroupLink(user, pn.getName(), FilteredThreadIndex.GROUP_FAVORITE, baseURI, "", "", "", "", "", author.toBase64()); - out.write("Remove " + pn.getName() + " from the list of favorite authors\n"); + out.write("Remove " + pn.getName() + " from the list of favorite authors\n"); String addIgnore = getAddToGroupLink(user, author, FilteredThreadIndex.GROUP_IGNORE, baseURI, "", "", "", "", "", author.toBase64()); - out.write(""); + out.write(""); String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "", baseURI, "", "", "", "", "", author.toBase64()); - out.write("Forget about " + pn.getName() + " entirely\n"); + out.write("Forget about " + pn.getName() + " entirely\n"); } else { out.write("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(" list"); String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "", baseURI, "", "", "", "", "", author.toBase64()); - out.write("Forget about " + pn.getName() + " entirely\n"); + out.write("Forget about " + pn.getName() + " entirely\n"); } if (info != null) { diff --git a/apps/syndie/jsp/addresses.jsp b/apps/syndie/jsp/addresses.jsp deleted file mode 100644 index 17b7fc875..000000000 --- a/apps/syndie/jsp/addresses.jsp +++ /dev/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"); %> - - -SyndieMedia addressbook - - - - - - - - - -
<% -if (!user.getAuthenticated()) { - %>You must log in to view your addressbook<% -} 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(); - } - } - %>Address updated<% - } - } else if ( (action != null) && ("Add".equals(action)) ) { - PetName cur = names.getByName(request.getParameter("name")); - if (cur != null) { %>Address already exists<% } 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(); - } - } - %>Address added<% - } - } 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()); - %>Address removed<% - } - } else if ( (action != null) && ("Export".equals(action)) ) { - %><%=BlogManager.instance().exportHosts(user)%><% - } - TreeSet sorted = new TreeSet(names.getNames()); - %> - - - - - - - - - -<% - StringBuffer buf = new StringBuffer(128); - for (Iterator iter = sorted.iterator(); iter.hasNext(); ) { - PetName name = names.getByName((String)iter.next()); - buf.append(""); - buf.append(""); - buf.append(""); - buf.append(""); - - buf.append(""); - - buf.append(""); - buf.append(""); - if (BlogManager.instance().authorizeRemote(user)) { - buf.append(""); - } else { - buf.append("\n"); - } - buf.append(""); - 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= ""; - %> - - - - - - - - - - - - - -
NameNetworkProtocolLocationPublic?Automated?Groups 
"); - if (name.getLocation() != null) - buf.append(""); - else - buf.append(""); - - buf.append(""); - buf.append(" "); - buf.append("
- Export the eepsites to your router's petname db -
- <% -} -%> -
- diff --git a/apps/syndie/jsp/web.xml b/apps/syndie/jsp/web.xml index 52c3a854d..17ce10263 100644 --- a/apps/syndie/jsp/web.xml +++ b/apps/syndie/jsp/web.xml @@ -24,6 +24,16 @@ net.i2p.syndie.web.ProfileServlet + + net.i2p.syndie.web.SwitchServlet + net.i2p.syndie.web.SwitchServlet + + + + net.i2p.syndie.web.AddressesServlet + net.i2p.syndie.web.AddressesServlet + + net.i2p.syndie.UpdaterServlet net.i2p.syndie.UpdaterServlet @@ -54,6 +64,14 @@ net.i2p.syndie.web.ProfileServlet /profile.jsp + + net.i2p.syndie.web.SwitchServlet + /switchuser.jsp + + + net.i2p.syndie.web.AddressesServlet + /addresses.jsp +