diff --git a/cookbook.py b/cookbook.py
index 73bea49..12cc803 100644
--- a/cookbook.py
+++ b/cookbook.py
@@ -4,6 +4,15 @@ import datetime
import frontmatter
from glob import glob
+import os
+from dotenv import load_dotenv
+from pathlib import Path
+
+dotenv_path = Path("/var/www/mw-env")
+load_dotenv(dotenv_path=dotenv_path)
+
+print(os.environ)
+
# prefix to add /SOUPBOAT/ATLAS-API to all the routes
# and to leave the @app.route() decorator more clean
@@ -52,7 +61,7 @@ def create_recipe(data):
with open(f"recipes/{slug}_{today}.md", "w") as f:
documentation = frontmatter.dumps(post)
f.write(documentation)
- print(f"{slug}_{today}.md - saved in the archive")
+ print(f"{data['title']} - saved in the archive")
# read the files from the recipes folder and return them in a list
@@ -82,7 +91,7 @@ def home():
create_recipe(request.json)
redirect(url_for("home"))
- return "hello"
+ return redirect("https://issue.xpub.nl/18/")
# return the list of recipes in JSON format
diff --git a/testmw.ipynb b/testmw.ipynb
new file mode 100644
index 0000000..db2b4b4
--- /dev/null
+++ b/testmw.ipynb
@@ -0,0 +1,147 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "OrderedDict([('result', 'Success'),\n",
+ " ('pageid', 38082),\n",
+ " ('title', 'Test with the Diffbot'),\n",
+ " ('contentmodel', 'wikitext'),\n",
+ " ('oldrevid', 218752),\n",
+ " ('newrevid', 218753),\n",
+ " ('newtimestamp', '2022-05-31T10:39:36Z')])"
+ ]
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import mwclient\n",
+ "\n",
+ "site = mwclient.Site('pzwiki.wdka.nl', path='/mw-mediadesign/')\n",
+ "site.login(\n",
+ " username='user',\n",
+ " password='pass'\n",
+ ")\n",
+ "page = site.pages['Diffractive Cookbook']\n",
+ "text = page.text()\n",
+ "\n",
+ "text += 'A new edit'\n",
+ "\n",
+ "page.edit(text, 'A new little test')\n",
+ " \n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def wiki_recipe(recipe):\n",
+ " steps = ''\n",
+ " for log in recipe['logs']:\n",
+ " steps+= f'# {log}\\n' \n",
+ "\n",
+ " # PROV TEMPLATE \n",
+ " content = f\"\"\"\n",
+ " === {recipe['title']} ===\n",
+ " ''{recipe['description']}'' \n",
+ "
\n",
+ " '''Nature of the input'''\n",
+ "
\n",
+ " {recipe['nature']}\n",
+ "
\n",
+ " ''' Process Log'''\n",
+ "
\n",
+ " {steps}\n",
+ " '''Who'''\n",
+ "
\n",
+ " {recipe['who']}\n",
+ " \"\"\"\n",
+ " return content"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ " === Test test test ===\n",
+ " ''A super simple description'' \n",
+ "
\n",
+ " '''Nature of the input'''\n",
+ "
\n",
+ " methods\n",
+ "
\n",
+ " ''' Process Log'''\n",
+ "
\n",
+ " # first step\n",
+ "# second step\n",
+ "# third step\n",
+ "\n",
+ " '''Who'''\n",
+ "
\n",
+ " a friend of mine\n",
+ " \n"
+ ]
+ }
+ ],
+ "source": [
+ "r = {\n",
+ " \"title\": \"Test test test\",\n",
+ " \"description\": \"A super simple description\",\n",
+ " \"logs\": [\"first step\", \"second step\", \"third step\"],\n",
+ " \"who\": \"a friend of mine\",\n",
+ " \"nature\": 'methods'\n",
+ "}\n",
+ "\n",
+ "print(wiki_recipe(r))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "interpreter": {
+ "hash": "46172edbb966926a6ca6e2e167d7aaa1e3cb13ab137295bdbeca8b798134a9e0"
+ },
+ "kernelspec": {
+ "display_name": "Python 3.10.2 ('venv': venv)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.2"
+ },
+ "orig_nbformat": 4
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}