diff --git a/app.py b/app.py index 84d9bc0..2f63a37 100644 --- a/app.py +++ b/app.py @@ -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) diff --git a/src/content/component-inventory.csv b/src/content/component-inventory.csv index 7b1367f..b5602ee 100644 --- a/src/content/component-inventory.csv +++ b/src/content/component-inventory.csv @@ -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 diff --git a/src/content/components/capacitors.md b/src/content/components/capacitor.md similarity index 100% rename from src/content/components/capacitors.md rename to src/content/components/capacitor.md diff --git a/src/content/components/resistors.md b/src/content/components/resistor.md similarity index 100% rename from src/content/components/resistors.md rename to src/content/components/resistor.md diff --git a/src/content/components/transistors.md b/src/content/components/transistor.md similarity index 100% rename from src/content/components/transistors.md rename to src/content/components/transistor.md diff --git a/src/content/unrepair.md b/src/content/unrepair.md index f179083..865f9d5 100644 --- a/src/content/unrepair.md +++ b/src/content/unrepair.md @@ -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! \ No newline at end of file +Come hang out! diff --git a/src/templates/base.jinja b/src/templates/base.jinja index de42d1d..80e45a1 100644 --- a/src/templates/base.jinja +++ b/src/templates/base.jinja @@ -20,7 +20,13 @@ {% block title %} - The title + + {% if page['title'] %} + {{ page['title'] }} + {% else %} + The title + + {% endif %} {% endblock %} @@ -30,49 +36,47 @@
{% block content %}{% endblock %} -
+ - {% block aside %} + {% block aside %} - {% endblock %}
diff --git a/src/templates/components.jinja b/src/templates/components.jinja index 6b0bf08..8f4f040 100644 --- a/src/templates/components.jinja +++ b/src/templates/components.jinja @@ -1,55 +1,20 @@ {% extends "base.jinja" %} +{% from 'snippets/inventory.jinja' import inventory with context %} {% block title %} - {{ page['title'] }} + Components | {{ page['title'] }} {% endblock %} {% block content %} -

template: components.jinja

+

template: components.jinja

-
-

{{page['title']}}

- {{ page['body'] }} +
+

{{page['title']}}

+ {{ page['body'] }} -

Component inventory

+

Component inventory

-{% 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 %} - - - - - - - - - - - {% for item in documents.inventory %} - {% if (item.Type.capitalize() | slugify)== (page.type.capitalize() | slugify) %} - - - - - - - {% endif %} - {% endfor %} - - -
NameValueWhereWhen
{{item.Name}}{{item.Value}}{{item.Where}}{{item.Date}}
- -{% else %} -No components were identified yet -{% endif %} - -
+ {{inventory("type", (page.type.capitalize() | slugify)) }} +
{% endblock %} \ No newline at end of file diff --git a/src/templates/devices.jinja b/src/templates/devices.jinja index 4cb2ff2..34d6634 100644 --- a/src/templates/devices.jinja +++ b/src/templates/devices.jinja @@ -1,7 +1,8 @@ {% extends "base.jinja" %} +{% from 'snippets/inventory.jinja' import inventory with context %} {% block title %} - {{ page['title'] }} + Devices | {{ page['title'] }} {% endblock %} @@ -15,43 +16,7 @@

Parts salvaged from this device

- {% 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 %} - - - - - - - - - - {% for item in documents.inventory %} - {% if ( item.Where.capitalize() | slugify ) == ( page.title.capitalize() | slugify ) %} - - - - - - - - {% endif %} - {% endfor %} - - -
NameValueType
{{item.Name}}{{item.Value}}{{item.Type}}
- - {% else %} - No components were identified yet - {% endif %} - - - - {% endblock %} \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/src/templates/index.jinja b/src/templates/index.jinja index 6d36a06..2022892 100644 --- a/src/templates/index.jinja +++ b/src/templates/index.jinja @@ -1,9 +1,5 @@ {% extends "base.jinja" %} -{% block title %} - {{ page['title'] }} -{% endblock %} - {% block content %}

template: index.jinja

diff --git a/src/templates/post.jinja b/src/templates/post.jinja index 508491b..e2e2009 100644 --- a/src/templates/post.jinja +++ b/src/templates/post.jinja @@ -1,10 +1,5 @@ {% extends "base.jinja" %} -{% block title %} - {{ page['title'] }} -{% endblock %} - - {% block content %}

template: post.jinja

diff --git a/src/templates/snippets/inventory.jinja b/src/templates/snippets/inventory.jinja new file mode 100644 index 0000000..1594ad8 --- /dev/null +++ b/src/templates/snippets/inventory.jinja @@ -0,0 +1,43 @@ +{% macro inventory(compare, compareWith) -%} +

doing a macro

+ {% 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 %} + + + + + + + + + + + + {% for item in documents.inventory %} + {% if (item[compare].capitalize() | slugify)== compareWith %} + + + + + + + + + + {% endif %} + {% endfor %} + + +
NameValuetypeWhereWhen
{{item.Name}}{{item.Value}}{{item.type}}{{item.Where}}{{item.Date}}
+ + {% else %} + No components were identified yet + {% endif %} +{% endmacro %} \ No newline at end of file diff --git a/src/templates/snippets/show-list.jinja b/src/templates/snippets/show-list.jinja index e725feb..e5f61b6 100644 --- a/src/templates/snippets/show-list.jinja +++ b/src/templates/snippets/show-list.jinja @@ -12,3 +12,6 @@ {% endif %} {%- endmacro %}

{{ render_list(type) }}

+ + + diff --git a/src/templates/unrepair.jinja b/src/templates/unrepair.jinja index a201495..28496ce 100644 --- a/src/templates/unrepair.jinja +++ b/src/templates/unrepair.jinja @@ -1,18 +1,14 @@ {% extends "base.jinja" %} - {% block title %} Let's unrepair together {% endblock %} - - {% block content %}

template: unrepair.jinja

-

{{page['title']}}

{{ page['body'] | shortcode}}