Merge pull request #3 from DoomHammer/add-label-maker
Add slightly (ok, very) dirty code to generate Brother P-Touch files
This commit is contained in:
commit
27eaf8191f
3 changed files with 165 additions and 31 deletions
27
main.py
27
main.py
|
|
@ -1,8 +1,17 @@
|
||||||
import os, shutil
|
import os, re, shutil
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from discourse import DiscourseDatabase
|
from discourse import DiscourseDatabase
|
||||||
|
|
||||||
|
|
||||||
|
def add_download_button(row):
|
||||||
|
item_id = re.sub(r'<a href.*/([0-9]+)".*', "\\1", row[1])
|
||||||
|
download_button = (
|
||||||
|
f'<button id="btn_{item_id}"><i class="fa fa-download"></i> {item_id}</button>'
|
||||||
|
)
|
||||||
|
return row + [download_button]
|
||||||
|
|
||||||
|
|
||||||
def generate_dashboard():
|
def generate_dashboard():
|
||||||
"""Generate dashboard from zasoby.csv file"""
|
"""Generate dashboard from zasoby.csv file"""
|
||||||
print("Generating HTML dashboard")
|
print("Generating HTML dashboard")
|
||||||
|
|
@ -16,13 +25,21 @@ def generate_dashboard():
|
||||||
shutil.copytree("template/static", f"{website_folder}/static")
|
shutil.copytree("template/static", f"{website_folder}/static")
|
||||||
template = env.get_template("_main_layout.html")
|
template = env.get_template("_main_layout.html")
|
||||||
with open(f"{website_folder}/index.html", "w+", encoding="utf-8") as file:
|
with open(f"{website_folder}/index.html", "w+", encoding="utf-8") as file:
|
||||||
header_row = data.columns.values.tolist()
|
header_row = data.columns.values.tolist() + ["label"]
|
||||||
rows = data.values.tolist()
|
rows = map(
|
||||||
html = template.render(title="Baza Zasobów Hackerspace Trójmiasto", t_header=header_row, t_body=rows)
|
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)
|
file.write(html)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
DiscourseDatabase()
|
DiscourseDatabase()
|
||||||
generate_dashboard()
|
generate_dashboard()
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,14 +1,14 @@
|
||||||
footer {
|
footer {
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* || Sidenav */
|
/* || Sidenav */
|
||||||
.sidenav {
|
.sidenav {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
top: 0;
|
top: 0;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
padding: 6px 8px 6px 16px;
|
padding: 6px 8px 6px 16px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue