Skip to content

Commit

Permalink
Merge branch 'main' into dcrepublic-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
DCRepublic authored Nov 24, 2024
2 parents 79328b4 + 7241789 commit 2518930
Show file tree
Hide file tree
Showing 38 changed files with 1,178 additions and 692 deletions.
20 changes: 0 additions & 20 deletions .eslintignore

This file was deleted.

98 changes: 1 addition & 97 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,99 +1,3 @@
{
"$schema": "https://json.schemastore.org/eslintrc.json",
"env": {
"browser": false,
"es2021": true,
"node": true
},
"extends": [
"plugin:react/recommended",
"plugin:prettier/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended"
],
"plugins": [
"react",
"unused-imports",
"import",
"@typescript-eslint",
"jsx-a11y",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"no-console": "warn",
"react/prop-types": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"react-hooks/exhaustive-deps": "off",
"jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/interactive-supports-focus": "warn",
"prettier/prettier": "warn",
"no-unused-vars": "off",
"unused-imports/no-unused-vars": "off",
"unused-imports/no-unused-imports": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "after-used",
"ignoreRestSiblings": false,
"argsIgnorePattern": "^_.*?$"
}
],
"import/order": [
"warn",
{
"groups": [
"type",
"builtin",
"object",
"external",
"internal",
"parent",
"sibling",
"index"
],
"pathGroups": [
{
"pattern": "~/**",
"group": "external",
"position": "after"
}
],
"newlines-between": "always"
}
],
"react/self-closing-comp": "warn",
"react/jsx-sort-props": [
"warn",
{
"callbacksLast": true,
"shorthandFirst": true,
"noSortAlphabetically": false,
"reservedFirst": true
}
],
"padding-line-between-statements": [
"warn",
{ "blankLine": "always", "prev": "*", "next": "return" },
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
{
"blankLine": "any",
"prev": ["const", "let", "var"],
"next": ["const", "let", "var"]
}
]
}
"extends": "next"
}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ next-env.d.ts

.env*

/postgres
/postgres

# Serwist
public/sw*
public/swe-worker*
1 change: 0 additions & 1 deletion app/actions/getCourses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export async function getTerms() {
}

export async function setPlanCookie(plan: string) {
//@ts-ignore
(await cookies()).set("plan", plan);
}

Expand Down
Binary file added app/apple-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/favicon.ico
Binary file not shown.
Binary file added app/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import clsx from "clsx";
import { CookiesProvider } from "next-client-cookies/server";

import { NextAuthProvider } from "../components/providers/NextAuthProvider";
import { siteConfig } from "../config/site";
import { sccsLD, siteConfig } from "../config/site";
import { fontSans } from "../config/fonts";
import { Navbar } from "../components/navbar";
import FooterInfo from "../components/FooterInfo";
Expand All @@ -18,15 +18,12 @@ export const metadata: Metadata = {
template: `%s - ${siteConfig.name}`,
},
description: siteConfig.description,
icons: {
icon: "/favicon.ico",
},
};

export const viewport: Viewport = {
themeColor: [
{ media: "(prefers-color-scheme: light)", color: "white" },
{ media: "(prefers-color-scheme: dark)", color: "black" },
{ media: "(prefers-color-scheme: light)", color: "#31425D" },
{ media: "(prefers-color-scheme: dark)", color: "#141C2A" },
],
};

