Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-news #4

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,60 @@ Pygfx (py-graphics) is built on WebGPU, enabling superior performance and reliab

## <i class='fas'></i> News

* `04-10-2024` Released [wgpu-py v0.19.0](https://github.com/pygfx/wgpu-py/releases/tag/v0.19.0)
* `25-09-2024` Released [pygfx v0.5.0](https://github.com/pygfx/pygfx/releases/tag/v0.5.0)
<div id='news-div'></div>

<script>

async function get_release_info(repo) {
let url = "https://api.github.com/repos/" + repo + "/releases?per_page=2";
try {
let response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
let json = await response.json();
let releases = [];
for (let i=0; i<json.length; i++) {
let date = new Date(json[i].published_at);
info = {
name: repo.split("/").slice(-1),
tag: json[i].tag_name,
url: json[i].html_url,
date: date,
};
releases.push(info);
}
return releases;
} catch (error) {
console.warn("Could not fetch release info for "+ repo + ": " + error.message);
}
}

async function create_news() {
let repos = ["pygfx/pygfx", "pygfx/wgpu-py", "pygfx/rendercanvas"];
let releases = [];
for (let repo of repos) {
let repo_releases = await get_release_info(repo);
releases.push(...repo_releases);
}

releases.sort((a, b) => (a.date < b.date));

let news_div = document.getElementById("news-div");
news_div.innerHTML = "";
let ul = document.createElement("ul");
news_div.appendChild(ul);
for (release of releases) {
// let d = release.date.toUTCString().split(" ").slice(0, 4).join(" ");
let d = release.date.toISOString().split("T")[0].split("-").reverse().join("-")
let li = document.createElement("li");
li.innerHTML = "<code>" + d + "</code> Release " + release.name + " <a href='" + release.url + "'>" + release.tag + "</a>"
ul.appendChild(li);
}
}

create_news();
</script>


## <i class='fas'></i> Getting started
Expand Down