Fix filenames, commented out events

This commit is contained in:
Jared He 2021-06-13 20:28:12 -05:00
parent 31a3a21dbc
commit 8b684b1236
4 changed files with 11460 additions and 75 deletions

View File

@ -7,11 +7,7 @@ var showdown = require("showdown");
const converterShowdown = new showdown.Converter();
const xmlJs = require("xml-js");
const useShowdown = (HTML) => {
return converterShowdown.makeMarkdown(HTML);
};
fs.readFile("./event-test.xml", "utf8", (err, data) => {
fs.readFile("./events.xml", "utf8", (err, data) => {
if (err) {
console.error(err);
return;
@ -19,9 +15,13 @@ fs.readFile("./event-test.xml", "utf8", (err, data) => {
parseXML(data);
});
const parseTime = (dateStr, timeStr) => {
fs.mkdir("./markdown-events/", { recursive: true }, (err) => {
if (err) throw err;
});
const parseTime = (dateStr, timeStr, title, currentTerm) => {
if (/-/.exec(timeStr)) {
console.error(`${timeStr} has date a range`);
console.error(`${title}, ${currentTerm} has a date range: ${timeStr}`);
return;
}
// converting cases like 7pm to 7PM
@ -44,36 +44,68 @@ const parseTime = (dateStr, timeStr) => {
const parseXML = (XML) => {
const js = xmlJs.xml2js(XML);
let currentTerm = "";
for (let i = 0; i < js.elements[0].elements.length; ++i) {
const title = js.elements[0].elements[i].attributes.title;
let short = useShowdown(
xmlJs.js2xml(js.elements[0].elements[i].elements[0])
);
// remove trailing newlines from short
short = short.replace(/\n+$/, "");
const dateStr = js.elements[0].elements[i].attributes.date;
const timeStr = js.elements[0].elements[i].attributes.time;
const date = parseTime(dateStr, timeStr);
const location = js.elements[0].elements[i].attributes.room;
const online = location.toLowerCase() === "online" ? true : false;
const abstract = useShowdown(
xmlJs.js2xml(js.elements[0].elements[i].elements[1])
);
let registerLink = "";
// detects a link in markdown
const markdownLinkDetectRegex = /(?<=\[(.*)\]\(<)(.*)(?=>\))/;
if (markdownLinkDetectRegex.exec(abstract)) {
registerLink = markdownLinkDetectRegex.exec(abstract)[0];
} else {
registerLink = "no link";
if (js.elements[0].elements[i].type === "comment") {
// sometimes there's events that are commented out, hopefully this catches that
if (
/(winter)|(fall)|(spring)/.exec(
js.elements[0].elements[i].comment.toLowerCase()
)
) {
currentTerm = js.elements[0].elements[i].comment.replace(
/(\s+|:+)/g,
"-"
);
}
} else if (js.elements[0].elements[i].type === "element") {
const title = js.elements[0].elements[i].attributes.title;
let short = converterShowdown.makeMarkdown(
xmlJs.js2xml(js.elements[0].elements[i].elements[0])
);
// remove newlines from short
short = short.replace(/\n/g, "");
const dateStr = js.elements[0].elements[i].attributes.date;
const timeStr = js.elements[0].elements[i].attributes.time;
const date = parseTime(dateStr, timeStr, title, currentTerm);
const location = js.elements[0].elements[i].attributes.room;
const online = location.toLowerCase() === "online" ? true : false;
let abstract = "undefined";
if (js.elements[0].elements[i].elements[1] === undefined) {
console.error(`${title}, ${currentTerm} has no abstract`);
} else {
abstract = converterShowdown.makeMarkdown(
xmlJs.js2xml(js.elements[0].elements[i].elements[1])
);
}
let registerLink = "";
// detects a link in markdown such as [CSC Club Website](<http://csclub.uwaterloo.ca//>)
const markdownLinkDetectRegex = /(?<=\[(.*)\]\(<)(.*)(?=>\))/;
if (markdownLinkDetectRegex.exec(abstract)) {
registerLink = markdownLinkDetectRegex.exec(abstract)[0];
} else {
registerLink = "no link";
}
const mdx = `export const metadata = {\n name: "${title}",\n short: "${short}",\n date: "${date}",\n online: ${online},\n location: "${location}",\n registerLink: "${registerLink}"\n}\n\n${abstract}`;
// remove invalid characters from filenames
let mdxTitle = title.replace(/[\\\\/:*?\"<>|]/g, "");
mdxTitle = mdxTitle.replace(/(\s+)/g, "-");
fs.mkdir(
`./markdown-events/${currentTerm}`,
{ recursive: true },
(err) => {
if (err) throw err;
}
);
fs.writeFile(
`./markdown-events/${currentTerm}/${mdxTitle}.mdx`,
mdx,
(err) => {
if (err) throw err;
}
);
}
const mdx = `export const metadata = {\n name: "${title}",\n short: "${short}",\n date: "${date}",\n online: ${online},\n location: "${location}",\n registerLink: "${registerLink}"\n}\n\n${abstract}`;
const mdxTitle = title.replace(/(\s+|:+)/g, "-");
fs.writeFile(`./markdown-events/${mdxTitle}.mdx`, mdx, function (err) {
if (err) return console.log(err);
});
}
};

View File

@ -1,39 +0,0 @@
<eventdefs>
<eventitem date="2021-05-24" time="7:00PM" room="Online" title="CSC x SE Soc: Interview Prep">
<short>
<p>CSC and SE Soc are hosting an Interview Prep Workshop next week! Join Kristy Gao and Bimesh De Silva as they review the interview process, from behavioural to technical interviews. They'll finish off with live mock interviews, and the event will be held on Twitch (https://www.twitch.tv/uwcsclub).</p>
</short>
<abstract>
<p>Browsing through your unsolved Leetcode problems? Flipping open CTCI for the first time? Have no clue what to expect from a technical interview or just need an interview refresher? </p>
<p>We've got you covered at our CSC x SE Soc Interview Prep Workshop this Monday, May 24th from 7:00-8:30pm ET! Live-streamed on Twitch, Kristy Gao and Bimesh De Silva will be walking through important aspects of the interview process from coding challenges to behavioural interviews to algorithmic interviews, go through some live mock interviews, and share their tips and techniques along the way!</p>
<p>Registration isn't required, we'll just be sending you an email reminder, as well as inviting you to our calendar event!</p>
<p>The event will be hosted on Twitch at <a href="http://bit.ly/csc-sesoc-interview-prep-signup">http://bit.ly/csc-sesoc-interview-prep-signup</a></p>
<p>Register at!</p>
</abstract>
</eventitem>
<eventitem date="2021-05-17" time="8pm" room="DC" title="CSC BOT &#38; Game Night">
<short>
<p>
Learn about our plans for the term and play some games with us.
</p>
</short>
<abstract>
<p>Kick off your Spring term with CSC! Come join us on Discord to learn more about what we'll be up to this term and how you can participate!</p>
<p>Afterwards, stick around for a relaxing and fun game night. See you there!</p>
<h1>Here, I am also testing with </h1>
<h2>Many headings, as well as <strong>bold text</strong> and <i>italics</i></h2>
<h4>More headings</h4>
<ul>
<li>One</li>
<li>Unordered</li>
<li>List</li>
</ul>
<ol>
<li>One</li>
<li>Ordered</li>
<li>List</li>
</ol>
</abstract>
</eventitem>
</eventdefs>

View File

@ -0,0 +1,76 @@
<eventdefs>
<!-- Spring 2021 -->
<eventitem date="2021-05-24" time="7:00PM" room="Online" title="CSC x SE Soc: Interview Prep">
<short>
<p>CSC and SE Soc are hosting an Interview Prep Workshop next week! Join Kristy Gao and Bimesh De Silva as they review the interview process, from behavioural to technical interviews. They'll finish off with live mock interviews, and the event will be held on Twitch (https://www.twitch.tv/uwcsclub).</p>
</short>
<abstract>
<p>Browsing through your unsolved Leetcode problems? Flipping open CTCI for the first time? Have no clue what to expect from a technical interview or just need an interview refresher? </p>
<p>We've got you covered at our CSC x SE Soc Interview Prep Workshop this Monday, May 24th from 7:00-8:30pm ET! Live-streamed on Twitch, Kristy Gao and Bimesh De Silva will be walking through important aspects of the interview process from coding challenges to behavioural interviews to algorithmic interviews, go through some live mock interviews, and share their tips and techniques along the way!</p>
<p>Registration isn't required, we'll just be sending you an email reminder, as well as inviting you to our calendar event!</p>
<p>The event will be hosted on Twitch at <a href="http://bit.ly/csc-sesoc-interview-prep-signup">http://bit.ly/csc-sesoc-interview-prep-signup</a></p>
<p>Register at!</p>
</abstract>
</eventitem>
<!-- Winter 2021-->
<eventitem date="2021-05-17" time="8pm" room="DC" title="CSC BOT &#38; Game Night">
<short>
<p>
Learn about our plans for the term and play some games with us.
</p>
</short>
<abstract>
<p>Kick off your Spring term with CSC! Come join us on Discord to learn more about what we'll be up to this term and how you can participate!</p>
<p>Afterwards, stick around for a relaxing and fun game night. See you there!</p>
<h1>Here, I am also testing with </h1>
<h2>Many headings, as well as <strong>bold text</strong> and <i>italics</i></h2>
<h4>More headings</h4>
<ul>
<li>One</li>
<li>Unordered</li>
<li>List</li>
</ul>
<ol>
<li>One</li>
<li>Ordered</li>
<li>List</li>
</ol>
</abstract>
</eventitem>
<eventitem date="2018-11-05" time="5:30 pm" room="MC-4063"
title="BBC micro:bit computer: What is it good for?">
<short>
<p>
Professor Richard Mann will be talking about the BBC micro:bit, an embedded computer that is popular with hobbyists and comes with a variety of peripherals.
</p>
</short>
<abstract>
<p>This talk was cancelled. The material for the talk can be found <a href="http://www.cs.uwaterloo.ca/~mannr">here.</a></p>
<h3>Abstract:</h3>
<p>
BBC micro:bit (microbit.org) was introduced in 2015 and has since become popular with educators and hobbyists.
</p><p>
Micro:bit uses an ARM Cortex M0 processor running the "mbed" OS/runtime (mbed.arm.com). It has a built in LED 7x7 array, two buttons, compass, accelerometer, infra red transceivers, and low power wireless communication. Most importantly, it has multiple analog and digital pins to connect to the external world.
</p><p>
Web based tools compile gui/blocks, javascript, or python to executable (HEX) files that run on the device. The device appears as a USB drive. It is programmed by copying (dragging) the HEX image to the device. Once programmed, the device runs standalone and communicates with the the host computer via a serial port API.
</p><p>
All of this is great fun and a gateway into electronics and real time programming.
</p><p>
In this talk I will present a brief introduction to micro:bit, electronics, and electronic signal measurement (voltmeter, function generator, oscilloscope).
</p><p>
We will measure the run time performance of the micro:bit, in particular the operation of the analog inputs and outputs and the response time/latency of the device and consider its suitability for user interface, music and audio projects.
</p>
<h3>Bio:</h3>
<p>
Richard Mann is Associate Professor in Computer Science. His research is in AI, Sound/Audio, Acoustics, and Electro/acoustic measurement. Details at www.cs.uwaterloo.ca/~mannr
</p><p>
In W19 I will teach: CS489 -- Advanced topics, Computational Sound and Audio. This is a project-based course (no final).
</p><p>
I am also looking for URA students in the Sound/Audio area.
</p>
</abstract>
</eventitem>
</eventdefs>

11316
scripts/mdx-scripts/events.xml Normal file

File diff suppressed because it is too large Load Diff