Add news-conversion scripts
This commit is contained in:
parent
b6e10c0c0f
commit
6789f8529a
|
@ -98,7 +98,7 @@ const parseXML = (XML) => {
|
|||
markdownLinkDetectRegex.exec(abstract)[0]
|
||||
}",`;
|
||||
}
|
||||
let mdx = `export const metadata = {
|
||||
const mdx = `export const metadata = {
|
||||
name: "${title}",
|
||||
short: "${short}",
|
||||
date: new Date("${date.toString()}"),
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
export const metadata = {
|
||||
name: "Afterhours: Personal Relationships",
|
||||
short: "Learn how React works and make your own version!",
|
||||
date: new Date("2021-03-02 2:00 PM"),
|
||||
online: false,
|
||||
location: "MC",
|
||||
registerLink: "http://csclub.uwaterloo.ca/",
|
||||
};
|
||||
|
||||
The past year has been tough for all of us, having to deal with the pandemic
|
||||
while studying or working remotely. If you've felt that meeting new people and
|
||||
sustaining relationships with others has never been more challenging, we feel
|
||||
that too, and we want to talk about it.
|
||||
|
||||
CSC brings you the third chapter of Afterhours, and this time we're discussing
|
||||
Personal Relationships. Join us for a chat about how our relationships
|
||||
(platonic and romantic) have been affected, whether that be due to co-op,
|
||||
sequence changes, or COVID. We'll be sharing our own personal stories and we'd
|
||||
love for you all to join in on the discussion.
|
||||
|
||||
Registration is required for attendance, so don't miss out!
|
|
@ -0,0 +1,14 @@
|
|||
export const metadata = {
|
||||
author: "merenber",
|
||||
date: new Date("2021-03-19"),
|
||||
}
|
||||
|
||||
Computer Science Club systems and services will be unavailable on Saturday, Mar. 20
|
||||
due to a planned power outage in the Mathematics and Computer Building (MC) from 7am to 5pm.
|
||||
|
||||
The CSC will begin shutting down machines at 6am in preparation of the outage.
|
||||
Please prepare for the outage by:
|
||||
|
||||
- Ensuring all running processes have their state saved (configuration, data, etc.)
|
||||
- Any important files are backed up off-site from the CSC
|
||||
- If you have any questions/concerns, please email the Systems Committee.
|
|
@ -0,0 +1,77 @@
|
|||
const fs = require("fs");
|
||||
const jsdom = require("jsdom");
|
||||
const { JSDOM } = jsdom;
|
||||
const { window } = new JSDOM("");
|
||||
global.window = window;
|
||||
var showdown = require("showdown");
|
||||
const converterShowdown = new showdown.Converter();
|
||||
const libxmljs = require("libxmljs");
|
||||
|
||||
fs.readFile("./news-test.xml", "utf8", (err, data) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
parseXML(data);
|
||||
});
|
||||
|
||||
fs.mkdir("./markdown-news/", { recursive: true }, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
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 getTerm = (dateStr) => {
|
||||
const date = new Date(dateStr);
|
||||
let term = "";
|
||||
const year = date.getUTCFullYear();
|
||||
if (new Date(`${year}-01-01`).getTime() <= date.getTime() && date.getTime() <= new Date(`${year}-04-30`).getTime()) {
|
||||
term = "Winter"
|
||||
} else if (new Date(`${year}-05-01`).getTime() <= date.getTime() && date.getTime() <= new Date(`${year}-08-31`).getTime()) {
|
||||
term = "Spring"
|
||||
} else if (new Date(`${year}-09-01`).getTime() <= date.getTime() && date.getTime() <= new Date(`${year}-12-31`).getTime()) {
|
||||
term = "Fall"
|
||||
}
|
||||
return `-${term}-${year}-`
|
||||
}
|
||||
|
||||
const parseXML = (XML) => {
|
||||
const xmlDoc = libxmljs.parseHtml(XML);
|
||||
let newsdefsChildren = xmlDoc.get("//newsdefs").childNodes();
|
||||
let currentTerm = "";
|
||||
for (let i = 0; i < newsdefsChildren.length; ++i) {
|
||||
if (newsdefsChildren[i].type() === "element") {
|
||||
const author = newsdefsChildren[i].attr("author").value();
|
||||
const date = newsdefsChildren[i].attr("date").value();
|
||||
currentTerm = getTerm(date);
|
||||
const contentNodes = newsdefsChildren[i].childNodes();
|
||||
const content = converterShowdown.makeMarkdown(
|
||||
nodeChildrenToString(contentNodes)
|
||||
);
|
||||
|
||||
const mdx = `export const metadata = {
|
||||
author: ${author},
|
||||
date: new Date("${date}"),
|
||||
}
|
||||
|
||||
${content}`;
|
||||
const mdxTitle = `${date}-${author}`;
|
||||
fs.mkdir(`./markdown-news/${currentTerm}`, { recursive: true }, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
fs.writeFile(`./markdown-news/${currentTerm}/${mdxTitle}.news.mdx`, mdx, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version='1.0'?>
|
||||
|
||||
<newsdefs>
|
||||
<newsitem author="jbroman" date="2014-01-16">
|
||||
<p>Elections for Winter 2014 have concluded. The following people were elected:</p>
|
||||
<ul>
|
||||
<li>President: Bryan Coutts (<tt>b2coutts</tt>)</li>
|
||||
<li>Vice-president: Visha Vijayanand (<tt>vvijayan</tt>)</li>
|
||||
<li>Treasurer: Marc Burns (<tt>m4burns</tt>)</li>
|
||||
<li>Secretary: Mark Farrell (<tt>m4farrel</tt>)</li>
|
||||
</ul>
|
||||
<p>The following people were appointed:</p>
|
||||
<ul>
|
||||
<li>Sysadmin: Murphy Berzish (<tt>mtrberzi</tt>)</li>
|
||||
<li>Office Manager: Nicholas Black (<tt>nablack</tt>)</li>
|
||||
</ul>
|
||||
</newsitem>
|
||||
</newsdefs>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue