site

(djk)
2011-02-20: Use hash of SSK instead of full SSK for version. Doc updates.

Use hash of SSK instead of full SSK for version. Doc updates.

diff --git a/doc/quickstart.txt b/doc/quickstart.txt
--- a/doc/quickstart.txt
+++ b/doc/quickstart.txt
@@ -4,7 +4,8 @@
 == Quick Start ==
 
 ===Configuration===
-# Click on the "View" link below to view (and edit) the configuration.
+# Click on the "View" link below to view (and edit) the configuration. \\
+  //Hint: Open the "View" link in a separate tab or window.//
 # Set the "FMS Name" to the human readable part of your FMS ID (everything before the '@').
 # Set the FMS Private SSK to your private FMS SSK (see below if you don't know how to find this).
 # Adjust any other values as necessary.  If you're running FMS and Fred on the same machine on the default ports this shouldn't be necessary.
@@ -16,10 +17,13 @@ Click the "Discover" link below to searc
 === Submitting ===
 Use the "Submit" link below to submit your changes.  It may take a long time for other people to see them.
 
+=== Known Limitations ===
+# There is no merging or rebasing (yet).
+
+----
 === Finding Your Private SSK ===
 # Go to http://127.0.0.1:18080/localidentities.htm in the FMS web interface and click the "Export Identities" button
 to save your FMS indentities to a file.
-
 # In the text editor of your choice, open the file you saved above and look for the Name and PrivateKey values for the identity you want to use.
 
 In the example identity snippet below, the FMS Name value would be:\\
diff --git a/readme.txt b/readme.txt
--- a/readme.txt
+++ b/readme.txt
@@ -1,4 +1,4 @@
-201102012
+201102020
 djk@isFiaD04zgAgnrEC5XJt1i4IE7AkNPqhBG5bONi6Yks
 
 WARNING:
@@ -33,7 +33,7 @@ Search for "biss.test000" and make sure 
 If you can't find the group, add it.
 
 BUILD:
-Copy freon.jar into ./alien/libs
+Copy freenet.jar into ./alien/libs
 
 run:
 ant jar
@@ -49,29 +49,27 @@ configuration to a file.
 
 Once you've done that you can start the script with the saved configuration. i.e.:
 
-./script/jfniki.sh path_to_your_saved_confess
+./script/jfniki.sh path_to_your_saved_config
 
 will start the stand alone app on the same port you used before.
 
 RUNNING STAND ALONE ON WINDOWS:
 I don't have access to a Windows machine to test on so I didn't write a .bat.
 
-Theseus's from FMS reports that you can run stand alone under Windows by copying freshened.jar
+TheSeeker from FMS reports that you can run stand alone under Windows by copying freenet.jar
 and jfniki.jar into the same directory and running:
 
-java(w) -PP freenet.jar;jfniki.jar fniki.standalone.ServeHttp [jfniki.cfg|port]
+java(w) -cp freenet.jar;jfniki.jar fniki.standalone.ServeHttp [jfniki.cfg|port]
 
-RUN AS A BRENT PLUGIN:
+RUN AS A FREENET PLUGIN:
 Load the jar file from ./build/jar/jfniki.jar
 
 Click on the "View" Configuration link and set the "FMS Private SSK" and "FMS ID" fields.
 
 OTHER DOC:
-See quickstart.txt in this directory (The default page when an empty wiki is displayed).
+See quickstart.txt in the doc directory (The default page when an empty wiki is displayed).
 
 KNOWN ISSUES:
 o "Cancel" sometimes fails. [WORKAROUND: load and unload the plugin / kill restart the stand alone app.]
 o FMS Id displays "???" when importing config with non-default FCP host and/or port.
   [WORKAROUND: Click "Done", then click view again and the FMS Id should be correctly displayed.]
-
- LocalWords:  SSK jfniki cfg PLUGIN quickstart
diff --git a/src/fniki/wiki/ArchiveManager.java b/src/fniki/wiki/ArchiveManager.java
--- a/src/fniki/wiki/ArchiveManager.java
+++ b/src/fniki/wiki/ArchiveManager.java
@@ -328,7 +328,7 @@ public class ArchiveManager {
         return mOverlay;
     }
 
