|
@ -208,8 +208,9 @@ async def handle_pad(args, padid, data, info, session): |
|
|
while True: |
|
|
while True: |
|
|
try: |
|
|
try: |
|
|
if os.path.exists(metapath): |
|
|
if os.path.exists(metapath): |
|
|
with open(metapath) as f: |
|
|
async with await trio.open_file(metapath) as f: |
|
|
meta.update(json.load(f)) |
|
|
contents = await f.read() |
|
|
|
|
|
meta.update(json.loads(contents)) |
|
|
url = ( |
|
|
url = ( |
|
|
info['localapiurl'] + 'getRevisionsCount?' + urlencode(data) |
|
|
info['localapiurl'] + 'getRevisionsCount?' + urlencode(data) |
|
|
) |
|
|
) |
|
@ -328,8 +329,8 @@ async def handle_pad(args, padid, data, info, session): |
|
|
|
|
|
|
|
|
ver["path"] = p + raw_ext |
|
|
ver["path"] = p + raw_ext |
|
|
ver["url"] = quote(ver["path"]) |
|
|
ver["url"] = quote(ver["path"]) |
|
|
with open(ver["path"], "w") as f: |
|
|
async with await trio.open_file(ver["path"], "w") as f: |
|
|
f.write(text) |
|
|
await f.write(text) |
|
|
# once the content is settled, compute a hash |
|
|
# once the content is settled, compute a hash |
|
|
# and link it in the metadata! |
|
|
# and link it in the metadata! |
|
|
|
|
|
|
|
@ -405,7 +406,7 @@ async def handle_pad(args, padid, data, info, session): |
|
|
scripts=args.script, |
|
|
scripts=args.script, |
|
|
links=links, |
|
|
links=links, |
|
|
) |
|
|
) |
|
|
with open(ver["path"], "w") as f: |
|
|
async with await trio.open_file(ver["path"], "w") as f: |
|
|
print( |
|
|
print( |
|
|
ET.tostring(doc, method="html", encoding="unicode"), |
|
|
ET.tostring(doc, method="html", encoding="unicode"), |
|
|
file=f, |
|
|
file=f, |
|
@ -430,7 +431,7 @@ async def handle_pad(args, padid, data, info, session): |
|
|
html5tidy( |
|
|
html5tidy( |
|
|
doc, indent=True, title=padid, scripts=args.script, links=links, |
|
|
doc, indent=True, title=padid, scripts=args.script, links=links, |
|
|
) |
|
|
) |
|
|
with open(ver["path"], "w") as f: |
|
|
async with await trio.open_file(ver["path"], "w") as f: |
|
|
print( |
|
|
print( |
|
|
ET.tostring(doc, method="html", encoding="unicode"), file=f, |
|
|
ET.tostring(doc, method="html", encoding="unicode"), file=f, |
|
|
) |
|
|
) |
|
@ -441,8 +442,8 @@ async def handle_pad(args, padid, data, info, session): |
|
|
versions.append(ver) |
|
|
versions.append(ver) |
|
|
ver["path"] = metapath |
|
|
ver["path"] = metapath |
|
|
ver["url"] = quote(metapath) |
|
|
ver["url"] = quote(metapath) |
|
|
with open(metapath, "w") as f: |
|
|
async with await trio.open_file(metapath, "w") as f: |
|
|
json.dump(meta, f, indent=2) |
|
|
await f.write(json.dumps(meta)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def handle_pad_chunk(args, padids, data, info, session): |
|
|
async def handle_pad_chunk(args, padids, data, info, session): |
|
|