Use libxmljs to increase readability

This commit is contained in:
Jared He 2021-06-14 13:29:36 -04:00
parent 55dc7cfbfa
commit d8d371d99c
5 changed files with 736 additions and 1033 deletions

View File

@ -5,7 +5,7 @@ const { window } = new JSDOM("");
global.window = window;
var showdown = require("showdown");
const converterShowdown = new showdown.Converter();
const xmlJs = require("xml-js");
const libxmljs = require("libxmljs");
fs.readFile("./events.xml", "utf8", (err, data) => {
if (err) {
@ -19,9 +19,10 @@ fs.mkdir("./markdown-events/", { recursive: true }, (err) => {
if (err) throw err;
});
const parseTime = (dateStr, timeStr, title, currentTerm) => {
const parseTime = (dateStr, timeStr) => {
// if timeStr is a range (ex. 7pm - 9pm) we take the first time (ex. 7pm)
if (/-/.exec(timeStr)) {
timeStr = timeStr.split('-')[0];
timeStr = timeStr.split("-")[0];
}
// converting cases like 7pm to 7PM
timeStr = timeStr.toUpperCase();
@ -40,64 +41,72 @@ const parseTime = (dateStr, timeStr, title, currentTerm) => {
return date;
};
const nodeChildrenToString = (nodeChildren) => {
let string = "";
for (let i = 0; i < nodeChildren.length; ++i) {
if (nodeChildren[i].type() === "text") {
string += nodeChildren[i];
} else {
string += nodeChildren[i].toString();
}
}
return string;
};
const parseXML = (XML) => {
const js = xmlJs.xml2js(XML);
const xmlDoc = libxmljs.parseHtml(XML);
let eventdefsChildren = xmlDoc.get("//eventdefs").childNodes();
let currentTerm = "";
for (let i = 0; i < js.elements[0].elements.length; ++i) {
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;
for (let i = 0; i < eventdefsChildren.length; ++i) {
// sometimes there's events that are commented out, hopefully this catches that
if (
eventdefsChildren[i].type() === "comment" &&
/((winter)|(fall)|(spring))/.exec(
eventdefsChildren[i].toString().toLowerCase()
)
) {
currentTerm = eventdefsChildren[i].text().replace(/(\s+|:+)/g, "-");
} else if (eventdefsChildren[i].type() === "element") {
const title = eventdefsChildren[i].attr("title").value();
const shortNodes = eventdefsChildren[i].get(".//short").childNodes();
let short = converterShowdown.makeMarkdown(
xmlJs.js2xml(js.elements[0].elements[i].elements[0])
nodeChildrenToString(shortNodes)
);
// 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 dateStr = eventdefsChildren[i].attr("date").value();
const timeStr = eventdefsChildren[i].attr("time").value();
const date = parseTime(dateStr, timeStr);
const location = eventdefsChildren[i].attr("room").value();
const online = location.toLowerCase() === "online" ? true : false;
let abstract = "undefined";
if (js.elements[0].elements[i].elements[1] === undefined) {
abstract = short;
} else {
let abstract = short;
if (eventdefsChildren[i].get(".//abstract") !== undefined) {
const abstractNodes = eventdefsChildren[i]
.get(".//abstract")
.childNodes();
abstract = converterShowdown.makeMarkdown(
xmlJs.js2xml(js.elements[0].elements[i].elements[1])
nodeChildrenToString(abstractNodes)
);
abstract = abstract.replace(/<br>/g, "\n");
}
let registerLink = null;
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];
registerLink = `\n registerLink: "${
markdownLinkDetectRegex.exec(abstract)[0]
}",`;
}
let mdx = `export const metadata = {
name: "${title}",
short: "${short}",
date: new Date("${date.toString()}"),
online: ${online},
location: "${location}"`;
registerLink
? (mdx += `,
registerLink: "${registerLink}"`)
: (mdx += "");
mdx += `
location: "${location}",${registerLink}
}
${abstract}`;
// remove invalid characters from filenames
let mdxTitle = title.replace(/[\\\\/:*?\"<>|]/g, "");
mdxTitle = mdxTitle.replace(/(\s+)/g, "-");

View File

@ -1,36 +1,103 @@
<?xml version='1.0'?>
<eventdefs>
<!-- Spring 2021 -->
<eventitem date="2015-07-08" time="5pm" room="MC 4060"
title="Infrasound is all around us">
<short>
<p>
Ambient infra sound surrounds us. Richard Mann presents his current
research and equipment on measuring infra sound, and samples of recorded
infra sound.
<!-- Fall 2016 -->
<eventitem date="2016-12-05" time="6:00 PM" room="MC Comfy" title="CSC/PMC EOT Party">
<short>
<p>
The CSC and the PMAMC&amp;OC (aka pure math club) are hosting our end
of term events together! We'll be taking over MC Comfy to hang out,
eat lots of food (from Kismet!), and play board games.
</p>
</short>
<abstract>
<p>
Infra sound refers to sound waves below the range of human hearing.
Infra sound comes from a number of natural phenomena including weather
changes, thunder, and ocean waves. Common man made sources include
heating and ventilation systems, industrial machinery, moving vehicle
cabins (air, trains, cars), and energy generation (wind turbines, gas
plants).
<br></br>
In this talk Richard Mann will present equipment he has built to measure infra sound, and
analyse some of the infra sound he has recorded.
<br />
Note: In Winter 2016 Richard Mann will be offering a new course, in Computer Sound. The
course will appear as CS489/CS689 ("Topics in Computer Science").
Karsten
This
is a project-based course (60% assignments, 40% project, no final).
Details at his web page,
<a href="http://www.cs.uwaterloo.ca/~mannr">~mannr</a>.
<abstract>
<p>
The CSC and the PMAMC&amp;OC (aka pure math club) are hosting our end
of term events together! We'll be taking over MC Comfy to hang out,
eat lots of food (from Kismet!), and play board games.
</p>
</abstract>
</eventitem>
<eventitem date="2016-11-21" time="6:15 PM" room="MC 4063" title="Richard Mann Prof Talk">
<short>
<p>
Professor Richard Mann will be giving a talk, titled "Open Source
Software for Sound Measurement and Analysis". He will be presenting
information about his new course, CS 489, Computational Sound, which
will be running in Winter 2017.
</p>
</short>
<abstract>
<p>
Professor Richard Mann will be giving a talk, titled "Open Source
Software for Sound Measurement and Analysis". He will be presenting
information about his new course, CS 489, Computational Sound, which
will be running in Winter 2017. The abstract for this talk is below.
<br/><br/>
</p>
<p>
The most common problem in acoustics is to measure the frequency
response of an (expensive!) listening room. While specifications
exist for the amplifiers, speakers, etc, each system must be still
evaluated individually, since the frequency response depends on the
direct sound from the speaker(s), the listener position and the
reverberation of the room. The user may spend considerable time
adjusting the speaker placement, the system equalization, and
possibly treating the room to get the best response.
</p>
<p>
There are several commercial and freeware applications for this task,
some of which are very good. However, to learn the methods the user
must understand the processing involved.
</p>
<p>
The purpose of this talk is to present an open source solution. Our
system is based on a very few lines of code, written in GNU Octave, a
Matlab(r) workalike that runs under Linux, Windows and Mac.
</p>
<p>
The program works by playing a known test signal, such a tone, or
some kind of noise source out of the sound card into the system. The
system is measured by comparing driving signal to that measured by a
microphone in the room. The frequency response is computed using the
Discrete Fourier Transform (DFT).
</p>
<p>
This is joint work with Prof. John Vanderkooy, Physics, University of
Waterloo.
</p>
</abstract>
</eventitem>
<eventitem date="2016-11-16" time="8:30 PM" room="M3 1006" title="General Meeting">
<short>
<p>
This general meeting will be held to discuss changes to our Code of
Conduct.
</p>
</short>
<abstract>
<p> The Code of Conduct and the amended version can be found below: </p>
<ul>
<li><a href="https://www.csclub.uwaterloo.ca/~exec/proposed-amendment/about/code-of-conduct">Proposed CoC</a></li>
<li><a href="https://www.csclub.uwaterloo.ca/~exec/proposed-amendment.patch">Diff between current and proposed CoC</a></li>
</ul>
</abstract>
</eventitem>
<eventitem date="2016-11-16" time="6:30 pm" room="M3 1006" title="Code Party">
<short>
<p>
Come code with us, eat some food, do some things.
Personal projects you want to work on? Homework
projects you need to finish? Or want some time to explore
some new technology and chat about it? You can join us at Code Party
and do it, with great company and great food.
</p>
</short>
</eventitem>
</eventdefs>

View File

@ -1,5 +1,7 @@
<?xml version='1.0'?>
<eventdefs>
<!-- Summer 2021 -->
<!-- Spring 2021 -->
<eventitem date="2021-05-24" time="7 PM" 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>
@ -793,6 +795,7 @@ Come listen to lightning tech talks by fellow students that will knock your meta
</p>
</abstract>
</eventitem>
<eventitem date="2018-10-03" time="7:00 pm" room="Columbia Lake Firepit 2"
title="CSC &amp; WiCS &amp; MathSoc go outside!">
<short>
@ -1873,98 +1876,7 @@ A talk and demo about more advanced Unix tricks and tools than are taught in our
</abstract>
</eventitem>
<eventitem date="2016-11-30" time="6:00 PM" room="MC 4063" title="ALT+TAB Talks">
<short>
<p>
Various members of the CSC will be giving brief, 25 minute talks on
CS-related topics. An list of the talks being delivered can be found
if you follow the event page link in this description. There will be
food provided.
</p>
</short>
<abstract>
<p>
The CSC is hosting ALT+TAB this Wednesday. ALT+TAB is similar to the
PMC's SASMS events; several members of the CSC will give brief, 25
minute talks on various interesting topics in CS. There will be food
provided at the event. The talks being delivered are:
<table border="1">
<tr>
<td><b>Member</b></td>
<td><b>Talk Title</b></td>
</tr>
<tr>
<td>Felix Bauckholt</td>
<td>A Short Idris Tutorial</td>
</tr>
<tr>
<td>Bryan Coutts</td>
<td>Linear and Integer Programming</td>
</tr>
<tr>
<td>Sean Harrap</td>
<td>Communication Complexity</td>
</tr>
<tr>
<td>Christopher Hawthorne</td>
<td>Gödel's Incompleteness Theorem</td>
</tr>
<tr>
<td>Charlie Wang</td>
<td>Typed Racket</td>
</tr>
<tr>
<td>Ifaz Kabir</td>
<td>How Modern SAT Solvers Work</td>
</tr>
</table>
</p>
</abstract>
</eventitem>
<eventitem date="2016-11-25" time="6:00 PM" room="MC 4063" title="Edmund Noble Member Talk">
<short>
<p>
CSC member Edmund Noble will be giving a talk, titled "Purely
Functional Programming with Freely-Generated Domain Specific
Languages". The talk will focus on embedded DSLs that exist within
other languages, and how they can easily be constructed.
</p>
</short>
<abstract>
<p>
CSC member Edmund Noble will be giving a talk, titled "Purely
Functional Programming with Freely-Generated Domain Specific
Languages". The talk will focus on embedded DSLs that exist within
other languages, and how they can easily be constructed. The abstract
for this talk is below. <br/><br/>
</p>
<p>
Dependency injection is an often-used technique in object-oriented
programming to easily modify the behaviours of an object by providing
it with objects it would have otherwise generated on its own, to
increase modularity. Aspect-oriented programming is a related
technique which adds additional behaviour ("advice") to existing code,
aiming to address cross-cutting concerns which affect wide areas of an
application without sacrificing modularity. Dependency injection
might not seem a common topic in functional programming, but
application modularity is essential to functional programming in a
practical setting. A natural analogue to dependency injection and
aspect-oriented programming in functional programming comes from a
surprising place, and offers superior modularity to both. The free
monad (F f) for a type constructor (and domain-specific language
instruction set) f provides a syntax tree with internal nodes as
domain-specific language instructions, which in combination with
coproduct functors, allow domain-specific languages to be composed and
combined easily.
<ul>
<li><a href="http://slides.com/edmundnoble/freely-generated-domain-specific-languages/fullscreen#">Slides</a></li>
<li><a href="https://github.com/edmundnoble/free-dsl">Sources</a></li>
</ul>
</p>
</abstract>
</eventitem>
<eventitem date="2016-11-21" time="6:15 PM" room="MC 4063" title="Richard Mann Prof Talk">
<short>
@ -2423,8 +2335,98 @@ There will be a break for food halfway through.
</abstract>
</eventitem>
<eventitem date="2016-11-30" time="6:00 PM" room="MC 4063" title="ALT+TAB Talks">
<short>
<p>
Various members of the CSC will be giving brief, 25 minute talks on
CS-related topics. An list of the talks being delivered can be found
if you follow the event page link in this description. There will be
food provided.
</p>
</short>
<abstract>
<p>
The CSC is hosting ALT+TAB this Wednesday. ALT+TAB is similar to the
PMC's SASMS events; several members of the CSC will give brief, 25
minute talks on various interesting topics in CS. There will be food
provided at the event. The talks being delivered are:
<table border="1">
<tr>
<td><b>Member</b></td>
<td><b>Talk Title</b></td>
</tr>
<tr>
<td>Felix Bauckholt</td>
<td>A Short Idris Tutorial</td>
</tr>
<tr>
<td>Bryan Coutts</td>
<td>Linear and Integer Programming</td>
</tr>
<tr>
<td>Sean Harrap</td>
<td>Communication Complexity</td>
</tr>
<tr>
<td>Christopher Hawthorne</td>
<td>Gödel's Incompleteness Theorem</td>
</tr>
<tr>
<td>Charlie Wang</td>
<td>Typed Racket</td>
</tr>
<tr>
<td>Ifaz Kabir</td>
<td>How Modern SAT Solvers Work</td>
</tr>
</table>
</p>
</abstract>
</eventitem>
<eventitem date="2016-11-25" time="6:00 PM" room="MC 4063" title="Edmund Noble Member Talk">
<short>
<p>
CSC member Edmund Noble will be giving a talk, titled "Purely
Functional Programming with Freely-Generated Domain Specific
Languages". The talk will focus on embedded DSLs that exist within
other languages, and how they can easily be constructed.
</p>
</short>
<abstract>
<p>
CSC member Edmund Noble will be giving a talk, titled "Purely
Functional Programming with Freely-Generated Domain Specific
Languages". The talk will focus on embedded DSLs that exist within
other languages, and how they can easily be constructed. The abstract
for this talk is below. <br/><br/>
</p>
<p>
Dependency injection is an often-used technique in object-oriented
programming to easily modify the behaviours of an object by providing
it with objects it would have otherwise generated on its own, to
increase modularity. Aspect-oriented programming is a related
technique which adds additional behaviour ("advice") to existing code,
aiming to address cross-cutting concerns which affect wide areas of an
application without sacrificing modularity. Dependency injection
might not seem a common topic in functional programming, but
application modularity is essential to functional programming in a
practical setting. A natural analogue to dependency injection and
aspect-oriented programming in functional programming comes from a
surprising place, and offers superior modularity to both. The free
monad (F f) for a type constructor (and domain-specific language
instruction set) f provides a syntax tree with internal nodes as
domain-specific language instructions, which in combination with
coproduct functors, allow domain-specific languages to be composed and
combined easily.
<ul>
<li><a href="http://slides.com/edmundnoble/freely-generated-domain-specific-languages/fullscreen#">Slides</a></li>
<li><a href="https://github.com/edmundnoble/free-dsl">Sources</a></li>
</ul>
</p>
</abstract>
</eventitem>
<eventitem date="2016-03-23" time="6:00 pm" room="QNC 1502"
title="SAT and SMT Solvers for Software Engineering and Security">
@ -4526,7 +4528,7 @@ title="The Future of 3D Graphics is in Software!">
</p></short>
<abstract><p>
Do you love the combination of s'mores, burgers, and fire? Are you brave enough to face
the newly-grown geese? Do you want to play some Frigsbee? If so, come hang out with the CSC
the newly-grown geese? Do you want to play some Frisbee? If so, come hang out with the CSC
at the EV3 Fire Pit this Friday!
All are welcome for some outdoor fun, food, games, and music.
</p>
@ -6884,7 +6886,7 @@ Haskell, and Erlang. No prior background is assumed.
<eventitem date="2008-10-02" time="4:30 PM" room="MC4021" title="General Meeting 2">
<short><p>
The second official general meeting of the terfm. Items on the adgenda are CSC Merch,
The second official general meeting of the term. Items on the adgenda are CSC Merch,
upcoming talks, and other possible planned events, as well as the announcement of
a librarian and planning of an office cleanout and a library organization day.
</p></short>
@ -7935,7 +7937,7 @@ Elections">
</eventitem>
<!-- Summer 2005 -->
<!-- Spring 2005 -->
<eventitem date="2005-06-02" time="3:30 PM" room="DC 1302" title="Programming and Verifying the Interactive Web">
<short>Shriram Krishnamurthi will be talking about continuations in Web Programming</short>
<abstract>
@ -11314,3 +11316,5 @@ Garbage Collection or memory management is needed.
</abstract>
</eventitem>
</eventdefs>

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{
"dependencies": {
"jsdom": "^16.6.0",
"showdown": "^1.9.1",
"xml-js": "^1.6.11"
"libxmljs": "^0.19.7",
"showdown": "^1.9.1"
}
}