From 3752d4cc55beac172e2f39a2cbab4e68b5ca9477 Mon Sep 17 00:00:00 2001 From: kamo Date: Fri, 13 May 2022 17:34:30 +0100 Subject: [PATCH] First prototype --- .gitignore | 1 + README.md | 33 +++++++++++++ archive.json | 1 + static/style.css | 100 ++++++++++++++++++++++++++++++++++++++ templates/add.html | 18 +++++++ templates/home.html | 42 ++++++++++++++++ workinon.py | 115 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 310 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 archive.json create mode 100644 static/style.css create mode 100644 templates/add.html create mode 100644 templates/home.html create mode 100644 workinon.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..763513e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ipynb_checkpoints diff --git a/README.md b/README.md new file mode 100644 index 0000000..31d8746 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# WORKINON +A small and shared archive to keep track of how ideas change during work, research and development +A call to share what we are doing with others, while we are doing it. +In a way that doesn't focus on results, but on process and sharing. + +## How does it work +The core of Workinon is a small API that read and write updates to a JSON file. +The inputs can be received through a form from the application page. + +## Structure of the JSON: +a list of projects, and each update has a codename and a list of steps +(since this is a first prototype this could change anytime) +(it's already changed 3 times while writing this initial documentation ah ah) + +`JSON +{ + "Workin title of the project or idea": [ + { + "when": "13.05.2022", + "what": "First idea of the project" + }, + ] + } +` + +To insert a new project just send in the first step and a name +to update with a new step just refer to the name you used the first time and add the new step + +this structure is not super robust. +if two different project use the same codename, this could lead to interferences between the two +so one suggestion for the usage of the Workinon could be to choose a really really really personal title + + diff --git a/archive.json b/archive.json new file mode 100644 index 0000000..9cd82ca --- /dev/null +++ b/archive.json @@ -0,0 +1 @@ +{"workinon": [{"when": "13.05.2022", "what": "First prototype for a small and shared archive to keep track of how ideas change during work, research and development"}, {"when": "13.05.2022", "what": "Little API to read and write new updates for projects"}, {"when": "13.05.2022", "what": "JSON test"}, {"when": "13.05.2022", "what": "JSON test and redirect"}], "k-pub": [{"when": "21.10.2021", "what": "Using karaoke as a form of republishing"}, {"when": "13.05.2022", "what": "test test it;'s a est"}], "mod cms": [{"when": "13.05.2022", "what": "store synth configurations to build a workbook"}]} \ No newline at end of file diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..ff78448 --- /dev/null +++ b/static/style.css @@ -0,0 +1,100 @@ +* { + box-sizing: border-box; + max-width: 60ch; +} + +html, body { + font-family: sans-serif; + font-size: 24px; + line-height: 1.5; + color: #3D9970; + max-width: 100%; + + margin: 12px; +} + + +h1 { + margin-top: 0; +} + +h2, h3 { + margin: 0; +} + +form { + width: 40ch; + display: inline-block; + margin: 64px 0; + padding: 16px; + border: 1px dashed currentColor; +} + +form > * + * { + margin-top: 16px; +} + +input, textarea { + display: block; + border: 1px solid currentColor; + color: currentColor; + padding: 8px; + background: none; +} + +input[type="submit"]{ + cursor: pointer; +} + + +input[type="submit"]:hover{ + color: white; + background-color: #3D9970; +} + +textarea { + width: 100%; + min-height: 10em; + max-width: 100%; +} + +dl { + max-width: 100%; + display: flex; + flex-wrap: wrap; +} + +dl > * { + flex-grow: 0; + padding: 0; + margin: 0; +} + +dt { +flex-basis: 30%; +} + +dd { + flex-basis: 70%; + margin-bottom: 32px; +} + +@media (max-width: 991.98px) { + + + html, body { + margin: 6px; +} + + + dl { + display: block; + } + + dt { + margin: 6px 0; + font-style: italic; + } + + +} \ No newline at end of file diff --git a/templates/add.html b/templates/add.html new file mode 100644 index 0000000..247594f --- /dev/null +++ b/templates/add.html @@ -0,0 +1,18 @@ + + + + + + + + Workinon + + +

What's new?

+
+ + + +
+ + diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..49d954c --- /dev/null +++ b/templates/home.html @@ -0,0 +1,42 @@ + + + + + + + + Workinon + + + +

Workinon

+
+ A small and shared archive to keep track of how ideas change during work, research and development.
+ A call to share what we are doing with others, while we are doing it.
+ In a way that doesn't focus on results, but on process and sharing. +
+ +
+ +

+ What's new? +

+ + + + +
+ +

Current archive

+
+ {% for key, value in projects | dictsort %} +
{{key}}
+
+ {%for step in value%} + {{step['when']}}, {{step['what']}}
+ {%endfor%} +
+ {% endfor %} +
+ + diff --git a/workinon.py b/workinon.py new file mode 100644 index 0000000..97b9996 --- /dev/null +++ b/workinon.py @@ -0,0 +1,115 @@ +# WORKINON +# A small and shared archive to keep track of how ideas change during work, research and development +# A call to share what we are doing with others, while we are doing it. +# In a way that doesn't focus on results, but on process and sharing. + +# How does it work +# The core of Workinon is a small API that read and write updates to a JSON file. +# The inputs can be received through a form from the application page. + +# Structure of the JSON: +# a list of projects, and each update has a codename and a list of steps +# (since this is a first prototype this could change anytime) +# (it's already changed 3 times while writing this initial documentation ah ah) +# { +# 'Workin title of the project or idea': [ +# {'13.05.2022', 'First idea of the project'}, +# {'14.05.2022', 'Second thoughts'}, +# {'15.05.2022', 'Something new and now everything makes sense'} +# ] +# } + +# To insert a new project just send in the first step and a name +# to update with a new step just refer to the name you used the first time and add the new step + +# this structure is not super robust. +# if two different project use the same codename, this could lead to interferences between the two +# so one suggestion for the usage of the Workinon could be to choose a really really really personal title + + + + + + + +import os +import json +from glob import glob +from flask import Flask, render_template, request, redirect, url_for +import datetime + + +# prefix to add /SOUPBOAT/ATLAS-API to all the routes +# and to leave the @app.route() decorator more clean + +class PrefixMiddleware(object): + def __init__(self, app, prefix=""): + self.app = app + self.prefix = prefix + + def __call__(self, environ, start_response): + + if environ["PATH_INFO"].startswith(self.prefix): + environ["PATH_INFO"] = environ["PATH_INFO"][len(self.prefix):] + environ["SCRIPT_NAME"] = self.prefix + return self.app(environ, start_response) + else: + start_response("404", [("Content-Type", "text/plain")]) + return ["This url does not belong to the app.".encode()] + + + + + +base_url = '/soupboat/workinon' + +# create flask application +app = Flask(__name__) + + +# register the middleware to prefix all the requests with our base_url +app.wsgi_app = PrefixMiddleware( + app.wsgi_app, prefix=base_url +) + + + + +# definition of the routes + +@app.route('/') +def home(): + with open('archive.json', 'r') as f: + projects = json.load(f) + + return render_template('home.html', projects=projects) + + + +@app.route('/add', methods=['GET', 'POST']) +def add(): + if request.method == 'POST': + name = request.form.get('name') + update = request.form.get('update') + + if name != '' and update != '': + with open('archive.json', 'r') as f: + projects = json.load(f) + + date = datetime.date.today().strftime('%d.%m.%Y') + step = {'when': date, 'what': update} + if name in projects: + projects[name].append(step) + else: + projects[name] = [step] + + with open('archive.json', 'w') as f: + f.write(json.dumps(projects)) + + return redirect(url_for('home')) + return render_template('add.html') + + + + +app.run(port=3144)