Skip to content

Commit

Permalink
projects more streamlined. use config/pastProjects.json to update. ne…
Browse files Browse the repository at this point in the history
…eyam to upload all images
  • Loading branch information
izzyg770 committed Jul 20, 2024
1 parent 6c3003e commit a37c596
Show file tree
Hide file tree
Showing 25 changed files with 96 additions and 91 deletions.
15 changes: 6 additions & 9 deletions components/icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
IoBrowsersOutline,
IoLogoSlack,
IoCopyOutline,
IoCalendarOutline
IoCalendarOutline,
IoDocumentTextOutline,
IoDocumentOutline
} from "react-icons/io5";
import { createElement } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faGoogleDrive } from "@fortawesome/free-brands-svg-icons";

const iconMap = {
envelope: IoMail,
Expand All @@ -33,7 +33,8 @@ const iconMap = {
slack: IoLogoSlack,
copy: IoCopyOutline,
calendar: IoCalendarOutline,
googleSlides: faGoogleDrive,
"file-text": IoDocumentTextOutline,
"file-pdf": IoDocumentOutline
};

export default function Icon({ name, ...props }) {
Expand All @@ -44,9 +45,5 @@ export default function Icon({ name, ...props }) {
return null;
}

if (name === 'googleSlides') {
return <FontAwesomeIcon icon={IconComponent} {...props} />;
}

return createElement(IconComponent, props);
}
}
24 changes: 5 additions & 19 deletions components/projectCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,22 @@ export default function ProjectCard({ project, basePath }) {
<div className="">
<h3 className="mb-1 text-2xl font-bold tracking-tight">{project.label}</h3>
<ul className="flex sm:justify-center mt-2 sm:mt-4 space-x-4">
{project.type === "link" && (
{project.github && (
<li>
<Link href={project.href} className="hover:text-gray" aria-label="Github Repo">
<Link href={project.github} className="hover:text-gray" aria-label="Github Repo">
<Icon name="github" className="text-3xl" />
</Link>
</li>
)}
{project.type === "md" && (
{project.googleSlides && (
<li>
<Link href={project.href} className="hover:text-gray" aria-label="Markdown">
<Icon name="file-text" className="text-3xl" />
</Link>
</li>
)}
{project.type === "pdf" && (
<li>
<Link href={project.href} className="hover:text-gray" aria-label="PDF">
<Link href={project.googleSlides} className="hover:text-gray" aria-label="Google Slides">
<Icon name="file-pdf" className="text-3xl" />
</Link>
</li>
)}
{project.type === "googleSlides" && (
<li>
<Link href={project.href} className="hover:text-gray" aria-label="Google Slides">
<Icon name="googleSlides" className="text-3xl" />
</Link>
</li>
)}
</ul>
</div>
</div>
);
}
}
62 changes: 62 additions & 0 deletions config/pastProjects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"Winter 2023": [
{
"label": "Footwear Image Classification",
"googleSlides": "https://docs.google.com/presentation/d/1Bb7nCc4o3fmV4OkR-NOeAwzl6i1E_BA_V937Gjoq1wc/"
},
{
"label": "Image Colorization",
"googleSlides": "https://docs.google.com/document/d/19CekIh2sZGKKMoRA5VNFEcjNGHc9GEYt/"
},
{
"label": "Mini DALL-E"
},
{
"label": "MOOC Data Analysis" },
{
"label": "Movie Quote Sentiment Analysis"
},
{
"label": "Twitter Chatbot",
"googleSlides": "https://docs.google.com/document/d/1_vf3Snj2KxcnSunW7eRLbDOLffrK5OKGKrFRIFLYDpM/"
},
{
"label": "Webscraping",
"googleSlides": "https://docs.google.com/document/d/1uVD5nvpA0lg9E8tE9khuEQDlwCwHKgrHGqtvzKe2JoA/"
},
{
"label": "Wildfire Spread Prediction"
}
],
"Fall 2022": [
{
"label": "College Football"
},
{
"label": "Dogs vs Cats"
},
{
"label": "Image Super Resolution"
},
{
"label": "Language Translation Application"
},
{
"label": "Pokemon Data Science"
},
{
"label": "SEC Insider Information",
"github": "https://github.com/MichiganDataScienceTeam/F22-SEC-Insider-Trading"
},
{
"label": "Sports Data Science"
},
{
"label": "TLDR Machine"
},
{
"label": "Twitter Sentiment Analysis"
}
]
}

82 changes: 23 additions & 59 deletions pages/projects/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import path from "path";
import HeadContent from "@/components/headContent";
import Hero from "@/components/hero";
import Layout from "@/components/layout";
import ProjectCard from "@/components/ProjectCard";
import CurrentProjectCard from "@/components/CurrentProjectCard";
import ProjectCard from "@/components/ProjectCard";
import { useRouter } from "next/router";

export default function Projects({ groupedLinks, currentProjects }) {
Expand All @@ -30,82 +30,46 @@ export default function Projects({ groupedLinks, currentProjects }) {
</div>
</section>

{Object.entries(groupedLinks).map(([subdirectory, links]) => (
<ProjectSection key={subdirectory} subdirectory={subdirectory} links={links} basePath={basePath} />
{Object.entries(groupedLinks).sort((a, b) => {
const [aSeason, aYear] = a[0].split(" ");
const [bSeason, bYear] = b[0].split(" ");
const seasonOrder = { Winter: 0, Fall: 1 };

if (aYear === bYear) {
return seasonOrder[aSeason] - seasonOrder[bSeason];
} else {
return parseInt(bYear) - parseInt(aYear);
}
}).map(([semester, projects]) => (
<GroupSection key={semester} basePath={basePath} semester={semester} projects={projects} />
))}
</Layout>
);
}

function ProjectSection({ subdirectory, links, basePath }) {
function GroupSection({ semester, projects, basePath }) {
return (
<div className="py-8 px-4 mx-auto max-w-screen-xl text-center lg:py-16 lg:px-6">
<div className="mx-auto mb-8 max-w-screen-sm lg:mb-16">
<h2 className="text-3xl mb-4">{subdirectory}</h2>
<h2 className="text-3xl mb-4">{semester}</h2>
</div>
<div className="flex flex-wrap justify-center gap-4 lg:gap-16 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{links.map((link, index) => (
<ProjectCard key={index} basePath={basePath} project={link} />
{projects.map((project, index) => (
<ProjectCard key={index} basePath={basePath} project={project} />
))}
</div>
</div>
);
}

export async function getStaticProps() {
const projectsDirectory = path.join(process.cwd(), "public", "projects");
const subdirectories = fs.readdirSync(projectsDirectory, { withFileTypes: true }).filter(dirent => dirent.isDirectory());

const sortedSubdirectories = subdirectories.sort((a, b) => {
const [aSeason, aYear] = a.name.split('_');
const [bSeason, bYear] = b.name.split('_');
const seasonOrder = { Winter: 0, Fall: 1 };

if (aYear === bYear) {
return seasonOrder[aSeason] - seasonOrder[bSeason];
} else {
return parseInt(bYear) - parseInt(aYear);
}
});

const groupedLinks = sortedSubdirectories.reduce((acc, subdirectory) => {
const subdirectoryPath = path.join(projectsDirectory, subdirectory.name);
const innerDirectories = fs.readdirSync(subdirectoryPath, { withFileTypes: true }).filter(dirent => dirent.isDirectory());

const links = innerDirectories.map(innerDir => {
const innerDirPath = path.join(subdirectoryPath, innerDir.name);
const writeupMdPath = path.join(innerDirPath, "writeup.md");
const writeupPdfPath = path.join(innerDirPath, "writeup.pdf");
const linkTxtPath = path.join(innerDirPath, "link.txt");

const label = innerDir.name.split("_").join(" ");
let type, href;

if (fs.existsSync(linkTxtPath)) {
const link = fs.readFileSync(linkTxtPath, "utf-8").trim();
if (link.toLowerCase().includes('docs.google.com/presentation')) {
href = link;
type = "googleSlides";
} else {
href = link;
type = "link";
}
} else if (fs.existsSync(writeupMdPath)) {
href = `/projects/${subdirectory.name}/${innerDir.name}`;
type = "md";
} else if (fs.existsSync(writeupPdfPath)) {
href = `/projects/${subdirectory.name}/${innerDir.name}/writeup.pdf`;
type = "pdf";
} else {
href = "";
type = "none";
}
return { label, href, type };
});
const pastProjectsPath = path.join(process.cwd(), "config", "pastProjects.json");
const pastProjects = JSON.parse(fs.readFileSync(pastProjectsPath, "utf-8"));

if (links.length > 0) {
acc[subdirectory.name.split("_").join(" ")] = links;
}
const groupedLinks = Object.entries(pastProjects).reduce((acc, [semester, projects]) => {
acc[semester] = projects.map(project => ({
...project
}));
return acc;
}, {});

Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

This file was deleted.

Empty file.
1 change: 0 additions & 1 deletion public/projects/Winter_2023/Image_Colorization/link.txt

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
1 change: 0 additions & 1 deletion public/projects/Winter_2023/Twitter_Chatbot/link.txt

This file was deleted.

Empty file.
1 change: 0 additions & 1 deletion public/projects/Winter_2023/Webscraping/link.txt

This file was deleted.

Empty file.

0 comments on commit a37c596

Please sign in to comment.