First pass at fn-wiki.
diff --git a/infocalypse/__init__.py b/infocalypse/__init__.py
--- a/infocalypse/__init__.py
+++ b/infocalypse/__init__.py
@@ -342,6 +342,8 @@ from infcmds import get_config_info, exe
from fmscmds import execute_fmsread, execute_fmsnotify, get_uri_from_hash
from sitecmds import execute_putsite, execute_genkey
+from wikicmds import execute_wiki
+
from config import read_freesite_cfg
from validate import is_hex_string, is_fms_id
@@ -618,6 +620,23 @@ def infocalypse_putsite(ui_, repo, **opt
execute_putsite(ui_, repo, params)
+def infocalypse_wiki(ui_, repo, **opts):
+ """ View and edit the current repository as a wiki. """
+ if os.getcwd() != repo.root:
+ raise util.Abort("You must be in the repository root directory.")
+
+ subcmds = ('run', 'createconfig')
+ required = sum([bool(opts[cmd]) for cmd in subcmds])
+ if required == 0:
+ raise util.Abort("You must specify either --run or --createconfig.")
+ if required > 1:
+ raise util.Abort("Use either --run or --createconfig.")
+ # hmmmm.... useless copy?
+ params = {'WIKI' : [cmd for cmd in subcmds if opts[cmd]][0],
+ 'HTTP_PORT': opts['http_port'],
+ 'HTTP_BIND': opts['http_bind']}
+ execute_wiki(ui_, repo, params)
+
def infocalypse_genkey(ui_, **opts):
""" Print a new SSK key pair. """
params, dummy = get_config_info(ui_, opts)
@@ -713,6 +732,15 @@ cmdtable = {
+ FCP_OPTS,
"[options]"),
+ "fn-wiki": (infocalypse_wiki,
+ [('', 'run', None, "start a local http server " +
+ "displaying a wiki"),
+ ('', 'createconfig', None, "create default fnwiki.cfg"),
+ ('', 'http_port', 8081, "port for http server"),
+ ('', 'http_bind', 'localhost', "interface http " +
+ "listens on, '' to listen on all"),],
+ "[options]"),
+
"fn-genkey": (infocalypse_genkey,
FCP_OPTS,
"[options]"),
diff --git a/infocalypse/wikicmds.py b/infocalypse/wikicmds.py
new file mode 100644
--- /dev/null
+++ b/infocalypse/wikicmds.py
@@ -0,0 +1,76 @@
+""" Implementation of experiment commands for wikis over freenet.
+
+ Copyright (C) 2009 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
+"""
+
+import os
+import sys
+
+#------------------------------------------------------------
+# REDFLAG: DCI path hacks
+import validate
+ADD_DIR = os.path.join(os.path.dirname(
+ os.path.dirname(os.path.dirname(validate.__file__))),
+ 'clean_piki')
+sys.path.append(ADD_DIR)
+#------------------------------------------------------------
+
+from servepiki import serve_wiki, create_empty_wiki
+
+from mercurial import util
+
+# piki's required files are in that directory.
+import servepiki
+PIKI_WWW_SRC = os.path.dirname(servepiki.__file__)
+
+def execute_wiki(ui_, repo, params):
+ """ Run the wiki command. """
+ def out_func(text):
+ """ Helper displays output from serve_wiki via ui.status. """
+ ui_.status(text + '\n')
+ if params['WIKI'] == 'run':
+ if not os.path.exists(os.path.join(repo.root, 'fnwiki.cfg')):
+ raise util.Abort("Can't read fnwiki.cfg. Did you forget hg " +
+ "fn-wiki --createconfig?")
+ serve_wiki(params['HTTP_PORT'], params['HTTP_BIND'], out_func)
+ return
+
+ # Hmmmm... some basic UI depends on wikitext. not sure
+ # how useful a completely empty wiki is.
+ if params['WIKI'] == 'createconfig':
+ if os.path.exists(os.path.join(repo.root, 'fnwiki.cfg')):
+ raise util.Abort("fnwiki.cfg already exists!")
+
+ if os.path.exists(os.path.join(repo.root, 'wiki_root')):
+ raise util.Abort("The wiki_root subdirectory already exists! " +
+ "Move it out of the way to continue.")
+
+ create_empty_wiki(os.path.join(repo.root, 'wiki_root'), PIKI_WWW_SRC)
+ out = open(os.path.join(repo.root, 'fnwiki.cfg'), 'w')
+ out.write("""[default]
+# fniki.cfg tells piki where to read the wiki data from.
+[default]
+root_dir = wiki_root
+""")
+ out.close()
+ ui_.status("Created fnwiki.cfg and skeleton wiki_root dir.\n")
+ return
+
+ raise util.Abort("Unsupported subcommand: " + params.get('WIKI', 'unknown'))
+