-    public String getNym(String sskRequestUri) {
+    public String getNym(String sskRequestUri, boolean showPublicKey) {
         int start = sskRequestUri.indexOf("@");
         int end = sskRequestUri.indexOf(",");
         if (start == -1 || end == -1 || start >= end) {
@@ -340,8 +340,11 @@ public class ArchiveManager {
         // SSK@THIS_PART,
         String nym = mNymLut.get(publicKeyHash);
         if (nym == null) {
-            return "???";
+            nym = "???";
         }
-        return nym;
+        if (!showPublicKey) {
+            return nym;
+        }
+        return nym + "@" + publicKeyHash;
     }
 }
\ No newline at end of file
diff --git a/src/fniki/wiki/HtmlUtils.java b/src/fniki/wiki/HtmlUtils.java
--- a/src/fniki/wiki/HtmlUtils.java
+++ b/src/fniki/wiki/HtmlUtils.java
@@ -24,6 +24,7 @@
 
 package fniki.wiki;
 
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 
@@ -35,6 +36,7 @@ import java.util.Set;
 import static ys.wikiparser.Utils.*;
 
 import wormarc.FileManifest;
+import wormarc.IOUtil;
 
 public class HtmlUtils {
 
@@ -137,10 +139,30 @@ public class HtmlUtils {
         return String.format(fmt, makeHref(fullPath), escapeHTML(label), escapeHTML(action));
     }
 
-    public static String getVersionLink(String prefix, String name, String uri, String action) {
+    public static String getVersionHex(String uri) {
+        try {
+            if (uri == null) {
+                return "???";
+            }
+            return IOUtil.getFileDigest(IOUtil.toStreamAsUtf8(uri)).hexDigest(8);
+        } catch (IOException ioe) {
+            return "???";
+        }
+    }
+
+    public static String getVersionLink(String prefix, String name, String uri, String action,
+                                        boolean hexLabel) {
+        String label = uri;
+        if (hexLabel) {
+            label = getVersionHex(uri);
+        }
         String href = makeHref(prefix + name, action, null, uri, null);
 
-        return String.format("<a href=\"%s\">%s</a>", href, escapeHTML(uri));
+        return String.format("<a href=\"%s\">%s</a>", href, escapeHTML(label));
+    }
+
+    public static String getVersionLink(String prefix, String name, String uri, String action) {
+        return  getVersionLink(prefix, name, uri, action, false);
     }
 
     // Hmmmm...
@@ -148,6 +170,10 @@ public class HtmlUtils {
         return getVersionLink(prefix, name, uri, "finished");
     }
 
+    public static String getShortVersionLink(String prefix, String name, String uri) {
+        return getVersionLink(prefix, name, uri, "finished", true);
+    }
+
     public static String gotoPageFormHtml(String basePath, String defaultPage) {
         final String fmt =
             "<form method=\"get\" action=\"%s\" accept-charset=\"UTF-8\"> \n" +
diff --git a/src/fniki/wiki/child/LoadingArchive.java b/src/fniki/wiki/child/LoadingArchive.java
--- a/src/fniki/wiki/child/LoadingArchive.java
+++ b/src/fniki/wiki/child/LoadingArchive.java
@@ -95,12 +95,18 @@ public class LoadingArchive extends Asyn
             body.println("<html><head>" + metaRefresh() + "<title>" + escapeHTML(title) + "</title></head><body>");
 
             if (getState() == STATE_WORKING || getState() == STATE_SUCCEEDED) {
-                title = "Loading Archive:"; // Don't put full uri in header
+                if (getState() == STATE_WORKING) {
+                    title = "Loading Archive:"; // Don't put full uri in header
+                } else {
+                    title = "Loaded Archive.";
+                }
             }
             body.println("<h3>" + escapeHTML(title) + "</h3>");
             if (showUri) {
-                body.println(escapeHTML(mUri));
-                body.println("<p/>Clicking Load will discard any unsubmitted local changes.</p>");
+                body.println(escapeHTML("Load Version: " + getVersionHex(mUri)));
+                body.println("<br>");
+                body.println(escapeHTML("from: " + mUri));
+                body.println("<p>Clicking Load will discard any unsubmitted local changes.</p>");
             } else if (getState() == STATE_WORKING || getState() == STATE_SUCCEEDED) {
                 body.println(escapeHTML(mUri));
             }
diff --git a/src/fniki/wiki/child/LoadingChangeLog.java b/src/fniki/wiki/child/LoadingChangeLog.java
--- a/src/fniki/wiki/child/LoadingChangeLog.java
+++ b/src/fniki/wiki/child/LoadingChangeLog.java
@@ -143,10 +143,10 @@ public class LoadingChangeLog extends As
                                               FileManifest.Changes fromNewToOld) {
 
         mListHtml.append("<br>");
+        mListHtml.append(getShortVersionLink(mContainerPrefix, "/jfniki/changelog", oldVer.mExternalKey));
+        mListHtml.append("<br>\n");
         mListHtml.append("FmsID: ");
-        mListHtml.append(escapeHTML(mArchiveManager.getNym(oldVer.mExternalKey)));
-        mListHtml.append("<br>");
-        mListHtml.append(getVersionLink(mContainerPrefix, "/jfniki/changelog", oldVer.mExternalKey));
+        mListHtml.append(escapeHTML(mArchiveManager.getNym(oldVer.mExternalKey, true)));
         mListHtml.append("<br>\n");
         appendChangesHtml(fromNewToOld, mContainerPrefix, mListHtml);
         return true;
diff --git a/src/fniki/wiki/child/LoadingVersionList.java b/src/fniki/wiki/child/LoadingVersionList.java
--- a/src/fniki/wiki/child/LoadingVersionList.java
+++ b/src/fniki/wiki/child/LoadingVersionList.java
@@ -37,7 +37,6 @@ import fmsutil.FMSUtil;
 import wormarc.ExternalRefs;
 import wormarc.FileManifest;
 
-
 import fniki.wiki.ArchiveManager;
 import fniki.wiki.ChildContainer;
 import fniki.wiki.ChildContainerException;
@@ -147,6 +146,23 @@ public class LoadingVersionList extends 
         return Integer.toString(value);
     }
 
+    public static String getParentVersion(FMSUtil.BISSRecord record) {
+        if (record.mKey == null) {
+            return "???";
+        }
+        String[] fields = record.mKey.split("/");
+        if (fields.length != 2) {
+            return "???";
+        }
+
+        fields = fields[1].split("_");
+        if (fields.length != 2) { // LATER. handle multiple parents
+            return "???";
+        }
+
+        return fields[1];
+    }
+
     public boolean doWork(PrintStream out) throws Exception {
         synchronized (this) {
             mListHtml = new StringBuilder();
@@ -158,10 +174,11 @@ public class LoadingVersionList extends 
             synchronized (this) {
 
                 mListHtml.append("<table border=\"1\">\n");
-                mListHtml.append("<tr><td>FMS ID</td><td>Date</td><td>Key</td><td>Msg Trust</td><td>TL Trust</td>" +
+                mListHtml.append("<tr><td>FMS ID</td><td>Date</td><td>Version</td><td>Parent</td>" +
+                                 "<td>Msg Trust</td><td>TL Trust</td>" +
                                  "<td>Peer Msg Trust</td><td>Peer TL Trust</td></tr>\n");
 
-                final String fmt = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>" +
+                final String fmt = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>" +
                 "<td>%s</td><td>%s</td></tr>\n";
 
                 // DCI: BUG. fix to force finished
@@ -169,8 +186,9 @@ public class LoadingVersionList extends 
                     mListHtml.append(String.format(fmt,
                                                    escapeHTML(record.mFmsId),
                                                    escapeHTML(record.mDate),
-                                                   getVersionLink(mContainerPrefix,
+                                                   getShortVersionLink(mContainerPrefix,
                                                                   "/jfniki/loadarchive", record.mKey),
+                                                   escapeHTML(getParentVersion(record)),
                                                    trustString(record.msgTrust()),
                                                    trustString(record.trustListTrust()),
                                                    trustString(record.peerMsgTrust()),
diff --git a/src/fniki/wiki/child/WikiContainer.java b/src/fniki/wiki/child/WikiContainer.java
--- a/src/fniki/wiki/child/WikiContainer.java
+++ b/src/fniki/wiki/child/WikiContainer.java
@@ -187,9 +187,9 @@ public class WikiContainer implements Ch
 
     private void addFooter(WikiContext context, String name, StringBuilder buffer) throws IOException {
         buffer.append("<hr>\n");
-        buffer.append("Parent Version:<br>");
+        buffer.append("Parent Version: ");
         // DCI: css class to make this smaller.
-        String version = context.getString("parent_uri", "None");
+        String version = getVersionHex(context.getString("parent_uri", null));
         buffer.append(escapeHTML(version));
         buffer.append("<hr>\n");