From 7fc17fc54c90e17c1148bce2d15d8906dca2967a Mon Sep 17 00:00:00 2001 From: Simon Steinkamp Date: Wed, 14 Oct 2026 15:40:26 +0200 Subject: [PATCH 1/4] Add argument to pass custom metadata to config --- InteractiveHtmlBom/core/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/InteractiveHtmlBom/core/config.py b/InteractiveHtmlBom/core/config.py index 605a40bc..c78d62c5 100644 --- a/InteractiveHtmlBom/core/config.py +++ b/InteractiveHtmlBom/core/config.py @@ -39,7 +39,7 @@ class Config: 'dark_mode', 'show_pads', 'show_fabrication', 'show_silkscreen', 'highlight_pin1', 'redraw_on_drag', 'board_rotation', 'checkboxes', 'bom_view', 'layer_view', 'offset_back_rotation', - 'kicad_text_formatting', 'mark_when_checked' + 'kicad_text_formatting', 'mark_when_checked', 'custom_metadata_field' ] default_show_group_fields = ["Value", "Footprint"] @@ -494,6 +494,10 @@ def add_options(cls, parser, version): help='Name of the extra field that indicates ' 'do not populate status. Components with ' 'this field not empty will be excluded.') + parser.add_argument('--custom-metadata', default='', + help='Custom metadata as a JSON string. Gets ' + 'attached to the BOM and can be accessed in ' + 'the user customization files.') def get_ini_defaults(self): # type: () -> dict | None @@ -645,6 +649,7 @@ def set_from_args(self, args): self.board_variant_whitelist = self._split(args.variants_whitelist) self.board_variant_blacklist = self._split(args.variants_blacklist) self.dnp_field = args.dnp_field + self.custom_metadata_field = args.custom_metadata def get_html_config(self): import json From 4ce15368a22ef362bcf741c43c7d725ca25cff7c Mon Sep 17 00:00:00 2001 From: Simon Steinkamp Date: Wed, 14 Oct 2026 16:00:28 +0200 Subject: [PATCH 2/4] Add example to user.js and userheader.html --- .../web/user-file-examples/user.js | 20 +++++++++++++++++++ .../web/user-file-examples/userheader.html | 3 +++ 2 files changed, 23 insertions(+) diff --git a/InteractiveHtmlBom/web/user-file-examples/user.js b/InteractiveHtmlBom/web/user-file-examples/user.js index 4cffc3b1..8c1e0007 100644 --- a/InteractiveHtmlBom/web/user-file-examples/user.js +++ b/InteractiveHtmlBom/web/user-file-examples/user.js @@ -2,3 +2,23 @@ // Event argument will always be {eventType, args} dict EventHandler.registerCallback(IBOM_EVENT_TYPES.ALL, (e) => console.log(e)); + +// Example custom metadata (use with userheader.html) +window.addEventListener("load", function () { + var meta = {}; + try { + console.log(typeof config.custom_metadata_field); + console.log(JSON.stringify(config.custom_metadata_field)); + meta = JSON.parse(config.custom_metadata_field || "{}"); + } catch (e) { + console.error("custom_metadata is no valid JSON string:", e); + } + + var element = document.getElementById("custom-metadata"); + if (!element) return; + + var text = "Drawing: " + (meta.drawing || "-") + + " | Customer: " + (meta.customer || "-"); + + element.textContent = text; +}); diff --git a/InteractiveHtmlBom/web/user-file-examples/userheader.html b/InteractiveHtmlBom/web/user-file-examples/userheader.html index bb597c57..e721c5ea 100644 --- a/InteractiveHtmlBom/web/user-file-examples/userheader.html +++ b/InteractiveHtmlBom/web/user-file-examples/userheader.html @@ -2,4 +2,7 @@
Hello header
+ + +
From 9314ad9e457d352865e9545e3740cefa1c2ee918 Mon Sep 17 00:00:00 2001 From: Simon Steinkamp Date: Thu, 15 Oct 2026 11:11:10 +0200 Subject: [PATCH 3/4] Rename custom_metadata_field to custom_metadata --- InteractiveHtmlBom/core/config.py | 4 ++-- InteractiveHtmlBom/web/user-file-examples/user.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/InteractiveHtmlBom/core/config.py b/InteractiveHtmlBom/core/config.py index c78d62c5..ebeb84bc 100644 --- a/InteractiveHtmlBom/core/config.py +++ b/InteractiveHtmlBom/core/config.py @@ -39,7 +39,7 @@ class Config: 'dark_mode', 'show_pads', 'show_fabrication', 'show_silkscreen', 'highlight_pin1', 'redraw_on_drag', 'board_rotation', 'checkboxes', 'bom_view', 'layer_view', 'offset_back_rotation', - 'kicad_text_formatting', 'mark_when_checked', 'custom_metadata_field' + 'kicad_text_formatting', 'mark_when_checked', 'custom_metadata' ] default_show_group_fields = ["Value", "Footprint"] @@ -649,7 +649,7 @@ def set_from_args(self, args): self.board_variant_whitelist = self._split(args.variants_whitelist) self.board_variant_blacklist = self._split(args.variants_blacklist) self.dnp_field = args.dnp_field - self.custom_metadata_field = args.custom_metadata + self.custom_metadata = args.custom_metadata def get_html_config(self): import json diff --git a/InteractiveHtmlBom/web/user-file-examples/user.js b/InteractiveHtmlBom/web/user-file-examples/user.js index 8c1e0007..4a3a3933 100644 --- a/InteractiveHtmlBom/web/user-file-examples/user.js +++ b/InteractiveHtmlBom/web/user-file-examples/user.js @@ -7,9 +7,9 @@ EventHandler.registerCallback(IBOM_EVENT_TYPES.ALL, (e) => console.log(e)); window.addEventListener("load", function () { var meta = {}; try { - console.log(typeof config.custom_metadata_field); - console.log(JSON.stringify(config.custom_metadata_field)); - meta = JSON.parse(config.custom_metadata_field || "{}"); + console.log(typeof config.custom_metadata); + console.log(JSON.stringify(config.custom_metadata)); + meta = JSON.parse(config.custom_metadata || "{}"); } catch (e) { console.error("custom_metadata is no valid JSON string:", e); } From 92e24a748b272a7a2e412b9fc70e499762deda9f Mon Sep 17 00:00:00 2001 From: Simon Steinkamp Date: Thu, 15 Oct 2026 11:12:31 +0200 Subject: [PATCH 4/4] Generalize custom metadata helpstring Helpstring was constraining metadata to JSON format which is not necessary. Plain strings could also be used here. --- InteractiveHtmlBom/core/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InteractiveHtmlBom/core/config.py b/InteractiveHtmlBom/core/config.py index ebeb84bc..55371e0e 100644 --- a/InteractiveHtmlBom/core/config.py +++ b/InteractiveHtmlBom/core/config.py @@ -495,8 +495,8 @@ def add_options(cls, parser, version): 'do not populate status. Components with ' 'this field not empty will be excluded.') parser.add_argument('--custom-metadata', default='', - help='Custom metadata as a JSON string. Gets ' - 'attached to the BOM and can be accessed in ' + help='Custom metadata. Gets attached to ' + 'the BOM and can be accessed in ' 'the user customization files.') def get_ini_defaults(self):