diff options
author | Daniil Baturin <daniil@baturin.org> | 2024-05-16 14:40:18 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2024-05-16 14:40:18 +0100 |
commit | 1db485a14594f325462fb1f1e41451b893d7aa10 (patch) | |
tree | 16a3baeba9d9080aebbde343ac5cecff5c317bc7 /plugins/release-status.lua | |
parent | 1ade4fc385ea79e331438e15bba6b3c24a9a0814 (diff) | |
download | community.vyos.net-1db485a14594f325462fb1f1e41451b893d7aa10.tar.gz community.vyos.net-1db485a14594f325462fb1f1e41451b893d7aa10.zip |
Add release status page
Diffstat (limited to 'plugins/release-status.lua')
-rw-r--r-- | plugins/release-status.lua | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/plugins/release-status.lua b/plugins/release-status.lua new file mode 100644 index 0000000..d7b0fd7 --- /dev/null +++ b/plugins/release-status.lua @@ -0,0 +1,62 @@ +selector = config["selector"] +path = config["file"] +text = config["text"] + +if not selector then + Log.warning("`selector' must be configured.") +elseif path and text then + Log.warning("Only one of `path' and `text' can be specified.") +elseif text then + toml_string = text +elseif path then + toml_string = Sys.read_file(path) +else + Log.warning("Either `path' or `text' must be specified.") +end + +function generate_table(vyos_version, version_table) + local target_elem = HTML.select_one(page, selector) + + local codename_header = HTML.create_element("h3", vyos_version) + HTML.set_attribute(codename_header, "id", vyos_version) + HTML.add_class(codename_header, "version") + local codename_anchor = HTML.create_element("a") + HTML.set_attribute(codename_anchor, "href", "#" .. vyos_version) + HTML.append_child(codename_anchor, codename_header) + HTML.append_child(target_elem, codename_anchor) + + local version_string = version_table["latest"] + local version_header = HTML.create_element("h4", version_string) + HTML.set_attribute(version_header, "id", version_string) + local version_anchor = HTML.create_element("a") + HTML.set_attribute(version_anchor, "href", "#" .. version_string) + HTML.append_child(version_anchor, version_header) + HTML.append_child(target_elem, version_anchor) + + local notes_string = version_table["notes"] + if notes_string then + local notes = HTML.create_element("p", notes_string) + HTML.append_child(target_elem, notes) + end + + local status_table = HTML.create_element("table") + HTML.append_child(status_table, HTML.parse("<tr><th>CVE</th><th>Name</th><th>Description</th><th>Status</th></tr>")) + + local i = 1 + while version_table["security_advisory"][i] do + local row = version_table["security_advisory"][i] + local advisory = HTML.create_element("tr") + HTML.append_child(advisory, HTML.create_element("td", row["cve"])) + HTML.append_child(advisory, HTML.create_element("td", row["title"])) + HTML.append_child(advisory, HTML.create_element("td", row["description"])) + HTML.append_child(advisory, HTML.create_element("td", row["status"])) + HTML.append_child(status_table, advisory) + i = i + 1 + end + HTML.append_child(HTML.select_one(page, selector), status_table) +end + +if toml_string then + local toml_table = TOML.from_string(toml_string) + Table.iter_ordered(generate_table, toml_table["release"]) +end |