From 28031bd3d7b850e2a9859cb74dbe550841e7beca Mon Sep 17 00:00:00 2001 From: Johannes Kimmel Date: Wed, 22 Feb 2023 22:46:05 +0100 Subject: [PATCH] add infrastructure for hardware database To keep device information consistent, use a small per device database embedded in the frontmatter of the device page source. Device information is extracted from the database and formatted into tables with the provided shortcodes The data can then further be used to build comparison tables and filters for specific usecases. New devices should make use of the provided archetype, which provides an example of most used fields: ``` hugo new content/hardware/my-device.md ``` Fixes: #5 --- archetypes/hardware.md | 50 ++++++++ content/hardware/_index.md | 2 +- layouts/shortcodes/detailsofhardware.html | 147 ++++++++++++++++++++++ layouts/shortcodes/tableofhardware.html | 26 ++++ 4 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 archetypes/hardware.md create mode 100644 layouts/shortcodes/detailsofhardware.html create mode 100644 layouts/shortcodes/tableofhardware.html diff --git a/archetypes/hardware.md b/archetypes/hardware.md new file mode 100644 index 0000000..4ba84c3 --- /dev/null +++ b/archetypes/hardware.md @@ -0,0 +1,50 @@ +--- +title: "{{ replace .Name "-" " " | title }}" +date: {{ .Date }} +hardware: + manufacturer: MFG + model: Model + chip: SoC + recommended: true + cores: 2 + threads: 4 + clock: 1000 + ram: 262144 + flash: 262144 + serial: + - ttl + - usb + - rj45 + interface: + - dev: eth0 + type: rj45 + speed: 1000 + features: [ 24V, dsa, PD ] + roleL3: wan + roleNode: wan + - dev: eth1 + type: rj45 + speed: 1000 + features: [ 802.3af, dsa ] + roleL3: client + roleNode: client + - dev: eth4 + type: sfp + speed: 1000 + features: [ ] + roleL3: client + roleNode: batman + - dev: wifi2 + type: 2ghz + speed: 150 + features: [ "n", 1T, 1R ] + - dev: wifi5 + type: 5ghz + speed: 866 + features: [ ac, 2T, 2R ] + benchmark: + benchmark1: measurement +--- + +## Spezifikation +{{< detailsofhardware >}} diff --git a/content/hardware/_index.md b/content/hardware/_index.md index f111383..4484e83 100644 --- a/content/hardware/_index.md +++ b/content/hardware/_index.md @@ -4,4 +4,4 @@ bookCollapseSection: true date: 2022-12-01T17:25:00+01:00 --- -{{< section >}} +{{< tableofhardware >}} diff --git a/layouts/shortcodes/detailsofhardware.html b/layouts/shortcodes/detailsofhardware.html new file mode 100644 index 0000000..34a55a7 --- /dev/null +++ b/layouts/shortcodes/detailsofhardware.html @@ -0,0 +1,147 @@ +{{ $hw := .Page.Params.hardware }} +

Datenblatt

+{{ with $hw }} + + + + + + + + + + + + + + + + + + + + + + + + + + {{ with .serial }} + + + + + {{ end }} +
Bezeichnung{{ .manufacturer }} {{ .model }}
Empfohlen{{ cond .recommended (emojify ":heavy_check_mark:") (emojify ":x:") }}
SoC{{ .chip }}
CPU{{ .cores }} Core {{ .threads }} Threads @ {{ .clock }} MHz
RAM{{ div .ram 1024 }}MiB
Flash{{ div .flash 1024 }}MiB
Serielle Schnittstelle{{ delimit . ", " }}
+{{ end }} +{{ with $hw.interface }} +

Schnittstellen

+ {{ $wired := where . "type" "in" (slice "rj45" "sfp") }} + {{ with $wired }} +

Kabelgebunden

+ + + + {{ range . -}} + + {{ end }} + + + + {{ range . -}} + + {{ end }} + + {{ if where . ".features" "intersect" (slice "24V" "802.3af" "802.3at" "PD") }} + + + {{ range . -}} + + {{ end }} + + {{ end }} + {{ if where . ".features" "intersect" (slice "dsa") }} + + + {{ range . -}} + + {{ end }} + + {{ end }} + {{ if where . "roleL3" "!=" nil }} + + + {{ range . -}} + + {{ end }} + + {{ end }} + {{ if where . "roleNode" "!=" nil }} + + + {{ range . -}} + + {{ end }} + + {{ end }} +
{{ .dev }}
Typ{{ .speed }}Mbps {{ .type | upper }}
PoE{{ delimit (intersect .features (slice "24V" "802.3af" "802.3at" "PD")) ", " }}
DSA Port{{ cond (in .features "dsa") (emojify ":heavy_check_mark:") "" }}
Belegung L3{{ echoParam . "roleL3" }}
Belegung Node{{ echoParam . "roleNode" }}
+ {{ end }} + + {{ $wireless := where $hw.interface "type" "in" (slice "2ghz" "5ghz") }} + {{ with $wireless }} +

Wireless

+ + + + {{ range . -}} + + {{ end }} + + {{ if where . ".features" "intersect" (slice "bg" "n" "ac" "ax") }} + + + {{ range . -}} + + {{ end }} + + {{ end }} + {{ if where . ".speed" "!=" nil }} + + + {{ range . -}} + + {{ end }} + + {{ end }} +
{{ .dev }}
Standard{{ delimit (intersect .features (slice "bg" "n" "ac" "ax")) ", " }}
Datenrate{{ echoParam . "speed" }} Mbit/s
+ {{ end }} +{{ end }} +{{ with $hw.benchmark }} +

Benchmarks

+ + + + + + {{ range $b, $m := . }} + + + + + {{ end }} +
BenchmarkMessung
{{ $b }}{{ $m }}
+{{ end }} + + +

debug :)

+{{ template "treeview" .Page.Params.hardware }} +{{ define "treeview" }} + +{{ end }} +{{ highlight (jsonify (dict "indent" "\t") .Page.Params.hardware) "json" }} diff --git a/layouts/shortcodes/tableofhardware.html b/layouts/shortcodes/tableofhardware.html new file mode 100644 index 0000000..5d0423b --- /dev/null +++ b/layouts/shortcodes/tableofhardware.html @@ -0,0 +1,26 @@ + + + + + + + + + + {{ range $device := where .Page.Pages "Params.hardware" "!=" nil }} + {{ $hw := $device.Params.hardware }} + + + + + + + + + {{ end }} +
HerstellerModellDSA PortsRadiosSchnittstellenEmpfohlen
{{ $hw.manufacturer }}{{ $hw.model }}{{ where $hw.interface "features" "intersect" (slice "dsa") | len }}{{ where $hw.interface "type" "in" (slice "2ghz" "5ghz") | len }} + {{ range $type := slice "sfp" "rj45" "2ghz" "5ghz" }} + {{ $n := (where $hw.interface "type" "in" (slice $type) | len) }} + {{ if gt $n 0 }}{{ $n }}x{{ $type }}{{ end }} + {{ end }} + {{ cond $hw.recommended (emojify ":heavy_check_mark:") (emojify ":x:") }}