Added a link to create an empty wiki.
diff --git a/src/fniki/wiki/WikiApp.java b/src/fniki/wiki/WikiApp.java
--- a/src/fniki/wiki/WikiApp.java
+++ b/src/fniki/wiki/WikiApp.java
@@ -46,6 +46,7 @@ import fniki.wiki.child.LoadingArchive;
import fniki.wiki.child.LoadingChangeLog;
import fniki.wiki.child.LoadingVersionList;
import fniki.wiki.child.QueryError;
+import fniki.wiki.child.ResetToEmptyWiki;
import fniki.wiki.child.SettingConfig;
import fniki.wiki.child.Submitting;
import fniki.wiki.child.WikiContainer;
@@ -81,6 +82,7 @@ public class WikiApp implements ChildCon
private final ChildContainer mGotoRedirect;
private final ChildContainer mQueryError;
private final ChildContainer mWikiContainer;
+ private final ChildContainer mResetToEmptyWiki;
// ChildContainers for modal UI states.
private final ChildContainer mSettingConfig;
@@ -118,6 +120,7 @@ public class WikiApp implements ChildCon
mGotoRedirect = new GotoRedirect();
mQueryError = new QueryError();
mWikiContainer = new WikiContainer();
+ mResetToEmptyWiki = new ResetToEmptyWiki(archiveManager);
mSettingConfig = new SettingConfig();
mLoadingVersionList = new LoadingVersionList(archiveManager);
@@ -237,6 +240,8 @@ public class WikiApp implements ChildCon
return setState(request, mLoadingVersionList);
} else if (path.equals("fniki/loadarchive")) {
return setState(request, mLoadingArchive);
+ } else if (path.equals("fniki/resettoempty")) {
+ return setState(request, mResetToEmptyWiki);
} else if (path.equals("")) {
return mDefaultRedirect;
} else if (slashCount != 0) {
diff --git a/src/fniki/wiki/child/ResetToEmptyWiki.java b/src/fniki/wiki/child/ResetToEmptyWiki.java
new file mode 100644
--- /dev/null
+++ b/src/fniki/wiki/child/ResetToEmptyWiki.java
@@ -0,0 +1,54 @@
+/* A UI subcomponent which resets the wiki to its empty state.
+ *
+ * Copyright (C) 2010, 2011 Darrell Karbott
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: djk@isFiaD04zgAgnrEC5XJt1i4IE7AkNPqhBG5bONi6Yks
+ *
+ * This file was developed as component of
+ * "fniki" (a wiki implementation running over Freenet).
+ */
+
+package fniki.wiki.child;
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+import fniki.wiki.ArchiveManager;
+import fniki.wiki.ChildContainer;
+import fniki.wiki.ChildContainerException;
+import fniki.wiki.ServerErrorException;
+import fniki.wiki.WikiContext;
+
+public class ResetToEmptyWiki implements ChildContainer {
+ private final ArchiveManager mArchiveManager;
+ public ResetToEmptyWiki(ArchiveManager archiveManager) {
+ mArchiveManager = archiveManager;
+ }
+
+ public String handle(WikiContext context) throws ChildContainerException {
+ try {
+ mArchiveManager.createEmptyArchive();
+ } catch (IOException ioe) {
+ throw new ServerErrorException("Unexpected error calling mArchiveManager.createEmptyArchive()");
+ }
+
+ context.raiseRedirect(context.makeLink("/" + context.getString("default_page", "Front_Page")),
+ "Redirecting...");
+
+ return "unreachable code";
+ }
+}
\ No newline at end of file
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
@@ -220,6 +220,9 @@ public class WikiContainer implements Ch
buffer.append(makeLocalLink(context, "fniki/config", "view", "View"));
buffer.append(" configuration.<p/>\n");
+ buffer.append(makeLocalLink(context, "fniki/resettoempty", "view", "Create Wiki!"));
+ buffer.append(" (<em>careful:</em> This deletes all content and history without confirmation.)<p/>\n");
+
buffer.append(gotoPageFormHtml(context.makeLink("/" + name),
context.getString("default_page", "Front_Page")));