Expand All @@ -39,7 +36,12 @@ export default function RootLayout({
<CookiesProvider>
<NextAuthProvider>
<html suppressHydrationWarning lang="en">
<head />
<head>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(sccsLD) }}
/>
</head>
<body
className={clsx(
"min-h-screen bg-background font-sans antialiased",
Expand Down
94 changes: 94 additions & 0 deletions app/manifest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { MetadataRoute } from "next";

export default function manifest(): MetadataRoute.Manifest {
return {
name: "SCCS Course Planner",
short_name: "Planner",
id: "sccs_plan",
categories: ["education", "productivity", "utilities"],
description: "Plan and track your classes with the SCCS Course Planner",
dir: "auto",
lang: "en-US",
start_url: "/",
scope: "/",
display: "standalone",
orientation: "any",
display_override: [
"window-controls-overlay",
/* @ts-ignore tabbed is new https://developer.mozilla.org/en-US/docs/Web/Manifest/display_override */
"tabbed",
"standalone",
"minimal-ui",
],
background_color: "#141C2A",
theme_color: "#141C2A",
prefer_related_applications: false,
edge_side_panel: {
preferred_width: 425,
},
shortcuts: [
{
name: "Calendar",
url: "/calendar",
description: "Course Planner calendar view",
},
{
name: "Ratings",
url: "/rating",
description: "Course Planner ratings form",
},
],
icons: [
{
src: "favicon.ico",
sizes: "32x32",
type: "image/x-icon",
purpose: "any",
},
{
src: "logo.svg",
sizes: "any",
type: "image/svg",
purpose: "any",
},
{
src: "icon.png",
sizes: "2048x2048",
type: "image/png",
purpose: "any",
},
{
src: "icon-maskable.png",
sizes: "2048x2048",
type: "image/png",
purpose: "maskable",
},
{
src: "opengraph-image.png",
sizes: "1200x630",
type: "image/png",
purpose: "any",
},
{
src: "twitter-image.png",
sizes: "1600x900",
type: "image/png",
purpose: "any",
},
],
screenshots: [
{
src: "screenshot-wide.png",
sizes: "2363x1267",
type: "image/png",
form_factor: "wide",
},
{
src: "screenshot-narrow.png",
sizes: "563x999",
type: "image/png",
form_factor: "narrow",
},
],
};
}
1 change: 1 addition & 0 deletions app/opengraph-image.alt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SCCS Course Planner logo; a letter 'P' on a minimalistic calendar.
Binary file added app/opengraph-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export default async function Page(props: {
const cookieStore = await cookies();
const planID = await cookieStore.get("plan");
const pagePref = cookieStore.get("pagePref");
if (pagePref && pagePref.value != "plan") {
redirect("/" + pagePref.value);

if (pagePref && pagePref.value != "/") {
redirect(pagePref.value);

}

const searchParams = await props.searchParams;
Expand Down
4 changes: 4 additions & 0 deletions app/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-Agent: *
Allow: /

Sitemap: https://schedulerv2.sccs.swarthmore.edu/sitemap.xml
24 changes: 24 additions & 0 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { MetadataRoute } from "next";

export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: "https://schedulerv2.sccs.swarthmore.edu",
lastModified: new Date(),
changeFrequency: "monthly",
priority: 1,
},
{
url: "https://schedulerv2.sccs.swarthmore.edu/calendar",
lastModified: new Date(),
changeFrequency: "monthly",
priority: 0.8,
},
{
url: "https://schedulerv2.sccs.swarthmore.edu/rating",
lastModified: new Date(),
changeFrequency: "monthly",
priority: 0.5,
},
];
}
76 changes: 76 additions & 0 deletions app/sw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { defaultCache } from "@serwist/next/worker";
import type { PrecacheEntry, SerwistGlobalConfig } from "serwist";
import { Serwist } from "serwist";

declare global {
interface WorkerGlobalScope extends SerwistGlobalConfig {
// Change this attribute's name to your `injectionPoint`.
// `injectionPoint` is an InjectManifest option.
// See https://serwist.pages.dev/docs/build/configuring
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
}
}

// @ts-expect-error
declare const self: ServiceWorkerGlobalScope;

const serwist = new Serwist({
precacheEntries: self.__SW_MANIFEST,
skipWaiting: true,
clientsClaim: true,
navigationPreload: true,
runtimeCaching: defaultCache,
fallbacks: {
entries: [
{
url: "/~offline",
matcher({ request }) {
return request.destination === "document";
},
},
],
},
});

serwist.addEventListeners();

/* Push Notifs */
self.addEventListener("push", function (event: any) {
if (event.data) {
let body;
let icon;
let title;
try {
const data = event.data.json();
body = data.body;
icon = data.icon || "/icon.png";
title = data.title;
} catch (e) {
console.log("clearly not a JSON notif");
body = "";
icon = "/icon.png";
title = event.data;
}

const options = {
body: body,
icon: icon,
badge: "/icon.png",
vibrate: [100, 50, 100],
data: {
dateOfArrival: Date.now(),
primaryKey: "2",
},
};
event.waitUntil(self.registration.showNotification(title, options));
}
});

self.addEventListener("notificationclick", function (event: any) {
console.log("Notification click received.");
event.notification.close();
event.waitUntil(
//@ts-ignore
clients.openWindow("https://schedulerv2.sccs.swarthmore.edu/")
);
});
Loading

0 comments on commit 2518930

Please sign in to comment.