Add registerLink and parseTime

This commit is contained in:
Jared He 2021-06-13 12:46:05 -05:00
parent b22c7058a5
commit c4a0e60760
7 changed files with 73 additions and 1914 deletions

View File

@ -1,17 +1,17 @@
export const metadata = {
name: "CSC BOT & Game Night",
short: "Learn about our plans for the term and play some games with us.",
date: "Mon May 17 2021 20:00:00 GMT-0500 (Central Daylight Time)",
online: TODO FIX THIS,
location: "Online",
registerLink: TODO FIX THIS,
date: "Mon May 17 2021 21:00:00 GMT-0500 (Central Daylight Time)",
online: false,
location: "DC",
registerLink: "no link"
}
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!
Afterwards, stick around for a relaxing and fun game night. See you there!
# Here, I am also testing with
# Here, I am also testing with
## Many headings, as well as **bold text** and *italics*

View File

@ -1,10 +1,10 @@
export const metadata = {
name: "CSC x SE Soc: Interview Prep",
short: "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).",
date: "Mon May 24 2021 19:00:00 GMT-0500 (Central Daylight Time)",
online: TODO FIX THIS,
date: "Mon May 24 2021 20:00:00 GMT-0500 (Central Daylight Time)",
online: true,
location: "Online",
registerLink: TODO FIX THIS,
registerLink: "http://bit.ly/csc-sesoc-interview-prep-signup"
}
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?
@ -13,7 +13,7 @@ We've got you covered at our CSC x SE Soc Interview Prep Workshop this Monday, M
Registration isn't required, we'll just be sending you an email reminder, as well as inviting you to our calendar event!
The event will be hosted on Twitch at [https://www.twitch.tv/uwcsclub](<https://www.twitch.tv/uwcsclub>)
The event will be hosted on Twitch at [http://bit.ly/csc-sesoc-interview-prep-signup](<http://bit.ly/csc-sesoc-interview-prep-signup>)
Register at [http://bit.ly/csc-sesoc-interview-prep-signup](<http://bit.ly/csc-sesoc-interview-prep-signup>)!
Register at!

View File

@ -19,6 +19,29 @@ fs.readFile("./event-test.xml", "utf8", (err, data) => {
parseXML(data);
});
const parseTime = (dateStr, timeStr) => {
if (/-/.exec(timeStr)) {
console.error(`${timeStr} has date a range`);
return;
}
// converting cases like 7pm to 7PM
timeStr = timeStr.toUpperCase();
// converting cases like 7PM to 7 PM
if (/[0-9](a|A|p|P)/g.exec(timeStr)) {
timeStr = timeStr.replace(/[0-9](?=(a|A|p|P))/g, "$& ");
}
// converting cases like 7 PM to 7:00 PM
if (/(?<!:[0-9])[0-9] (a|A|p|P)/g.exec(timeStr)) {
timeStr = timeStr.replace(/[0-9](?= )/, "$&:00");
}
// convert from CST to EST
const OFFSET_FROM_EST = +1;
let date = new Date(`${dateStr} ${timeStr}`);
date.setHours(date.getHours() + OFFSET_FROM_EST);
return date;
};
const parseXML = (XML) => {
const js = xmlJs.xml2js(XML);
@ -30,16 +53,25 @@ const parseXML = (XML) => {
short = short.replace(/\n+$/, "");
const dateStr = js.elements[0].elements[i].attributes.date;
const timeStr = js.elements[0].elements[i].attributes.time;
const date = new Date(`${dateStr} ${timeStr} EST`); // need to add EST
const room = js.elements[0].elements[i].attributes.room;
// const online
// const location
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])
);
const mdx = `export const metadata = {\n name: "${title}",\n short: "${short}",\n date: "${date}",\n online: TODO FIX THIS,\n location: "${room}",\n registerLink: TODO FIX THIS,\n}\n\n${abstract}`;
let registerLink = "";
// detects a link in markdown
const markdownLinkDetectRegex = /(?<=\[(.*)\]\(<)(.*)(?=>\))/;
if (markdownLinkDetectRegex.exec(abstract)) {
registerLink = markdownLinkDetectRegex.exec(abstract)[0];
} else {
registerLink = "no link";
}
console.log(registerLink);
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(`${mdxTitle}.mdx`, mdx, function (err) {

View File

@ -1,6 +1,6 @@
<eventdefs>
<eventitem date="2021-05-24" time="7:00:00 PM" room="Online" title="CSC x SE Soc: Interview Prep">
<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>
@ -8,11 +8,11 @@
<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="https://www.twitch.tv/uwcsclub">https://www.twitch.tv/uwcsclub</a></p>
<p>Register at <a href="http://bit.ly/csc-sesoc-interview-prep-signup">http://bit.ly/csc-sesoc-interview-prep-signup</a>!</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="8:00 pm" room="Online" title="CSC BOT &#38; Game Night">
<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.
@ -21,7 +21,7 @@
<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>
<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>

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,5 @@
{
"dependencies": {
"breakdance": "^3.0.1",
"cheerio": "^0.22.0",
"showdown": "^1.9.1",
"xml-js": "^1.6.11"
}

View File

@ -0,0 +1,20 @@
const parseTime = (dateStr, timeStr) => {
if (/-/.exec(timeStr)) {
console.error(`${timeStr} has date a range`);
return;
}
timeStr = timeStr.toUpperCase() // converting cases like 7PM to 7PM
if (/[0-9](a|A|p|P)/g.exec(timeStr)) { // converting cases like 7PM to 7 PM
timeStr = timeStr.replace(/[0-9](?=(a|A|p|P))/g, "$& ");
}
if (/(?<!:[0-9])[0-9] (a|A|p|P)/g.exec(timeStr)) { // converting cases like 7 PM to 7:00 PM
timeStr = timeStr.replace(/[0-9](?= )/, "$&:00");
}
let date = new Date(`${dateStr} ${timeStr}`); // convert from CST to EST
date.setHours(date.getHours() + 1);
console.log(date.toString());
return date;
}