Readme

Polls the Vulkan specification repository for specification updates. If found, sends an email and makes a post on /r/vulkan.

Runs every 15 min
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { fetch } from "https://esm.town/v/std/fetch";
import { set } from "https://esm.town/v/std/set?v=11";
import { getRedditAccessToken } from "https://esm.town/v/tambre/getRedditAccessToken";
import { email } from "https://esm.town/v/std/email?v=9";
let { lastVulkanRSSFeedTime } = await import("https://esm.town/v/tambre/lastVulkanRSSFeedTime");
import { parseXML } from "https://esm.town/v/stevekrouse/parseXML?v=1";
export async function pollVulkanRSSFeed({ lastRunAt }: Interval) {
const githubProject = "https://github.com/KhronosGroup/Vulkan-Docs";
const response = await fetch(`${githubProject}/commits.atom`);
const feed =
(await parseXML(await response.text())).feed;
const entries = feed.entry.filter((entry) =>
new Date(lastVulkanRSSFeedTime) < new Date(entry.updated)
);
for (const entry of entries) {
const titles = entry.title.match(/Vulkan \d+\.\d+\.\d+ spec update/);
if (!titles || !titles.length) {
continue;
}
const title = titles[0];
const url = `${githubProject}/commit/${entry.id.match(/Commit\/(.+)/)[1]}`;
await email({
html: `<a href="${url}">Vulkan-Docs commit</a>\n\n${entry.content}`,
subject: title,
});
const formData = new URLSearchParams();
formData.append("kind", "link");
formData.append("sr", "vulkan");
formData.append("title", title);
formData.append("url", url);
formData.append("send_replies", "true");
const result = await fetch("https://oauth.reddit.com/api/submit", {
method: "POST",
headers: {
"Authorization": `Bearer ${await getRedditAccessToken()}`,
"Content-Type": "application/x-www-form-urlencoded",
},
body: formData.toString(),
});
console.info(`${result.status}: ${await result.text()}`);
lastVulkanRSSFeedTime = new Date(entry.updated).toISOString();
}
await set(
"lastVulkanRSSFeedTime",
lastVulkanRSSFeedTime,
);
return entries;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023