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: with open("src/content/component-inventory.csv") as f:
documents['inventory'] = [] 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) 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 1,Electrolytic capacitor,?,Capacitor,25/11/2024,Reel to Reel recorder
2,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 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,3 +1,7 @@
---
title: "Let's unrepair together"
---
# 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.

View File

@ -20,7 +20,13 @@
<meta name="robots" content="noarchive, noimageindex"> <meta name="robots" content="noarchive, noimageindex">
{% block title %} {% block title %}
{% if page['title'] %}
<title>{{ page['title'] }}</title>
{% else %}
<title>The title</title> <title>The title</title>
{% endif %}
{% endblock %} {% endblock %}
</head> </head>
@ -64,11 +70,9 @@
<h3>5.0 Conclusion?</h3> <h3>5.0 Conclusion?</h3>
<h1>Other pages</h1> <h1>Other pages</h1>
<h3></h3>
<p>{{ render_list('repair-logs', 'Repair Logs') }}</p> <p>{{ render_list('repair-logs', 'Repair Logs') }}</p>
{% block footer %} {% block footer %}
<p>Find the code on Klankservers <a target="_blank" href="https://code.klank.school/vitrinekast/klank-docs">Git!</a>.</p> <p>Find the code on Klankservers <a target="_blank" href="https://code.klank.school/vitrinekast/klank-docs">Git!</a>.</p>
{% endblock %} {% endblock %}

View File

@ -1,7 +1,8 @@
{% extends "base.jinja" %} {% extends "base.jinja" %}
{% from 'snippets/inventory.jinja' import inventory with context %}
{% block title %} {% block title %}
<title>{{ page['title'] }}</title> <title>Components | {{ page['title'] }}</title>
{% endblock %} {% endblock %}
@ -14,42 +15,6 @@
<h2>Component inventory</h2> <h2>Component inventory</h2>
{% set ns = namespace(has_inventory=false) %} {{inventory("type", (page.type.capitalize() | slugify)) }}
{% 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> </article>
{% endblock %} {% endblock %}

View File

@ -1,7 +1,8 @@
{% extends "base.jinja" %} {% extends "base.jinja" %}
{% from 'snippets/inventory.jinja' import inventory with context %}
{% block title %} {% block title %}
<title>{{ page['title'] }}</title> <title>Devices | {{ page['title'] }}</title>
{% endblock %} {% endblock %}
@ -15,43 +16,7 @@
<h2>Parts salvaged from this device</h2> <h2>Parts salvaged from this device</h2>
{% set ns = namespace(has_inventory=false) %} {{ inventory("Where", ( page.title.capitalize() | slugify )) }}
{% for item in documents.inventory %}
{% if (item.Where.capitalize() | slugify) == (page.title.capitalize() | slugify ) %}
{% set ns.has_inventory = true %}
{% 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> </article>
{% endblock %} {% endblock %}

View File

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

View File

@ -1,10 +1,5 @@
{% extends "base.jinja" %} {% extends "base.jinja" %}
{% block title %}
<title>{{ page['title'] }}</title>
{% endblock %}
{% block content %} {% block content %}
<header><p>template: post.jinja</p></header> <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 %} {% endif %}
{%- endmacro %} {%- endmacro %}
<p>{{ render_list(type) }}</p> <p>{{ render_list(type) }}</p>

View File

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