settext and other tweaks
This commit is contained in:
parent
423832f125
commit
90bdde07ba
27
README.md
27
README.md
@ -7,13 +7,14 @@ Tool to publish [etherpad](http://etherpad.org/) pages to files.
|
||||
Requirements
|
||||
-------------
|
||||
|
||||
python-dateutil, html5lib
|
||||
* html5lib
|
||||
* python-datutil, jinja2 (index subcommand)
|
||||
|
||||
|
||||
Installation
|
||||
-------------
|
||||
|
||||
pip install python-dateutil html5lib
|
||||
pip install python-dateutil jinja2 html5lib
|
||||
python setup.py install
|
||||
|
||||
Example
|
||||
@ -45,24 +46,20 @@ subcommands
|
||||
* gethtml
|
||||
* creatediffhtml
|
||||
* revisionscount
|
||||
* index
|
||||
|
||||
To get help on a subcommand:
|
||||
|
||||
etherdump revisionscount --help
|
||||
|
||||
file sync
|
||||
----------
|
||||
epfs?
|
||||
pad to file
|
||||
|
||||
etherdump init http://localhost:9001/ --path foo
|
||||
etherdump status
|
||||
compare state of files to etherpad & report
|
||||
etherdump pull <padid/path>
|
||||
etherdump sync
|
||||
push / pull file contents to pad
|
||||
Change log / notes
|
||||
=======================
|
||||
|
||||
why
|
||||
-------
|
||||
Etherdump is useful as a means of dumping the contents of etherpad to files, as a way of opening up the contents of the service to other services / methods / uses / tools / situations. (Files also of course allow for archival tools / methods)
|
||||
Originally designed for use at: [constant](http://etherdump.constantvzw.org/).
|
||||
|
||||
|
||||
17 Oct 2016
|
||||
-----------------------------------------------
|
||||
Preparations for [Machine Research](https://machineresearch.wordpress.com/) [2](http://constantvzw.org/site/Machine-Research,2646.html)
|
||||
|
||||
|
33
etherdump/commands/deletepad.py
Normal file
33
etherdump/commands/deletepad.py
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import json
|
||||
from urllib import urlencode
|
||||
from urllib2 import urlopen, HTTPError, URLError
|
||||
|
||||
|
||||
def main(args):
|
||||
p = ArgumentParser("calls the getText API function for the given padid")
|
||||
p.add_argument("padid", help="the padid")
|
||||
p.add_argument("--padinfo", default=".etherdump/settings.json", help="settings, default: .etherdump/settings.json")
|
||||
p.add_argument("--showurl", default=False, action="store_true")
|
||||
p.add_argument("--format", default="text", help="output format, can be: text, json; default: text")
|
||||
args = p.parse_args(args)
|
||||
|
||||
with open(args.padinfo) as f:
|
||||
info = json.load(f)
|
||||
apiurl = info.get("apiurl")
|
||||
# apiurl = "{0[protocol]}://{0[hostname]}:{0[port]}{0[apiurl]}{0[apiversion]}/".format(info)
|
||||
data = {}
|
||||
data['apikey'] = info['apikey']
|
||||
data['padID'] = args.padid # is utf-8 encoded
|
||||
requesturl = apiurl+'deletePad?'+urlencode(data)
|
||||
if args.showurl:
|
||||
print requesturl
|
||||
else:
|
||||
results = json.load(urlopen(requesturl))
|
||||
if args.format == "json":
|
||||
print json.dumps(results)
|
||||
else:
|
||||
if results['data']:
|
||||
print results['data']['text'].encode("utf-8")
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import json
|
||||
import json, sys
|
||||
from urllib import urlencode
|
||||
from urllib2 import urlopen, HTTPError, URLError
|
||||
|
||||
@ -28,8 +28,9 @@ def main(args):
|
||||
if args.showurl:
|
||||
print requesturl
|
||||
else:
|
||||
results = json.load(urlopen(requesturl))['data']
|
||||
results = json.load(urlopen(requesturl))
|
||||
if args.format == "json":
|
||||
print json.dumps(results)
|
||||
else:
|
||||
print results['text'].encode("utf-8")
|
||||
if results['data']:
|
||||
sys.stdout.write(results['data']['text'].encode("utf-8"))
|
||||
|
@ -43,7 +43,7 @@ def main (args):
|
||||
p.add_argument("--meta", default=False, action="store_true", help="download meta to PADID.meta.json, default: False")
|
||||
p.add_argument("--text", default=False, action="store_true", help="download text to PADID.txt, default: False")
|
||||
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("--dhtml", default=False, action="store_true", help="download dhtml to PADID.diff.html, 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 in a folder named PADID (meta, text, html, dhtml), default: False")
|
||||
p.add_argument("--output", default=False, action="store_true", help="output changed padids on stdout")
|
||||
|
49
etherdump/commands/settext.py
Normal file
49
etherdump/commands/settext.py
Normal file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import json, sys
|
||||
from urllib import urlencode
|
||||
from urllib2 import urlopen, HTTPError, URLError
|
||||
|
||||
|
||||
def main(args):
|
||||
p = ArgumentParser("calls the getText API function for the given padid")
|
||||
p.add_argument("padid", help="the padid")
|
||||
p.add_argument("--text", default=None, help="text, default: read from stdin")
|
||||
p.add_argument("--padinfo", default=".etherdump/settings.json", help="settings, default: .etherdump/settings.json")
|
||||
p.add_argument("--showurl", default=False, action="store_true")
|
||||
p.add_argument("--format", default="text", help="output format, can be: text, json; default: text")
|
||||
p.add_argument("--create", default=False, action="store_true", help="flag to create pad if necessary")
|
||||
args = p.parse_args(args)
|
||||
|
||||
with open(args.padinfo) as f:
|
||||
info = json.load(f)
|
||||
apiurl = info.get("apiurl")
|
||||
# apiurl = "{0[protocol]}://{0[hostname]}:{0[port]}{0[apiurl]}{0[apiversion]}/".format(info)
|
||||
data = {}
|
||||
data['apikey'] = info['apikey']
|
||||
data['padID'] = args.padid # is utf-8 encoded
|
||||
|
||||
createPad = False
|
||||
if args.create:
|
||||
requesturl = apiurl+'getRevisionsCount?'+urlencode(data)
|
||||
results = json.load(urlopen(requesturl))
|
||||
# print json.dumps(results, indent=2)
|
||||
if results['code'] != 0:
|
||||
createPad = True
|
||||
if args.text:
|
||||
text = args.text
|
||||
else:
|
||||
text = sys.stdin.read()
|
||||
data['text'] = text
|
||||
|
||||
if createPad:
|
||||
requesturl = apiurl+'createPad?'+urlencode(data)
|
||||
else:
|
||||
requesturl = apiurl+'setText?'+urlencode(data)
|
||||
|
||||
if args.showurl:
|
||||
print requesturl
|
||||
else:
|
||||
results = json.load(urlopen(requesturl))
|
||||
print json.dumps(results, indent=2)
|
Loading…
Reference in New Issue
Block a user