|
|
|
@ -33,11 +33,9 @@ export interface Metadata { |
|
|
|
|
image: string; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function getExecNames() { |
|
|
|
|
export async function getExecNamePosPairs() { |
|
|
|
|
if (process.env.USE_LDAP?.toLowerCase() !== "true") { |
|
|
|
|
return (await readdir(EXECS_PATH)) |
|
|
|
|
.filter((name) => name.endsWith(fileType)) |
|
|
|
|
.map((name) => name.slice(0, -1 * fileType.length)); |
|
|
|
|
return [["codey", "mascot"]]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const url = "ldap://ldap1.csclub.uwaterloo.ca"; |
|
|
|
@ -46,7 +44,7 @@ export async function getExecNames() { |
|
|
|
|
|
|
|
|
|
// position: name
|
|
|
|
|
const execMembers: { [name: string]: string } = {}; |
|
|
|
|
let formattedExec: string[] = []; |
|
|
|
|
let formattedExec: [string, string][] = []; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
await client.bind("", ""); |
|
|
|
@ -62,7 +60,7 @@ export async function getExecNames() { |
|
|
|
|
searchEntries.forEach((item) => { |
|
|
|
|
if (typeof item.position === "string" && item.position in execPositions) { |
|
|
|
|
execMembers[item.position] = item.cn as string; |
|
|
|
|
} else if (typeof item.position === "object") { |
|
|
|
|
} else if (item.position instanceof Array) { |
|
|
|
|
item.position.forEach((p) => { |
|
|
|
|
if ((p as string) in execPositions) { |
|
|
|
|
execMembers[p as string] = item.cn as string; |
|
|
|
@ -71,14 +69,18 @@ export async function getExecNames() { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
formattedExec = positionNames.map( |
|
|
|
|
(position, i) => |
|
|
|
|
`0${i + 1}-${execMembers[position] |
|
|
|
|
.split(" ")[0] |
|
|
|
|
.toLowerCase()}-${execMembers[position].split(" ")[1].toLowerCase()}` |
|
|
|
|
); |
|
|
|
|
formattedExec = positionNames.map((position) => { |
|
|
|
|
return [ |
|
|
|
|
`${execMembers[position].split(" ")[0].toLowerCase()}-${execMembers[ |
|
|
|
|
position |
|
|
|
|
] |
|
|
|
|
.split(" ")[1] |
|
|
|
|
.toLowerCase()}`,
|
|
|
|
|
position, |
|
|
|
|
]; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
formattedExec = [...formattedExec, "06-codey"]; |
|
|
|
|
formattedExec = [...formattedExec, ["codey", "mascot"]]; |
|
|
|
|
} finally { |
|
|
|
|
await client.unbind(); |
|
|
|
|
} |
|
|
|
@ -86,11 +88,16 @@ export async function getExecNames() { |
|
|
|
|
return formattedExec; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function getExec(fileName: string, convert = true) { |
|
|
|
|
export async function getExec( |
|
|
|
|
execNamePosPair: [string, string], |
|
|
|
|
convert = true |
|
|
|
|
) { |
|
|
|
|
let content, metadata; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
const raw = await readFile(path.join(EXECS_PATH, `${fileName}${fileType}`)); |
|
|
|
|
const raw = await readFile( |
|
|
|
|
path.join(EXECS_PATH, `${execNamePosPair[0]}${fileType}`) |
|
|
|
|
); |
|
|
|
|
({ content, data: metadata } = matter(raw)); |
|
|
|
|
|
|
|
|
|
const image = |
|
|
|
@ -103,12 +110,13 @@ export async function getExec(fileName: string, convert = true) { |
|
|
|
|
}; |
|
|
|
|
} catch (err) { |
|
|
|
|
const firstName = |
|
|
|
|
fileName.split("-")[1][0].toUpperCase() + fileName.split("-")[1].slice(1); |
|
|
|
|
execNamePosPair[0].split("-")[0][0].toUpperCase() + |
|
|
|
|
execNamePosPair[0].split("-")[0].slice(1); |
|
|
|
|
const lastName = |
|
|
|
|
fileName.split("-")[2][0].toUpperCase() + fileName.split("-")[2].slice(1); |
|
|
|
|
execNamePosPair[0].split("-")[1][0].toUpperCase() + |
|
|
|
|
execNamePosPair[0].split("-")[1].slice(1); |
|
|
|
|
|
|
|
|
|
const posOrder = fileName.split("-")[0][1]; |
|
|
|
|
const posName = execPositions[positionNames[Number(posOrder) - 1]]; |
|
|
|
|
const posName = execPositions[execNamePosPair[1]]; |
|
|
|
|
({ content, metadata } = { |
|
|
|
|
content: "Coming soon!", |
|
|
|
|
metadata: { |
|
|
|
|