From 7aa8fbee310cd94cad0116573fa3d70c525a0663 Mon Sep 17 00:00:00 2001 From: Piotr Gaczkowski Date: Wed, 4 Feb 2026 10:50:33 +0100 Subject: [PATCH] Add slightly (ok, very) dirty code to generate Brother P-Touch files --- main.py | 27 ++++-- template/_base_template.html | 151 ++++++++++++++++++++++++++++++---- template/static/css/style.css | 18 ++-- 3 files changed, 165 insertions(+), 31 deletions(-) diff --git a/main.py b/main.py index f851c57..1415ca2 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,17 @@ -import os, shutil +import os, re, shutil from jinja2 import Environment, FileSystemLoader import pandas as pd from discourse import DiscourseDatabase + +def add_download_button(row): + item_id = re.sub(r' {item_id}' + ) + return row + [download_button] + + def generate_dashboard(): """Generate dashboard from zasoby.csv file""" print("Generating HTML dashboard") @@ -16,13 +25,21 @@ def generate_dashboard(): shutil.copytree("template/static", f"{website_folder}/static") template = env.get_template("_main_layout.html") with open(f"{website_folder}/index.html", "w+", encoding="utf-8") as file: - header_row = data.columns.values.tolist() - rows = data.values.tolist() - html = template.render(title="Baza Zasobów Hackerspace Trójmiasto", t_header=header_row, t_body=rows) + header_row = data.columns.values.tolist() + ["label"] + rows = map( + add_download_button, + data.values.tolist(), + ) + html = template.render( + title="Baza Zasobów Hackerspace Trójmiasto", + t_header=header_row, + t_body=rows, + ) file.write(html) if __name__ == "__main__": DiscourseDatabase() generate_dashboard() - print("Done!") \ No newline at end of file + print("Done!") + diff --git a/template/_base_template.html b/template/_base_template.html index 33fcb3a..ecf3da4 100644 --- a/template/_base_template.html +++ b/template/_base_template.html @@ -1,4 +1,4 @@ - + @@ -6,28 +6,145 @@ Baza Zasobów Hackerspace Trójmiasto - + - + - {% block body %}{% endblock body %} + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ + + + + + - - - - - - - diff --git a/template/static/css/style.css b/template/static/css/style.css index aa902ec..fcfabb6 100644 --- a/template/static/css/style.css +++ b/template/static/css/style.css @@ -1,14 +1,14 @@ footer { - padding: 12px; - margin-top: auto; + padding: 12px; + margin-top: auto; } /* || Sidenav */ .sidenav { - width: 250px; - position: sticky; - z-index: 1; - top: 0; - overflow-x: hidden; - padding: 6px 8px 6px 16px; -} \ No newline at end of file + width: 250px; + position: sticky; + z-index: 1; + top: 0; + overflow-x: hidden; + padding: 6px 8px 6px 16px; +}