Compare commits

...

41 Commits

Author SHA1 Message Date
Rebecca-Chou 5adebddec6 test placeholder 11 months ago
Rebecca-Chou cafdf334fe final fix 11 months ago
Rebecca-Chou 00caa70143 fix data type 11 months ago
Rebecca-Chou ccd075fa84 resolve conflicts with main 11 months ago
Rebecca-Chou 67afba862a fix type bug 11 months ago
Rebecca-Chou 4c087b4af4 eliminate position name to keep in sync 11 months ago
Rebecca-Chou 51bb491277 fix undefined bug 11 months ago
Rebecca-Chou 2d9176256d Fix logic for fetching array 11 months ago
Beihao Zhou 83b68a3ce3 Merge branch 'main' into b72zhou-ldap-exec 11 months ago
Rebecca-Chou 856f849526 finalize ldap 12 months ago
Rebecca-Chou 0c0515a3c6 fetch array at index 0 from ldap 12 months ago
Rebecca-Chou 3dbc1efe39 test data type for position 12 months ago
Rebecca-Chou f09580151f test position array 12 months ago
Rebecca-Chou bb743f4ca6 test president 12 months ago
Rebecca-Chou ca1a9f3185 debug sort function 12 months ago
Rebecca-Chou 3506b6d00c test sort function 12 months ago
Rebecca-Chou 615a8ddbf9 test filter function 12 months ago
Rebecca-Chou 6dc69fbe14 get position test 12 months ago
Rebecca-Chou 9a1ecf82bd edit president to presidentcro 12 months ago
Rebecca-Chou f96d776259 Test position field 2 12 months ago
Rebecca-Chou fe3358d9ae Test position field 12 months ago
Rebecca-Chou 340dfa67b5 Add placeholder 12 months ago
Rebecca-Chou 57f67bc8d1 edit codey file name 12 months ago
Rebecca-Chou ae66794a54 add codey 12 months ago
Rebecca-Chou be43b75694 change order of exec 12 months ago
Beihao Zhou 2aeaeaccde Fix Line Format 12 months ago
Beihao Zhou c729bf40ee Fix name order 12 months ago
Rebecca-Chou 8b8432cf76 Change the order of exec name 12 months ago
Rebecca-Chou 3a7ec04f4e Debug ldap data fetch function 12 months ago
Rebecca-Chou ae0b81c4cc debug getExecNames 1 year ago
Rebecca-Chou c7947d9054 Test new getExecNames 1 year ago
Rebecca-Chou 6ad38d1971 Test getExec function 1 year ago
Rebecca-Chou 608f6342da Debug placeholder 1 year ago
Rebecca-Chou fc3d3e11d3 Merge branch 'b72zhou-ldap-exec' of https://git.csclub.uwaterloo.ca/www/www-new into b72zhou-ldap-exec 1 year ago
Rebecca-Chou 0f15953979 Fix Typo 1 year ago
Beihao Zhou cb17e15b22 Merge branch 'main' into b72zhou-ldap-exec 1 year ago
Rebecca-Chou 79c5005652 add placeholder 1 year ago
Rebecca-Chou 8f144983ef Test Ldap 1 year ago
Rebecca-Chou fbcdec33eb Change returned data type 1 year ago
Rebecca-Chou 6e8f7bba94 Test using console log 1 year ago
Rebecca-Chou b06189f5f3 Test Ldap 1 year ago
  1. 6
      content/team/execs/03-dina-orucevic.md
  2. 0
      content/team/execs/codey.md
  3. 0
      content/team/execs/eden-chan.md
  4. 0
      content/team/execs/eric-huang.md
  5. 0
      content/team/execs/juthika-hoque.md
  6. 0
      content/team/execs/raymond-li.md
  7. 122
      lib/team.ts
  8. 6
      pages/about/team.tsx

@ -1,6 +0,0 @@
---
name: Dina Orucevic
role: Assistant Vice President
---
Hi everyone, I’m Dina, a rising 1B student in Systems Design Engineering! I’m so glad I get the chance to lead a group of interested students to make the CS community even more inclusive, diverse, and engaging! In my free time I love snapping film photos, going to dog parks (even though I don’t own a dog) and reading a good novel.

