list rendering

main
km0 2 years ago
parent aa469e758d
commit 6684cb1ddf

1
.gitignore vendored

@ -1,3 +1,4 @@
venv/
.DS_Store
txt/
__pycache__

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Souptxt</title>
<link rel="stylesheet" href="/static/style.css" />
</head>
<body>
<h1>Souptxt</h1>
<p>Writings for the thesis</p>
<ul>
<li>
<a href="/txt/cc">Coding Contingencies</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/complexity">Complexity</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/contexts">Contexts</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/devices">Devices</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/hackpact01">Hackpact 01</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/hackpact02">Hackpact 02</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/hackpact03">Hackpact 03</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/hackpact04">Hackpact 04</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/hackpact05">Hackpact 05</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/hackpact06">Hackpact 06 07 08</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/list-multiplicity-mol-law">List and multiplicity (Mol and Law)</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/narrative">Narrative</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/project">Project</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/size">Size</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
<li>
<a href="/txt/sumiyaki">Sumiyaki</a>
<span class="last-edit"> last edit: 03.12.2022</span>
</li>
</ul>
</body>
</html>

@ -1,8 +1,10 @@
click==8.1.3
colorama==0.4.6
Flask==2.2.2
importlib-metadata==5.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
Markdown==3.4.1
MarkupSafe==2.1.1
python-dotenv==0.21.0
python-frontmatter==1.0.0

@ -1,5 +1,5 @@
import os
from flask import Flask, render_template, url_for, send_from_directory
from flask import Flask, render_template, url_for, send_from_directory, request, redirect
import frontmatter
import markdown
from prefix import PrefixMiddleware
@ -7,6 +7,7 @@ from dotenv import load_dotenv
from time import strftime, localtime
import random
import glob
import subprocess
@ -45,6 +46,11 @@ def txt_list():
return writings
def render_list():
subprocess.run(['update.sh'], shell=True)
with open('list.html', 'w+') as f:
f.write(render_template('home.html', writings=txt_list()))
# ---
# Create Flask App
@ -53,14 +59,13 @@ def txt_list():
app = Flask(__name__)
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix=prefix)
# ---
# Routes
# ---
@app.route('/')
def home():
return render_template('home.html', writings=txt_list())
return send_from_directory(app.root_path,'list.html')
@app.route('/txt/<slug>')
def txt(slug):
@ -73,6 +78,15 @@ def txt(slug):
except FileNotFoundError:
return 'File not found!'
@app.route('/api/update', methods=['GET', 'POST'])
def update():
render_list()
if request.method == 'POST':
render_list()
return redirect(url_for('home'))
# ---
# Run the app
# ---

@ -0,0 +1,4 @@
rm -rf txt
git clone https://git.xpub.nl/kamo/txt.git txt
cd txt
git checkout main
Loading…
Cancel
Save