diff --git a/apps/syndie/java/src/net/i2p/syndie/data/BlogInfoData.java b/apps/syndie/java/src/net/i2p/syndie/data/BlogInfoData.java
index b1aeb60e0..69e9baee4 100644
--- a/apps/syndie/java/src/net/i2p/syndie/data/BlogInfoData.java
+++ b/apps/syndie/java/src/net/i2p/syndie/data/BlogInfoData.java
@@ -102,6 +102,7 @@ public class BlogInfoData {
prevGroup = pn.getGroup(0);
}
}
+ line.setLength(0);
if (!ok)
break;
}
diff --git a/apps/syndie/java/src/net/i2p/syndie/data/FilteredThreadIndex.java b/apps/syndie/java/src/net/i2p/syndie/data/FilteredThreadIndex.java
index eeaa9ee80..c8684be87 100644
--- a/apps/syndie/java/src/net/i2p/syndie/data/FilteredThreadIndex.java
+++ b/apps/syndie/java/src/net/i2p/syndie/data/FilteredThreadIndex.java
@@ -61,6 +61,8 @@ public class FilteredThreadIndex extends ThreadIndex {
}
private boolean isIgnored(ThreadNode node, List ignoredAuthors, Collection requestedTags, Collection filteredAuthors, boolean filterAuthorsByRoot) {
+ if (node.getTags().contains(BlogInfoData.TAG))
+ return true; // its a fake post, containing some updated metadata for the blog
if (filteredAuthors.size() <= 0) {
boolean allAuthorsIgnored = true;
for (Iterator iter = node.getRecursiveAuthorIterator(); iter.hasNext(); ) {
diff --git a/apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java b/apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java
index 3174f404f..db9ed3b49 100644
--- a/apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java
+++ b/apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java
@@ -1102,7 +1102,7 @@ public class HTMLRenderer extends EventReceiverImpl {
+ "&" + SyndicateServlet.PARAM_SCHEMA + "=" + sanitizeTagParam(archiveLocation.getSchema())
+ "&" + SyndicateServlet.PARAM_LOCATION + "=" + sanitizeTagParam(archiveLocation.getLocation());
}
- public String getBookmarkURL(String name, String location, String schema, String protocol) {
+ public static String getBookmarkURL(String name, String location, String schema, String protocol) {
return "addresses.jsp?" + AddressesServlet.PARAM_NAME + '=' + sanitizeTagParam(name)
+ "&" + AddressesServlet.PARAM_NET + '=' + sanitizeTagParam(schema)
+ "&" + AddressesServlet.PARAM_PROTO + '=' + sanitizeTagParam(protocol)
diff --git a/apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java b/apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java
index b11e593cf..f82db02ee 100644
--- a/apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java
+++ b/apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java
@@ -23,7 +23,7 @@ import net.i2p.util.Log;
*/
public abstract class BaseServlet extends HttpServlet {
protected static final String PARAM_AUTH_ACTION = "syndie.auth";
- private static long _authNonce;
+ protected static long _authNonce;
protected I2PAppContext _context;
protected Log _log;
@@ -141,6 +141,7 @@ public abstract class BaseServlet extends HttpServlet {
forceNewIndex = handleBookmarking(user, req) || forceNewIndex;
forceNewIndex = handleManageTags(user, req) || forceNewIndex;
handleUpdateProfile(user, req);
+ req.setAttribute(BaseServlet.class.getName() + ".auth", "true");
}
// the 'dataImported' flag is set by successful fetches in the SyndicateServlet/RemoteArchiveBean
@@ -176,6 +177,10 @@ public abstract class BaseServlet extends HttpServlet {
protected void render(User user, HttpServletRequest req, HttpServletResponse resp, ThreadIndex index) throws IOException, ServletException {
render(user, req, resp.getWriter(), index);
}
+ protected boolean isAuthed(HttpServletRequest req) {
+ String auth = (String)req.getAttribute(BaseServlet.class.getName() + ".auth");
+ return (auth != null) && (Boolean.valueOf(auth).booleanValue());
+ }
private boolean handleBookmarking(User user, HttpServletRequest req) {
if (!user.getAuthenticated())
diff --git a/apps/syndie/java/src/net/i2p/syndie/web/BlogConfigBean.java b/apps/syndie/java/src/net/i2p/syndie/web/BlogConfigBean.java
index d5ecd1c2d..4ad6c7c8f 100644
--- a/apps/syndie/java/src/net/i2p/syndie/web/BlogConfigBean.java
+++ b/apps/syndie/java/src/net/i2p/syndie/web/BlogConfigBean.java
@@ -33,6 +33,8 @@ public class BlogConfigBean {
_styleOverrides = new Properties();
}
+ public boolean isUpdated() { return _updated; }
+
public User getUser() { return _user; }
public void setUser(User user) {
_user = user;
@@ -74,6 +76,8 @@ public class BlogConfigBean {
PetName pn = (PetName)grp.get(0);
if ( (pn.getGroupCount() == 0) && ( (name == null) || (name.length() <= 0) ) )
return grp;
+ if (pn.getGroupCount() == 0)
+ continue;
String curGroup = pn.getGroup(0);
if (curGroup.equals(name))
return grp;
@@ -94,6 +98,7 @@ public class BlogConfigBean {
} else {
group.add(pn);
}
+ _updated = true;
}
public void remove(PetName pn) {
String groupName = null;
@@ -105,6 +110,7 @@ public class BlogConfigBean {
if (group.size() <= 0)
_groups.remove(group);
}
+ _updated = true;
}
public void remove(String name) {
for (int i = 0; i < getGroupCount(); i++) {
@@ -115,6 +121,7 @@ public class BlogConfigBean {
group.remove(j);
if (group.size() <= 0)
_groups.remove(group);
+ _updated = true;
return;
}
}
@@ -140,7 +147,7 @@ public class BlogConfigBean {
_logo = logo;
_updated = true;
}
- public boolean hasPendingChanges() { return _updated; }
+ public boolean hasPendingChanges() { return _loaded && _updated; }
private void load() {
Archive archive = BlogManager.instance().getArchive();
@@ -175,7 +182,9 @@ public class BlogConfigBean {
add(pn);
}
}
- _styleOverrides.putAll(data.getStyleOverrides());
+ Properties overrides = data.getStyleOverrides();
+ if (overrides != null)
+ _styleOverrides.putAll(overrides);
} catch (IOException ioe) {
_log.warn("Unable to load the blog info data from " + uri, ioe);
}
@@ -183,9 +192,10 @@ public class BlogConfigBean {
}
}
_loaded = true;
+ _updated = false;
}
- public boolean publishChanges() throws IOException {
+ public boolean publishChanges() {
FileInputStream logo = null;
try {
if (_logo != null)
@@ -229,6 +239,7 @@ public class BlogConfigBean {
if (updated) {
// ok great, published locally, though should we push it to others?
_log.info("Blog summary updated for " + _user + " in " + uri.toString());
+ setUser(_user);
return true;
}
} else {
@@ -239,6 +250,8 @@ public class BlogConfigBean {
_log.error("Error creating the summary entry");
return false;
}
+ } catch (IOException ioe) {
+ _log.error("Error publishing", ioe);
} finally {
if (logo != null) try { logo.close(); } catch (IOException ioe) {}
// the other streams are in-memory, drop with the scope
diff --git a/apps/syndie/java/src/net/i2p/syndie/web/BlogConfigServlet.java b/apps/syndie/java/src/net/i2p/syndie/web/BlogConfigServlet.java
index 117bf9161..af71fbbc2 100644
--- a/apps/syndie/java/src/net/i2p/syndie/web/BlogConfigServlet.java
+++ b/apps/syndie/java/src/net/i2p/syndie/web/BlogConfigServlet.java
@@ -22,8 +22,8 @@ import net.i2p.syndie.sml.*;
public class BlogConfigServlet extends BaseServlet {
private static final String ATTR_CONFIG_BEAN = "__blogConfigBean";
public static final String PARAM_CONFIG_SCREEN = "screen";
- public static final String SCREEN_GENERAL = "general";
public static final String SCREEN_REFERENCES = "references";
+ public static final String SCREEN_IMAGES = "images";
protected void renderServletDetails(User user, HttpServletRequest req, PrintWriter out, ThreadIndex index,
int threadOffset, BlogURI visibleEntry, Archive archive) throws IOException {
if ( (user == null) || (!user.getAuthenticated() && !BlogManager.instance().isSingleUser())) {
@@ -34,6 +34,7 @@ public class BlogConfigServlet extends BaseServlet {
if (bean == null) {
bean = new BlogConfigBean();
bean.setUser(user);
+ req.getSession().setAttribute(ATTR_CONFIG_BEAN, bean);
}
// handle actions here...
@@ -41,191 +42,329 @@ public class BlogConfigServlet extends BaseServlet {
String screen = req.getParameter(PARAM_CONFIG_SCREEN);
if (screen == null)
- screen = SCREEN_GENERAL;
- out.write("todo: Display screen " + screen);
- /*
- if (SCREEN_REFERENCES.equals(screen)) {
- displayReferencesScreen(req, out, bean);
+ screen = SCREEN_REFERENCES;
+ out.write("
| \n");
+ showConfigNav(req, out);
+
+ if (isAuthed(req)) {
+ StringBuffer buf = handleOtherAuthedActions(user, req, bean);
+ if (buf != null) out.write(buf.toString());
} else {
- displayGeneralScreen(req, out, bean);
}
- */
- }
- /*
- private void renderMyProfile(User user, String baseURI, PrintWriter out, Archive archive) throws IOException {
- BlogInfo info = archive.getBlogInfo(user.getBlog());
- if (info == null)
- return;
+ if (bean.isUpdated())
+ showCommitForm(req, out);
- out.write("\n");
- out.write(" |
\n");
+ }
+
+ private void showCommitForm(HttpServletRequest req, PrintWriter out) throws IOException {
+ out.write("\n");
+ }
+
+ private void showConfigNav(HttpServletRequest req, PrintWriter out) throws IOException {
+ out.write("References "
+ + "Images
\n");
+ }
+
+ private String getScreenURL(HttpServletRequest req, String screen, boolean wantAuth) {
+ StringBuffer buf = new StringBuffer(128);
+ buf.append(req.getRequestURI()).append("?").append(PARAM_CONFIG_SCREEN).append("=");
+ buf.append(screen).append("&");
+ if (wantAuth)
+ buf.append(PARAM_AUTH_ACTION).append('=').append(_authNonce).append("&");
+ return buf.toString();
+ }
+
+ private void displayUnknownScreen(PrintWriter out, String screen) throws IOException {
+ out.write("
The screen " + HTMLRenderer.sanitizeString(screen) + " has not yet been implemented");
+ }
+ private void displayReferencesScreen(HttpServletRequest req, PrintWriter out, User user, BlogConfigBean bean) throws IOException {
+ out.write("\n");
}
- private void renderProfile(User user, String baseURI, PrintWriter out, Hash author, Archive archive) throws IOException {
- out.write("Profile for ");
- PetName pn = user.getPetNameDB().getByLocation(author.toBase64());
- String name = null;
- BlogInfo info = archive.getBlogInfo(author);
+ private void writePetnameDropdown(PrintWriter out, PetNameDB db) throws IOException {
+ Set names = db.getNames();
+ TreeSet ordered = new TreeSet(names);
+ for (Iterator iter = ordered.iterator(); iter.hasNext(); ) {
+ String name = (String)iter.next();
+ PetName pn = db.getByName(name);
+ String proto = pn.getProtocol();
+ if ("syndietag".equals(proto))
+ continue;
+ out.write("\n");
+ }
+ }
+
+ protected StringBuffer handleOtherAuthedActions(User user, HttpServletRequest req, BlogConfigBean bean) {
+ StringBuffer buf = new StringBuffer();
+ req.setAttribute(getClass().getName() + ".output", buf);
+ String action = req.getParameter("action");
+ if ("Publish blog configuration".equals(action)) {
+ if (bean.publishChanges()) {
+ buf.append("Changes published \n");
+ } else {
+ buf.append("Changes could not be published (please check the log) \n");
+ }
+ } else {
+ if ("Save changes".equals(action)) {
+ String newGroup = req.getParameter("new.group");
+ if ( (newGroup == null) || (newGroup.trim().length() <= 0) )
+ newGroup = req.getParameter("new.groupOther");
+ if ( (newGroup != null) && (newGroup.trim().length() > 0) ) {
+ addElement(req, user, newGroup, buf, bean);
+ } else {
+ }
+ } else {
+ }
+
+ handleDelete(req, user, bean, buf);
+ handleReorderGroup(req, user, bean, buf);
+ handleReorderRef(req, user, bean, buf);
+ }
+ return buf;
+ }
+
+ private void addElement(HttpServletRequest req, User user, String newGroup, StringBuffer actionOutputHTML, BlogConfigBean bean) {
+ String type = req.getParameter("new.type");
+ String loc = req.getParameter("new.location");
+ String name = req.getParameter("new.name");
+
+ if (empty(type) || empty(loc) || empty(name)) return;
+
+ PetName pn = null;
+ if ("blog".equals(type))
+ pn = new PetName(name, "syndie", "syndieblog", loc);
+ else if ("blogpost".equals(type))
+ pn = new PetName(name, "syndie", "syndieblogpost", loc);
+ else if ("blogpostattachment".equals(type))
+ pn = new PetName(name, "syndie", "syndieblogattachment", loc);
+ else if ("eepsite".equals(type))
+ pn = new PetName(name, "i2p", "http", loc);
+ else if ("website".equals(type))
+ pn = new PetName(name, "web", "http", loc);
+ else {
+ // unknown type
+ }
+
if (pn != null) {
- out.write(pn.getName());
- name = null;
- if (info != null)
- name = info.getProperty(BlogInfo.NAME);
-
- if ( (name == null) || (name.trim().length() <= 0) )
- name = author.toBase64().substring(0, 6);
-
- out.write(" (" + name + ")");
- } else {
- if (info != null)
- name = info.getProperty(BlogInfo.NAME);
-
- if ( (name == null) || (name.trim().length() <= 0) )
- name = author.toBase64().substring(0, 6);
- out.write(name);
+ if (!ViewBlogServlet.DEFAULT_GROUP_NAME.equals(newGroup))
+ pn.addGroup(newGroup);
+ bean.add(pn);
+ actionOutputHTML.append("Reference '").append(HTMLRenderer.sanitizeString(name));
+ actionOutputHTML.append("' for ").append(HTMLRenderer.sanitizeString(loc)).append(" added to ");
+ actionOutputHTML.append(HTMLRenderer.sanitizeString(newGroup)).append(" \n");
}
- out.write("");
- if (info != null)
- out.write(" [edition " + info.getEdition() + "]");
- out.write(" \n");
- out.write("View their blog or ");
- out.write("threads they have participated in\n");
- out.write(" |
\n");
-
- out.write("
|
\n");
- if (pn == null) {
- out.write("| Not currently bookmarked. Add them to your ");
- String addFav = getAddToGroupLink(user, author, FilteredThreadIndex.GROUP_FAVORITE,
- baseURI, "", "", "", "", "", author.toBase64());
- String addIgnore = getAddToGroupLink(user, author, FilteredThreadIndex.GROUP_IGNORE,
- baseURI, "", "", "", "", "", author.toBase64());
- out.write("favorites or ");
- out.write("ignored ");
- out.write(" |
\n");
- } else if (pn.isMember(FilteredThreadIndex.GROUP_IGNORE)) {
- 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");
- String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "",
- baseURI, "", "", "", "", "", author.toBase64());
- 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");
- String addIgnore = getAddToGroupLink(user, author, FilteredThreadIndex.GROUP_IGNORE,
- baseURI, "", "", "", "", "", author.toBase64());
- out.write("| Ignore the author |
");
- String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "",
- baseURI, "", "", "", "", "", author.toBase64());
- out.write("| Forget about " + pn.getName() + " entirely |
\n");
+ }
+
+ private void handleDelete(HttpServletRequest req, User user, BlogConfigBean bean, StringBuffer actionOutputHTML) {
+ // control parameters:
+ // delete=$i removes group # $i
+ // delete=$i.$j removes element $j in group $i
+ String del = req.getParameter("delete");
+ if (empty(del)) return;
+ int split = del.indexOf('.');
+ int group = -1;
+ int elem = -1;
+ if (split <= 0) {
+ try { group = Integer.parseInt(del); } catch (NumberFormatException nfe) {}
} else {
- out.write("| Currently bookmarked. Add them to your ");
- String addFav = getAddToGroupLink(user, author, FilteredThreadIndex.GROUP_FAVORITE,
- baseURI, "", "", "", "", "", author.toBase64());
- String addIgnore = getAddToGroupLink(user, author, FilteredThreadIndex.GROUP_IGNORE,
- baseURI, "", "", "", "", "", author.toBase64());
- out.write("favorites or ");
- out.write("ignored list |
");
- String remCompletely = getRemoveFromGroupLink(user, pn.getName(), "",
- baseURI, "", "", "", "", "", author.toBase64());
- out.write("| Forget about " + pn.getName() + " entirely |
\n");
+ try {
+ group = Integer.parseInt(del.substring(0, split));
+ elem = Integer.parseInt(del.substring(split+1));
+ } catch (NumberFormatException nfe) {
+ group = -1;
+ elem = -1;
+ }
}
-
- if (info != null) {
- String descr = info.getProperty(BlogInfo.DESCRIPTION);
- if ( (descr != null) && (descr.trim().length() > 0) )
- out.write("| Account description: " + HTMLRenderer.sanitizeString(descr) + " |
\n");
+ if ( (elem >= 0) && (group >= 0) ) {
+ List l = bean.getGroup(group);
+ if (elem < l.size()) {
+ PetName pn = (PetName)l.get(elem);
+ bean.remove(pn);
+ actionOutputHTML.append("Reference '").append(HTMLRenderer.sanitizeString(pn.getName()));
+ actionOutputHTML.append("' for ").append(HTMLRenderer.sanitizeString(pn.getLocation()));
+ actionOutputHTML.append(" removed
\n");
+ }
+ } else if ( (elem == -1) && (group >= 0) ) {
+ List l = bean.getGroup(group);
+ for (int i = 0; i < l.size(); i++) {
+ PetName pn = (PetName)l.get(i);
+ bean.remove(pn);
+ }
+ actionOutputHTML.append("All references in the selected group were removed
\n");
+ } else {
+ // noop
+ }
+ }
+
+ private void handleReorderGroup(HttpServletRequest req, User user, BlogConfigBean bean, StringBuffer actionOutputHTML) {
+ // control parameters:
+ // moveFrom=$i & moveTo=$j moves group $i to position $j
+ int from = -1;
+ int to = -1;
+ try {
+ String str = req.getParameter("moveFrom");
+ if (str != null)
+ from = Integer.parseInt(str);
+ str = req.getParameter("moveTo");
+ if (str != null)
+ to = Integer.parseInt(str);
- String contactURL = info.getProperty(BlogInfo.CONTACT_URL);
- if ( (contactURL != null) && (contactURL.trim().length() > 0) )
- out.write("| Contact information: "
- + HTMLRenderer.sanitizeString(contactURL) + " |
\n");
-
- String props[] = info.getProperties();
- int altCount = 0;
- if (props != null)
- for (int i = 0; i < props.length; i++)
- if (!BlogInfo.NAME.equals(props[i]) &&
- !BlogInfo.DESCRIPTION.equals(props[i]) &&
- !BlogInfo.EDITION.equals(props[i]) &&
- !BlogInfo.OWNER_KEY.equals(props[i]) &&
- !BlogInfo.POSTERS.equals(props[i]) &&
- !BlogInfo.SIGNATURE.equals(props[i]) &&
- !BlogInfo.CONTACT_URL.equals(props[i]))
- altCount++;
- if (altCount > 0) {
- for (int i = 0; i < props.length; i++) {
- if (!BlogInfo.NAME.equals(props[i]) &&
- !BlogInfo.DESCRIPTION.equals(props[i]) &&
- !BlogInfo.EDITION.equals(props[i]) &&
- !BlogInfo.OWNER_KEY.equals(props[i]) &&
- !BlogInfo.POSTERS.equals(props[i]) &&
- !BlogInfo.SIGNATURE.equals(props[i]) &&
- !BlogInfo.CONTACT_URL.equals(props[i])) {
- out.write("| ");
- out.write(HTMLRenderer.sanitizeString(props[i]) + ": "
- + HTMLRenderer.sanitizeString(info.getProperty(props[i])));
- out.write(" |
\n");
+ if ( (from >= 0) && (to >= 0) ) {
+ List src = bean.getGroup(from);
+ List dest = bean.getGroup(to);
+ List orig = new ArrayList(dest);
+ dest.clear();
+ dest.addAll(src);
+ src.clear();
+ src.addAll(orig);
+ bean.groupsUpdated();
+ actionOutputHTML.append("Reference group moved
\n");
+ }
+ } catch (NumberFormatException nfe) {
+ // ignore
+ }
+ }
+
+ private void handleReorderRef(HttpServletRequest req, User user, BlogConfigBean bean, StringBuffer actionOutputHTML) {
+ // control parameters:
+ // moveRefFrom=$i.$j & moveRefTo=$k.$l moves element $j in group $i to position $l in group l
+ // (i == k)
+ int from = -1;
+ int fromElem = -1;
+ int to = -1; // ignored
+ int toElem = -1;
+ try {
+ String str = req.getParameter("moveRefFrom");
+ if (str != null) {
+ int split = str.indexOf('.');
+ if (split > 0) {
+ try {
+ from = Integer.parseInt(str.substring(0, split));
+ fromElem = Integer.parseInt(str.substring(split+1));
+ } catch (NumberFormatException nfe) {
+ from = -1;
+ fromElem = -1;
}
}
}
+ str = req.getParameter("moveRefTo");
+ if (str != null) {
+ int split = str.indexOf('.');
+ if (split > 0) {
+ try {
+ to = Integer.parseInt(str.substring(0, split));
+ toElem = Integer.parseInt(str.substring(split+1));
+ } catch (NumberFormatException nfe) {
+ to = -1;
+ toElem = -1;
+ }
+ }
+ }
+
+ if ( (from >= 0) && (fromElem >= 0) && (toElem >= 0) ) {
+ List src = bean.getGroup(from);
+ PetName pn = (PetName)src.remove(fromElem);
+ src.add(toElem, pn);
+ bean.groupsUpdated();
+ actionOutputHTML.append("Reference element moved
\n");
+ }
+ } catch (NumberFormatException nfe) {
+ // ignore
}
}
- */
-
+
+
protected String getTitle() { return "Syndie :: Configure blog"; }
}
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 ebebc4914..f4ee59228 100644
--- a/apps/syndie/java/src/net/i2p/syndie/web/ProfileServlet.java
+++ b/apps/syndie/java/src/net/i2p/syndie/web/ProfileServlet.java
@@ -104,6 +104,7 @@ public class ProfileServlet extends BaseServlet {
out.write(" |
\n");
out.write("\n");
+ out.write("| Configure your blog |
\n");
}
private void renderProfile(User user, String baseURI, PrintWriter out, Hash author, Archive archive) throws IOException {
diff --git a/apps/syndie/java/src/net/i2p/syndie/web/ViewBlogServlet.java b/apps/syndie/java/src/net/i2p/syndie/web/ViewBlogServlet.java
index 5d5d780c7..f4c93a392 100644
--- a/apps/syndie/java/src/net/i2p/syndie/web/ViewBlogServlet.java
+++ b/apps/syndie/java/src/net/i2p/syndie/web/ViewBlogServlet.java
@@ -79,6 +79,20 @@ public class ViewBlogServlet extends BaseServlet {
private List getPosts(User user, Archive archive, BlogInfo info, HttpServletRequest req, ThreadIndex index) {
List rv = new ArrayList(1);
if (info == null) return rv;
+
+ String entrySelected = req.getParameter(PARAM_ENTRY);
+ if (entrySelected != null) {
+ // $blogKey/$entryId
+ BlogURI uri = null;
+ if (entrySelected.startsWith("blog://"))
+ uri = new BlogURI(entrySelected);
+ else
+ uri = new BlogURI("blog://" + entrySelected.trim());
+ if (uri.getEntryId() >= 0) {
+ rv.add(uri);
+ return rv;
+ }
+ }
ArchiveIndex aindex = archive.getIndex();
@@ -188,7 +202,7 @@ public class ViewBlogServlet extends BaseServlet {
out.write("\n");
}
- private static final String DEFAULT_GROUP_NAME = "References";
+ public static final String DEFAULT_GROUP_NAME = "References";
private void renderReferences(PrintWriter out, BlogInfo info, BlogInfoData data) throws IOException {
out.write("\n");
if (data != null) {
@@ -207,23 +221,118 @@ public class ViewBlogServlet extends BaseServlet {
out.write("
\n");
for (int j = 0; j < group.size(); j++) {
pn = (PetName)group.get(j);
- out.write("- " + renderLink(pn) + "
\n");
+ out.write("- " + renderLink(info.getKey().calculateHash(), pn) + "
\n");
}
out.write("
\n
\n\n");
}
}
- out.write("\n");
- out.write("
Custom links\n");
- out.write("
\n");
- out.write("
");
+ //out.write("\n");
+ //out.write("
Custom links\n");
+ //out.write("
\n");
+ //out.write("
");
out.write("");
out.write("Secured by
Syndie");
out.write("
\n");
out.write("\n\n");
}
- private String renderLink(PetName pn) {
- return "" + HTMLRenderer.sanitizeString(pn.getName()) + "";
+ /** generate a link for the given petname within the scope of the given blog */
+ public static String renderLink(Hash blogFrom, PetName pn) {
+ StringBuffer buf = new StringBuffer(64);
+ String type = pn.getProtocol();
+ if ("syndieblog".equals(type)) {
+ String loc = pn.getLocation();
+ if (loc != null) {
+ buf.append("");
+ }
+ buf.append(HTMLRenderer.sanitizeString(pn.getName()));
+ if (loc != null) {
+ buf.append("");
+ //buf.append(" \n");
+ }
+ } else if ("syndieblogpost".equals(type)) {
+ String loc = pn.getLocation();
+ if (loc != null) {
+ buf.append("");
+ }
+ buf.append(HTMLRenderer.sanitizeString(pn.getName()));
+ if (loc != null) {
+ buf.append("");
+ }
+ } else if ("syndieblogattachment".equals(type)) {
+ String loc = pn.getLocation();
+ if (loc != null) {
+ int split = loc.lastIndexOf('/');
+ try {
+ int attachmentId = -1;
+ if (split > 0)
+ attachmentId = Integer.parseInt(loc.substring(split+1));
+
+ if (attachmentId < 0) {
+ loc = null;
+ } else {
+ BlogURI post = null;
+ if (loc.startsWith("blog://"))
+ post = new BlogURI(loc.substring(0, split));
+ else
+ post = new BlogURI("blog://" + loc.substring(0, split));
+
+ EntryContainer entry = BlogManager.instance().getArchive().getEntry(post);
+ if (entry != null) {
+ Attachment attachments[] = entry.getAttachments();
+ if (attachmentId < attachments.length) {
+ buf.append("");
+ buf.append(HTMLRenderer.sanitizeString(pn.getName()));
+ buf.append("");
+ } else {
+ loc = null;
+ }
+ } else {
+ loc = null;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ loc = null;
+ }
+ }
+ if (loc == null)
+ buf.append(HTMLRenderer.sanitizeString(pn.getName()));
+ } else if ( ("eepsite".equals(type)) || ("i2p".equals(type)) ||
+ ("website".equals(type)) || ("http".equals(type)) || ("web".equals(type)) ) {
+ String loc = pn.getLocation();
+ if (loc != null) {
+ buf.append("");
+ }
+ buf.append(HTMLRenderer.sanitizeString(pn.getName()));
+ if (loc != null) {
+ buf.append("");
+ }
+ } else {
+ buf.append("");
+ buf.append(HTMLRenderer.sanitizeString(pn.getName())).append("");
+ }
+ return buf.toString();
}
private static final int POSTS_PER_PAGE = 5;
@@ -410,7 +519,7 @@ public class ViewBlogServlet extends BaseServlet {
"}\n" +
".syndieBlogLinkGroup li a {\n" +
" display: block;\n" +
-" width: 100%;\n" +
+//" width: 100%;\n" +
"}\n" +
".syndieBlogLinkGroupName {\n" +
" font-size: 80%;\n" +
diff --git a/history.txt b/history.txt
index c2d67c553..be1277259 100644
--- a/history.txt
+++ b/history.txt
@@ -1,4 +1,9 @@
-$Id: history.txt,v 1.378 2006/01/04 21:48:17 jrandom Exp $
+$Id: history.txt,v 1.379 2006/01/08 15:54:39 jrandom Exp $
+
+2005-01-09 jrandom
+ * Bugfix for a rare SSU error (thanks cervantes!)
+ * More progress on the blog interface, allowing customizable blog-wide
+ links.
2006-01-08 jrandom
* First pass of the new blog interface, though without much of the useful
diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java
index 78f51c017..639c3d3fc 100644
--- a/router/java/src/net/i2p/router/RouterVersion.java
+++ b/router/java/src/net/i2p/router/RouterVersion.java
@@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
- public final static String ID = "$Revision: 1.324 $ $Date: 2006/01/01 12:23:29 $";
+ public final static String ID = "$Revision: 1.325 $ $Date: 2006/01/04 21:48:17 $";
public final static String VERSION = "0.6.1.8";
- public final static long BUILD = 8;
+ public final static long BUILD = 9;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);
diff --git a/router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java b/router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java
index ff2dd703e..e4148ea58 100644
--- a/router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java
+++ b/router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java
@@ -473,6 +473,7 @@ public class OutboundMessageFragments {
// ok, simplest possible thing is to always tack on the bitfields if
List msgIds = peer.getCurrentFullACKs();
+ if (msgIds == null) msgIds = new ArrayList();
List partialACKBitfields = new ArrayList();
peer.fetchPartialACKs(partialACKBitfields);
int piggybackedPartialACK = partialACKBitfields.size();
@@ -482,6 +483,10 @@ public class OutboundMessageFragments {
for (int i = 0; i < fragments; i++) {
if (state.needsSending(i)) {
rv[i] = _builder.buildPacket(state, i, peer, remaining, partialACKBitfields);
+ if (rv[i] == null) {
+ sparseCount++;
+ continue;
+ }
rv[i].setFragmentCount(fragments);
OutNetMessage msg = state.getMessage();
if (msg != null)