@ -2,10 +2,30 @@ import { readFile, readdir, access } from "fs/promises";
import path from "path";
import matter from "gray-matter";
import { Client } from "ldapts";
import { serialize } from "next-mdx-remote/serialize";
import { getCurrentTerm } from "@/lib/events";
const EXECS_PATH = path.join("content", "team", "execs");
const fileType = ".md";
const { year, term } = getCurrentTerm();
const execPositions: { [name: string]: string } = {
president: "President",
"vice-president": "Vice President",
secretary: "Assistant Vice President",
treasurer: "Treasurer",
sysadmin: "System Administrator",
};
const positionNames: string[] = [
"president",
"vice-president",
"secretary",
"treasurer",
"sysadmin",
];
export interface Metadata {
name: string;
@ -13,23 +33,95 @@ export interface Metadata {
image: string;
}
export async function getExecNames() {
return (await readdir(EXECS_PATH))
.filter((name) => name.endsWith(fileType))
.map((name) => name.slice(0, -1 * fileType.length));
export async function getExecNamePosPairs() {
if (process.env.USE_LDAP?.toLowerCase() !== "true") {
return [["codey", "mascot"]];
}
const url = "ldap://ldap1.csclub.uwaterloo.ca";
const searchDN = "ou=People,dc=csclub,dc=uwaterloo,dc=ca";
const client = new Client({ url });
// position: name
const execMembers: { [name: string]: string } = {};
let formattedExec: [string, string][] = [];
try {
await client.bind("", "");
const { searchEntries } = await client.search(searchDN, {
scope: "sub",
filter: `(&(objectClass=member)(term=${(term as string).slice(
0,
1
)}${year}))`,
});
// item.position might be an array if the member has more than one position
searchEntries.forEach((item) => {
if (typeof item.position === "string" && item.position in execPositions) {
execMembers[item.position] = item.cn as string;
} else if (item.position instanceof Array) {
item.position.forEach((p) => {
if ((p as string) in execPositions) {
execMembers[p as string] = item.cn as string;
}
});
}
});
formattedExec = positionNames.map((position) => {
return [
`${execMembers[position].split(" ")[0].toLowerCase()}-${execMembers[
position
]
.split(" ")[1]
.toLowerCase()}`,
position,
];
});
formattedExec = [...formattedExec, ["codey", "mascot"]];
} finally {
await client.unbind();
}
return formattedExec;
}
export async function getExec(fileName: string, convert = true) {
const raw = await readFile(path.join(EXECS_PATH, `${fileName}${fileType}`));
const { content, data: metadata } = matter(raw);
const image =
(metadata.image as string | undefined) ??
(await getMemberImagePath(metadata.name));
return {
content: convert ? await serialize(content) : content,
metadata: { ...metadata, image } as Metadata,
};
export async function getExec(name: string, pos: string, convert = true) {
let content, metadata;
try {
const raw = await readFile(path.join(EXECS_PATH, `${name}${fileType}`));
({ content, data: metadata } = matter(raw));
const image = await getMemberImagePath(metadata.name);
return {
content: convert ? await serialize(content) : content,
metadata: { ...metadata, image } as Metadata,
};
} catch (err) {
// Capitalize the first letter of the first name and last name
const firstName =
name.split("-")[0][0].toUpperCase() + name.split("-")[0].slice(1);
const lastName =
name.split("-")[1][0].toUpperCase() + name.split("-")[1].slice(1);
const posName = execPositions[pos];
content = "Coming Soon";
metadata = {
name: `${firstName} ${lastName}`,
role: `${posName}`,
};
const image = await getMemberImagePath(metadata.name);
return {
content: convert ? await serialize(content) : content,
metadata: { ...metadata, image } as Metadata,
};
}
}
async function getImage(imgPath: string) {

@ -11,7 +11,7 @@ import { TeamMemberCard } from "@/components/TeamMemberCard";
import { Title } from "@/components/Title";
import {
getExec,
getExecNames,
getExecNamePosPairs,
Metadata,
getMemberImagePath,
} from "@/lib/team";
@ -208,10 +208,10 @@ async function getTeamWithImages(team: TeamMember[]) {
}
export const getStaticProps: GetStaticProps<Props> = async () => {
const execNames = await getExecNames();
const execNamePosPairs = await getExecNamePosPairs();
const execs = (await Promise.all(
execNames.map((name) => getExec(name))
execNamePosPairs.map((posPairs) => getExec(posPairs[0], posPairs[1]))
)) as SerializedExec[];
const [

Loading…
Cancel
Save