|
|
|
@ -75,6 +75,41 @@ def get_recipes():
|
|
|
|
|
return recipes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_wiki(recipe):
|
|
|
|
|
import mwclient
|
|
|
|
|
|
|
|
|
|
site = mwclient.Site('pzwiki.wdka.nl', path='/mw-mediadesign/')
|
|
|
|
|
site.login(
|
|
|
|
|
username=os.environ.get('MW_BOT'),
|
|
|
|
|
password=os.environ.get('MW_KEY')
|
|
|
|
|
)
|
|
|
|
|
page = site.pages['Test form test form test form test']
|
|
|
|
|
|
|
|
|
|
text = page.text()
|
|
|
|
|
|
|
|
|
|
steps = ''
|
|
|
|
|
for log in recipe['logs']:
|
|
|
|
|
steps+= f'# {log}\n'
|
|
|
|
|
|
|
|
|
|
# PROV TEMPLATE
|
|
|
|
|
content = f"""
|
|
|
|
|
=== {recipe['title']} ===
|
|
|
|
|
''{recipe['description']}''
|
|
|
|
|
<br>
|
|
|
|
|
'''Nature of the input'''
|
|
|
|
|
<br>
|
|
|
|
|
{recipe['nature']}
|
|
|
|
|
<br>
|
|
|
|
|
''' Process Log'''
|
|
|
|
|
<br>
|
|
|
|
|
{steps}
|
|
|
|
|
'''Who'''
|
|
|
|
|
<br>
|
|
|
|
|
{recipe['who']}
|
|
|
|
|
"""
|
|
|
|
|
text += content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# sample object to test the md output
|
|
|
|
|
r = {
|
|
|
|
|
"title": "Test test test",
|
|
|
|
@ -89,6 +124,7 @@ r = {
|
|
|
|
|
def home():
|
|
|
|
|
if request.method == "POST":
|
|
|
|
|
create_recipe(request.json)
|
|
|
|
|
update_wiki(request.json)
|
|
|
|
|
redirect(url_for("home"))
|
|
|
|
|
|
|
|
|
|
return redirect("https://issue.xpub.nl/18/")
|
|
|
|
|