diff --git a/etherdump/commands/appendmeta.py b/etherdump/commands/appendmeta.py new file mode 100644 index 0000000..03e505f --- /dev/null +++ b/etherdump/commands/appendmeta.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +from __future__ import print_function +from argparse import ArgumentParser +import json, os + +def main(args): + p = ArgumentParser("") + p.add_argument("input", nargs="+", help="filenames") + p.add_argument("--indent", type=int, default=2, help="indent") + args = p.parse_args(args) + inputs = args.input + inputs.sort() + ret = [] + for p in inputs: + with open(p) as f: + meta = json.load(f) + ret.append(meta) + + if args.indent: + print (json.dumps(ret, indent=args.indent)) + else: + print (json.dumps(ret)) diff --git a/etherdump/commands/common.py b/etherdump/commands/common.py index 90a21fd..819730d 100644 --- a/etherdump/commands/common.py +++ b/etherdump/commands/common.py @@ -11,6 +11,9 @@ def splitpadname (padid): else: return (u"", padid) +def padurl (padid, ): + return padid + def padpath (padid, pub_path=u"", group_path=u""): g, p = splitpadname(padid) if type(g) == unicode: diff --git a/etherdump/commands/index.py b/etherdump/commands/index.py new file mode 100644 index 0000000..4d5af65 --- /dev/null +++ b/etherdump/commands/index.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +from __future__ import print_function +from argparse import ArgumentParser +import json, os, re +from urllib import urlencode +from urllib2 import urlopen, HTTPError, URLError +from jinja2 import FileSystemLoader, Environment + +def group (items, key=lambda x: x): + ret = [] + keys = {} + for item in items: + k = key(item) + if k not in keys: + keys[k] = [] + keys[k].append(item) + for k in sorted(keys): + keys[k].sort() + ret.append(keys[k]) + return ret + +def main(args): + p = ArgumentParser("") + p.add_argument("input", nargs="+", help="filenames") + p.add_argument("--templates", default=None, help="templates path") + args = p.parse_args(args) + + tmpath = args.templates + if tmpath == None: + tmpath = os.path.split(os.path.abspath(__file__))[0] + tmpath = os.path.split(tmpath)[0] + tmpath = os.path.join(tmpath, "data", "templates") + + env = Environment(loader=FileSystemLoader(tmpath)) + template = env.get_template("pad_index.html") + + inputs = args.input + inputs.sort() + inputs = [x for x in inputs if os.path.isdir(x)] + + def base (x): + return re.sub(r"(\.html)|(\.diff\.html)|(\.meta\.json)|(\.txt)$", "", x) + + # TODO: MODIFY THIS TO MAKE THE OUTPUT JOINABLE with the collected META DATA + # evt: how can the metadata become a GRAPH structure!!! with each output DOCUMENT + # + print ("
    ") + for x in inputs: + padid = x + metapath = os.path.join(x, "{0}.meta.json".format(padid)) + if os.path.exists(metapath): + print ("""
  1. {0}
  2. """.format(x)) + with open(metapath) as f: + meta = json.load(f) + indexpath = os.path.join(x, "index.html") + with open(indexpath, "w") as f: + print (template.render(**meta).encode("utf-8"), file=f) + + print ("
") diff --git a/etherdump/commands/pull.py b/etherdump/commands/pull.py index 55985bc..b78df0f 100644 --- a/etherdump/commands/pull.py +++ b/etherdump/commands/pull.py @@ -14,6 +14,11 @@ pull(meta): Update meta data files for those that have changed. Check for changed pads by looking at revisions & comparing to existing + +todo... +use/prefer public interfaces ? (export functions) + + """ def main (args): @@ -29,6 +34,9 @@ def main (args): p.add_argument("--html", default=False, action="store_true", help="download html to PADID.html, default: False") p.add_argument("--dhtml", default=False, action="store_true", help="download dhtml to PADID.dhtml, default: False") p.add_argument("--all", default=False, action="store_true", help="download all files (meta, text, html, dhtml), default: False") + p.add_argument("--folder", default=False, action="store_true", help="dump files to folder named PADID (meta, text, html, dhtml), default: False") + p.add_argument("--output", default=False, action="store_true", help="output changed padids on stdout") + p.add_argument("--force", default=False, action="store_true", help="reload, even if revisions count matches previous") args = p.parse_args(args) info = loadpadinfo(args.padinfo) @@ -44,27 +52,51 @@ def main (args): # maxmsglen = 0 count = 0 for i, padid in enumerate(padids): + # TODO... + """ +Self-containted documents / and/or document receipts +storing enough information to reconstruct (or understand an error occurred) + """ + + if args.skip != None and i + + + + + + +
+ +
+
+ versions +
+ + + + + + + + +
padid{{padid}}
lastedited{{lastedited_iso}}
revisions{{revisions}}
versions + +
+
+ + + +