partsdb

electronic parts inventory
git clone https://git.e1e0.net/partsdb.git
Log | Files | Refs | README | LICENSE

commit d3f448c545882d52db3a52438b5a4f5beccc6334
parent b61855c376a15ed80574f5605cb5f4390f0cbba0
Author: Paco Esteban <paco@e1e0.net>
Date:   Sat,  7 Oct 2023 16:08:30 +0200

add favicon to HTML export

Diffstat:
Apartsdb/exports/files/icons8-transistor-office-m-16.png | 0
Apartsdb/exports/files/icons8-transistor-office-m-32.png | 0
Mpartsdb/exports/templates/cat.html | 2++
Mpartsdb/exports/templates/index.html | 2++
Mpartsdb/exports/templates/part.html | 2++
Mpartsdb/exports/templates/storage.html | 2++
Mpartsdb/helpers.py | 12++++++++++++
Mpartsdb/partsdb.py | 1+
8 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/partsdb/exports/files/icons8-transistor-office-m-16.png b/partsdb/exports/files/icons8-transistor-office-m-16.png Binary files differ. diff --git a/partsdb/exports/files/icons8-transistor-office-m-32.png b/partsdb/exports/files/icons8-transistor-office-m-32.png Binary files differ. diff --git a/partsdb/exports/templates/cat.html b/partsdb/exports/templates/cat.html @@ -8,6 +8,8 @@ <meta name="description" content="partsdb category index"> <meta name="author" content="e1e0"> + <link rel="icon" type="image/png" sizes="32x32" href="icons8-transistor-office-m-32.png"> + <link rel="icon" type="image/png" sizes="16x16" href="icons8-transistor-office-m-16.png"> <link rel="stylesheet" href="style.css?v=1.0"> </head> <body> diff --git a/partsdb/exports/templates/index.html b/partsdb/exports/templates/index.html @@ -8,6 +8,8 @@ <meta name="description" content="partsdb category index"> <meta name="author" content="e1e0"> + <link rel="icon" type="image/png" sizes="32x32" href="icons8-transistor-office-m-32.png"> + <link rel="icon" type="image/png" sizes="16x16" href="icons8-transistor-office-m-16.png"> <link rel="stylesheet" href="style.css?v=1.0"> </head> <body> diff --git a/partsdb/exports/templates/part.html b/partsdb/exports/templates/part.html @@ -8,6 +8,8 @@ <meta name="description" content="partsdb part description"> <meta name="author" content="e1e0"> + <link rel="icon" type="image/png" sizes="32x32" href="icons8-transistor-office-m-32.png"> + <link rel="icon" type="image/png" sizes="16x16" href="icons8-transistor-office-m-16.png"> <link rel="stylesheet" href="style.css?v=1.0"> </head> <body> diff --git a/partsdb/exports/templates/storage.html b/partsdb/exports/templates/storage.html @@ -8,6 +8,8 @@ <meta name="description" content="partsdb storage index"> <meta name="author" content="e1e0"> + <link rel="icon" type="image/png" sizes="32x32" href="icons8-transistor-office-m-32.png"> + <link rel="icon" type="image/png" sizes="16x16" href="icons8-transistor-office-m-16.png"> <link rel="stylesheet" href="style.css?v=1.0"> </head> <body> diff --git a/partsdb/helpers.py b/partsdb/helpers.py @@ -6,6 +6,11 @@ import json import subprocess import tempfile import time +import shutil + +from os import listdir + +from partsdb import exports def print_parts_list(parts, output="full"): @@ -166,6 +171,13 @@ def html_css(dest_folder, env): f.write(tpl.render()) +def html_aux_files(dest_folder): + orig_folder = list(exports.__path__)[0] + aux_files = listdir(f"{orig_folder}/files") + for f in aux_files: + shutil.copy2(f"{orig_folder}/files/{f}", dest_folder) + + def html_attachments(dest_folder, part_id, datasheet, image): if datasheet["datasheet"] is not None: with open(f"{dest_folder}/part_datasheet_{part_id}.pdf", "wb") as f: diff --git a/partsdb/partsdb.py b/partsdb/partsdb.py @@ -200,6 +200,7 @@ def export_db(dest_folder): datasheet = db.get_datasheet(p["id"]) helpers.html_attachments(dest_folder, p["id"], datasheet, image) helpers.html_css(dest_folder, env) + helpers.html_aux_files(dest_folder) def list_categories():