rename some files and delete duplicate code

This commit is contained in:
vitrinekast 2024-12-03 00:08:45 +01:00
parent 8fddbb5e85
commit ad1ece0f1b
14 changed files with 112 additions and 141 deletions

2
app.py
View File

@ -122,7 +122,7 @@ def get_inventory():
with open("src/content/component-inventory.csv") as f:
documents['inventory'] = []
for line in csv.DictReader(f, fieldnames=('ID', 'Name', 'Value', 'Type', 'Date', 'Where')):
for line in csv.DictReader(f, fieldnames=('ID', 'Name', 'Value', 'type', 'Date', 'Where')):
documents['inventory'].append(line)

View File

@ -1,4 +1,4 @@
ID,Name,Value,Type,Date,Where
ID,Name,Value,type,Date,Where
1,Electrolytic capacitor,?,Capacitor,25/11/2024,Reel to Reel recorder
2,Electrolytic capacitor,??,Capacitor,25/11/2024,Reel to Reel recorder
3,Electrolytic capacitor,??,Capacitor,25/11/2024,Reel to Reel recorder

1 ID Name Value Type type Date Where
2 1 Electrolytic capacitor ? Capacitor 25/11/2024 Reel to Reel recorder
3 2 Electrolytic capacitor ?? Capacitor 25/11/2024 Reel to Reel recorder
4 3 Electrolytic capacitor ?? Capacitor 25/11/2024 Reel to Reel recorder

View File

@ -1,5 +1,9 @@
---
title: "Let's unrepair together"
---
# Let's unrepair together
Hello! Every thursday we're hanging out at Cato, to unrepair together. In januari 2025 we're kickstarting a series of hangouts where we'll dive into topics like server maintainance, salvaging electronic components and making sound devices.
Hello! Every thursday we're hanging out at Cato, to unrepair together. In januari 2025 we're kickstarting a series of hangouts where we'll dive into topics like server maintainance, salvaging electronic components and making sound devices.
Come hang out!
Come hang out!

View File

@ -20,7 +20,13 @@
<meta name="robots" content="noarchive, noimageindex">
{% block title %}
<title>The title</title>
{% if page['title'] %}
<title>{{ page['title'] }}</title>
{% else %}
<title>The title</title>
{% endif %}
{% endblock %}
</head>
@ -30,49 +36,47 @@
<main>
<section>
{% block content %}{% endblock %}
</section>
</section>
{% block aside %}
{% block aside %}
<aside>
<h1>WIP THESIS</h1>
<a href="/thesis.html">index</a>
<h2>TOC</h2>
<h3>1.0 Introduction</h3>
<h3>2.0 Quick start guide</h3>
{% macro render_list(name, title) -%}
{% if documents[name]|length > 0 %}
<h3>{{ title}}</h3>
<ul>
{% for item in documents[name] %}
<li>
<a href="/{{ name }}/{{ item['slug'] }}.html">{{ item['title'] }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{%- endmacro %}
<p>{{ render_list('components', '3.0 Components') }}</p>
<p>{{ render_list('recipes', '4.0 Recipes for sound devices') }}</p>
<h3>5.0 Conclusion?</h3>
<h1>Other pages</h1>
<h3></h3>
<p>{{ render_list('repair-logs', 'Repair Logs') }}</p>
<aside>
<h1>WIP THESIS</h1>
<a href="/thesis.html">index</a>
{% block footer %}
<p>Find the code on Klankservers <a target="_blank" href="https://code.klank.school/vitrinekast/klank-docs">Git!</a>.</p>
{% endblock %}
</aside>
<h2>TOC</h2>
<h3>1.0 Introduction</h3>
<h3>2.0 Quick start guide</h3>
{% macro render_list(name, title) -%}
{% if documents[name]|length > 0 %}
<h3>{{ title}}</h3>
<ul>
{% for item in documents[name] %}
<li>
<a href="/{{ name }}/{{ item['slug'] }}.html">{{ item['title'] }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{%- endmacro %}
<p>{{ render_list('components', '3.0 Components') }}</p>
<p>{{ render_list('recipes', '4.0 Recipes for sound devices') }}</p>
<h3>5.0 Conclusion?</h3>
<h1>Other pages</h1>
<p>{{ render_list('repair-logs', 'Repair Logs') }}</p>
{% block footer %}
<p>Find the code on Klankservers <a target="_blank" href="https://code.klank.school/vitrinekast/klank-docs">Git!</a>.</p>
{% endblock %}
</aside>
{% endblock %}
</main>

View File

@ -1,55 +1,20 @@
{% extends "base.jinja" %}
{% from 'snippets/inventory.jinja' import inventory with context %}
{% block title %}
<title>{{ page['title'] }}</title>
<title>Components | {{ page['title'] }}</title>
{% endblock %}
{% block content %}
<header><p>template: components.jinja</p></header>
<header><p>template: components.jinja</p></header>
<article>
<h1>{{page['title']}}</h1>
{{ page['body'] }}
<article>
<h1>{{page['title']}}</h1>
{{ page['body'] }}
<h2>Component inventory</h2>
<h2>Component inventory</h2>
{% set ns = namespace(has_inventory=false) %}
{% for item in documents.inventory %}
{% if (item.Type.capitalize() | slugify)== (page['type'].capitalize() | slugify)%}
{% set ns.has_inventory = true %}
{% endif %}
{% endfor %}
{% if ns.has_inventory %}
<table>
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>Where</th>
<th>When</th>
</tr>
</thead>
<tbody>
{% for item in documents.inventory %}
{% if (item.Type.capitalize() | slugify)== (page.type.capitalize() | slugify) %}
<tr>
<td>{{item.Name}}</td>
<td>{{item.Value}}</td>
<td><a href="/devices/{{item.Where | slugify}}.html">{{item.Where}}</td>
<td>{{item.Date}}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% else %}
No components were identified yet
{% endif %}
</article>
{{inventory("type", (page.type.capitalize() | slugify)) }}
</article>
{% endblock %}

View File

@ -1,7 +1,8 @@
{% extends "base.jinja" %}
{% from 'snippets/inventory.jinja' import inventory with context %}
{% block title %}
<title>{{ page['title'] }}</title>
<title>Devices | {{ page['title'] }}</title>
{% endblock %}
@ -15,43 +16,7 @@
<h2>Parts salvaged from this device</h2>
{% set ns = namespace(has_inventory=false) %}
{% for item in documents.inventory %}
{% if (item.Where.capitalize() | slugify) == (page.title.capitalize() | slugify ) %}
{% set ns.has_inventory = true %}
{{ inventory("Where", ( page.title.capitalize() | slugify )) }}
{% endif %}
{% endfor %}
{% if ns.has_inventory %}
<table>
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>Type</th>
</tr>
</thead>
<tbody>
{% for item in documents.inventory %}
{% if ( item.Where.capitalize() | slugify ) == ( page.title.capitalize() | slugify ) %}
<tr>
<td>{{item.Name}}</td>
<td>{{item.Value}}</td>
<td><a href="/components/{{item.Type | slugify}}.html">{{item.Type}}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% else %}
No components were identified yet
{% endif %}
</article>
{% endblock %}
</article>
{% endblock %}

View File

@ -1,9 +1,5 @@
{% extends "base.jinja" %}
{% block title %}
<title>{{ page['title'] }}</title>
{% endblock %}
{% block content %}
<header><p>template: index.jinja</p></header>

View File

@ -1,10 +1,5 @@
{% extends "base.jinja" %}
{% block title %}
<title>{{ page['title'] }}</title>
{% endblock %}
{% block content %}
<header><p>template: post.jinja</p></header>

View File

@ -0,0 +1,43 @@
{% macro inventory(compare, compareWith) -%}
<h2>doing a macro</h2>
{% set ns = namespace(has_inventory=false) %}
{% for item in documents.inventory %}
{% if (item[compare].capitalize() | slugify) == compareWith %}
{% set ns.has_inventory = true %}
{% endif %}
{% endfor %}
{% if ns.has_inventory %}
<table>
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>type</th>
<th>Where</th>
<th>When</th>
</tr>
</thead>
<tbody>
{% for item in documents.inventory %}
{% if (item[compare].capitalize() | slugify)== compareWith %}
<tr>
<td>{{item.Name}}</td>
<td>{{item.Value}}</td>
<td><a href="/components/{{item.type | slugify}}.html">{{item.type}}</a></td>
<td><a href="/devices/{{item.Where | slugify}}.html">{{item.Where}}</a></td>
<td>{{item.Date}}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% else %}
No components were identified yet
{% endif %}
{% endmacro %}

View File

@ -12,3 +12,6 @@
{% endif %}
{%- endmacro %}
<p>{{ render_list(type) }}</p>

View File

@ -1,18 +1,14 @@
{% extends "base.jinja" %}
{% block title %}
<title>Let's unrepair together</title>
{% endblock %}
{% block content %}
<header><p>template: unrepair.jinja</p></header>
<article>
<h1>{{page['title']}}</h1>
{{ page['body'] | shortcode}}