next driver
This commit is contained in:
parent
ff301b5e3f
commit
b0f4a7e460
4
cron.sh
4
cron.sh
@ -1,10 +1,10 @@
|
|||||||
# This will pump all the pads with a __PUBLISH__ tag into a folder "publish" as meta.json, txt, html and dhtml
|
# This will pump all the pads with a __PUBLISH__ tag into a folder "publish" as meta.json, txt, html and dhtml
|
||||||
poetry run etherpump pull --meta --html --text --publish-opt-in --publish __PUBLISH__ --pub publish --css ../stylesheet.css --fix-names
|
etherpump pull --meta --html --text --publish-opt-in --publish __PUBLISH__ --pub publish --css ../stylesheet.css --fix-names
|
||||||
|
|
||||||
echo "Making the Etherpump index now ..."
|
echo "Making the Etherpump index now ..."
|
||||||
|
|
||||||
# This will make an index for the dump
|
# This will make an index for the dump
|
||||||
poetry run etherpump index input \
|
etherpump index input \
|
||||||
publish/*.meta.json \
|
publish/*.meta.json \
|
||||||
--templatepath templates \
|
--templatepath templates \
|
||||||
--title "Notes, __MAGICWORDS__, readers & more ..." \
|
--title "Notes, __MAGICWORDS__, readers & more ..." \
|
||||||
|
@ -171,7 +171,7 @@ def build_argument_parser(args):
|
|||||||
help="ensure `--publish` is honoured instead of `--nopublish`",
|
help="ensure `--publish` is honoured instead of `--nopublish`",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--magic-words",
|
"--magicwords",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="store all magic words used in a page in the meta.json file",
|
help="store all magic words used in a page in the meta.json file",
|
||||||
@ -375,7 +375,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
|
|
||||||
|
|
||||||
# include magic words
|
# include magic words
|
||||||
if args.magic_words:
|
if args.magicwords:
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
## INCLUDE __XXX__ MAGIC WORDS
|
## INCLUDE __XXX__ MAGIC WORDS
|
||||||
@ -383,6 +383,7 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
pattern = r'__[a-zA-Z0-9]+?__'
|
pattern = r'__[a-zA-Z0-9]+?__'
|
||||||
magic_words = re.findall(pattern, text)
|
magic_words = re.findall(pattern, text)
|
||||||
if magic_words:
|
if magic_words:
|
||||||
|
meta["magicwords"] = magic_words
|
||||||
print('FOUND MAGIC WORD(s): {} in {}'.format(magic_words, padid))
|
print('FOUND MAGIC WORD(s): {} in {}'.format(magic_words, padid))
|
||||||
|
|
||||||
links = []
|
links = []
|
||||||
@ -495,6 +496,33 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
# except Exception as exception:
|
# except Exception as exception:
|
||||||
# print("PANIC: {}".format(exception))
|
# print("PANIC: {}".format(exception))
|
||||||
|
|
||||||
|
if args.all or args.magicwords:
|
||||||
|
url = info["localapiurl"] + "getHTML?" + "padID=" + padid + "&" + 'apikey=' + data["apikey"]
|
||||||
|
# print(url)
|
||||||
|
html = await agetjson(session, url)
|
||||||
|
ver = {"type": "magicwords"}
|
||||||
|
versions.append(ver)
|
||||||
|
# mb: warning, HACK! Added a Try and Except here, as it sometimes bumped into an error, stopping the pull.
|
||||||
|
# try:
|
||||||
|
ver["code"] = html["_code"]
|
||||||
|
if html["_code"] == 200:
|
||||||
|
try:
|
||||||
|
html = html["data"]["html"]
|
||||||
|
ver["path"] = p + ".magicwords.html"
|
||||||
|
ver["url"] = quote(ver["path"])
|
||||||
|
doc = html5lib.parse(
|
||||||
|
html, treebuilder="etree", namespaceHTMLElements=False
|
||||||
|
)
|
||||||
|
# INSERT MAGIC WORDS HIGHLIGHTING STUFF HERE!!!
|
||||||
|
html5tidy(
|
||||||
|
doc, indent=True, title=padid, scripts=args.script, links=links,
|
||||||
|
)
|
||||||
|
async with await trio.open_file(ver["path"], "w") as f:
|
||||||
|
output = ET.tostring(doc, method="html", encoding="unicode")
|
||||||
|
await f.write(output)
|
||||||
|
except TypeError:
|
||||||
|
ver["message"] = html["message"]
|
||||||
|
|
||||||
# output meta
|
# output meta
|
||||||
if args.all or args.meta:
|
if args.all or args.meta:
|
||||||
ver = {"type": "meta"}
|
ver = {"type": "meta"}
|
||||||
|
Loading…
Reference in New Issue
Block a user