mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Create website
This commit is contained in:
parent
064750968c
commit
0ca9cac82d
20 changed files with 3512 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="dataSourceStorageLocal" created-in="PY-222.4345.23">
|
<component name="dataSourceStorageLocal" created-in="PY-222.4459.20">
|
||||||
<data-source name="main" uuid="28efee07-d306-4126-bf69-01008b4887e2">
|
<data-source name="main" uuid="28efee07-d306-4126-bf69-01008b4887e2">
|
||||||
<database-info product="SQLite" version="3.39.2" jdbc-version="2.1" driver-name="SQLite JDBC" driver-version="3.39.2.0" dbms="SQLITE" exact-version="3.39.2" exact-driver-version="3.39">
|
<database-info product="SQLite" version="3.39.2" jdbc-version="2.1" driver-name="SQLite JDBC" driver-version="3.39.2.0" dbms="SQLITE" exact-version="3.39.2" exact-driver-version="3.39">
|
||||||
<identifier-quote-string>"</identifier-quote-string>
|
<identifier-quote-string>"</identifier-quote-string>
|
||||||
|
|
3
website/.eslintrc.json
Normal file
3
website/.eslintrc.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"extends": "next/core-web-vitals"
|
||||||
|
}
|
36
website/.gitignore
vendored
Normal file
36
website/.gitignore
vendored
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# next.js
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env*.local
|
||||||
|
|
||||||
|
# vercel
|
||||||
|
.vercel
|
||||||
|
|
||||||
|
# typescript
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
5
website/.idea/.gitignore
vendored
Normal file
5
website/.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
6
website/.idea/inspectionProfiles/Project_Default.xml
Normal file
6
website/.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
8
website/.idea/modules.xml
Normal file
8
website/.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/website.iml" filepath="$PROJECT_DIR$/.idea/website.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
website/.idea/vcs.xml
Normal file
6
website/.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
12
website/.idea/website.iml
Normal file
12
website/.idea/website.iml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
34
website/README.md
Normal file
34
website/README.md
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
First, run the development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
# or
|
||||||
|
yarn dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||||
|
|
||||||
|
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
|
||||||
|
|
||||||
|
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
|
||||||
|
|
||||||
|
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
To learn more about Next.js, take a look at the following resources:
|
||||||
|
|
||||||
|
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||||
|
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||||
|
|
||||||
|
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
||||||
|
|
||||||
|
## Deploy on Vercel
|
||||||
|
|
||||||
|
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||||
|
|
||||||
|
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
6
website/next.config.js
Normal file
6
website/next.config.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
|
reactStrictMode: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = nextConfig
|
3129
website/package-lock.json
generated
Normal file
3129
website/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
19
website/package.json
Normal file
19
website/package.json
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "website",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"lint": "next lint"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"eslint": "8.28.0",
|
||||||
|
"eslint-config-next": "13.0.4",
|
||||||
|
"next": "13.0.4",
|
||||||
|
"next-auth": "^4.17.0",
|
||||||
|
"react": "18.2.0",
|
||||||
|
"react-dom": "18.2.0"
|
||||||
|
}
|
||||||
|
}
|
12
website/pages/_app.js
Normal file
12
website/pages/_app.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import '../styles/globals.css';
|
||||||
|
import { SessionProvider } from 'next-auth/react'
|
||||||
|
|
||||||
|
function MyApp({ Component, pageProps }) {
|
||||||
|
return (
|
||||||
|
<SessionProvider session={pageProps.session}>
|
||||||
|
<Component {...pageProps} />
|
||||||
|
</SessionProvider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MyApp
|
18
website/pages/api/auth/[...nextauth].js
Normal file
18
website/pages/api/auth/[...nextauth].js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import NextAuth from "next-auth"
|
||||||
|
import DiscordProvider from "next-auth/providers/discord"
|
||||||
|
|
||||||
|
// noinspection JSUnresolvedVariable
|
||||||
|
export const authOptions = {
|
||||||
|
// Configure one or more authentication providers
|
||||||
|
providers: [
|
||||||
|
DiscordProvider(
|
||||||
|
{
|
||||||
|
clientId: '1019217990111199243',
|
||||||
|
clientSecret: 'JIgEecH6RyG9TJLZjga0EoMzafqwRIEb'
|
||||||
|
}
|
||||||
|
),
|
||||||
|
// ...add more providers here
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NextAuth(authOptions);
|
5
website/pages/api/hello.js
Normal file
5
website/pages/api/hello.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||||
|
|
||||||
|
export default function handler(req, res) {
|
||||||
|
res.status(200).json({ name: 'John Doe' })
|
||||||
|
}
|
151
website/pages/index.js
Normal file
151
website/pages/index.js
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
import timetable from '../../utils/timetable.json';
|
||||||
|
import { useSession, signIn } from "next-auth/react"
|
||||||
|
import style from '../styles/Home.module.css';
|
||||||
|
import {useState} from "react";
|
||||||
|
|
||||||
|
|
||||||
|
const days = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
||||||
|
|
||||||
|
|
||||||
|
function currentTimeTable(_day_diff = null) {
|
||||||
|
let now = new Date();
|
||||||
|
if(_day_diff) {
|
||||||
|
now = new Date(now.valueOf() + (86400 * _day_diff))
|
||||||
|
}
|
||||||
|
let day = days[now.getDay()];
|
||||||
|
const today_timetable = timetable[day];
|
||||||
|
return today_timetable || []
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_old(lesson, now) {
|
||||||
|
let lesson_start = new Date();
|
||||||
|
lesson_start.setHours(lesson.start[0], lesson.start[1], 0)
|
||||||
|
let lesson_end = new Date();
|
||||||
|
lesson_end.setHours(lesson.end[0], lesson.end[1], 0);
|
||||||
|
if(lesson_end > now) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function currentLesson() {
|
||||||
|
const now = new Date();
|
||||||
|
const date = now.toLocaleDateString("en-GB");
|
||||||
|
const time = now.toLocaleTimeString("en-GB");
|
||||||
|
const hour = parseInt(time.split(":")[0]);
|
||||||
|
const minute = parseInt(time.split(":")[1]);
|
||||||
|
const day = days[now.getDay()];
|
||||||
|
const today_timetable = currentTimeTable();
|
||||||
|
console.debug(
|
||||||
|
now,
|
||||||
|
date,
|
||||||
|
time,
|
||||||
|
hour,
|
||||||
|
minute,
|
||||||
|
day,
|
||||||
|
today_timetable
|
||||||
|
)
|
||||||
|
|
||||||
|
for(let lesson of today_timetable) {
|
||||||
|
let lesson_start = new Date();
|
||||||
|
lesson_start.setHours(lesson.start[0], lesson.start[1], 0)
|
||||||
|
let lesson_end = new Date();
|
||||||
|
lesson_end.setHours(lesson.end[0], lesson.end[1], 0);
|
||||||
|
if(lesson_end > now) {
|
||||||
|
if(lesson_start <= now) {
|
||||||
|
console.debug("Returning", lesson)
|
||||||
|
lesson.start_timestamp = lesson_start.valueOf()
|
||||||
|
lesson.end_timestamp = lesson_end.valueOf()
|
||||||
|
return lesson
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
"name": "No Current Lesson",
|
||||||
|
"start": [0, 0],
|
||||||
|
"end": [0, 0],
|
||||||
|
"tutor": "",
|
||||||
|
"room": "",
|
||||||
|
"start_timestamp": (new Date()).setHours(0, 0, 0),
|
||||||
|
"end_timestamp": (new Date()).setHours(23, 59, 59)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function normaliseTime(t) {
|
||||||
|
return `${t[0].toString().padStart(2, "0")}:${t[1].toString().padStart(2, "0")}`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function TimeTableBlock(props) {
|
||||||
|
const lesson = props.lesson;
|
||||||
|
let [open, setOpen] = useState(false);
|
||||||
|
const _onClick = () => {setOpen(!open)};
|
||||||
|
return (
|
||||||
|
<div className={style.timetableListContainer} onClick={_onClick}>
|
||||||
|
<h3>{lesson.name || 'error'}</h3>
|
||||||
|
<span hidden={open}><i>Click/tap to expand</i></span>
|
||||||
|
<ul className={style.timetableList} hidden={!open}>
|
||||||
|
<li>Start: {normaliseTime(lesson.start || [0, 0])}</li>
|
||||||
|
<li>End: {normaliseTime(lesson.end || [23, 59])}</li>
|
||||||
|
<li>Room: {lesson.room}</li>
|
||||||
|
<li>Tutor: {lesson.tutor}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
let [dayOfTheWeek, setDay] = useState((new Date()).getDay());
|
||||||
|
const incrementDay = (by) => {
|
||||||
|
let new_DOTW = dayOfTheWeek + by;
|
||||||
|
if(new_DOTW>6) {
|
||||||
|
new_DOTW = 0
|
||||||
|
}
|
||||||
|
else if (new_DOTW < 0) {
|
||||||
|
new_DOTW = 6
|
||||||
|
}
|
||||||
|
setDay(new_DOTW);
|
||||||
|
}
|
||||||
|
const { data: session } = useSession();
|
||||||
|
if(!session) {
|
||||||
|
return (
|
||||||
|
<div style={{textAlign: "center"}}>
|
||||||
|
<button onClick={() => signIn()}>Sign In (with Discord)</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
let current_lesson = currentLesson();
|
||||||
|
// let current_timetable = currentTimeTable(dayOfTheWeek);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1 style={{textAlign: "center", marginBottom: "4rem"}}>Hello, {session.user.name}.</h1>
|
||||||
|
<div style={{textAlign: "center"}}>
|
||||||
|
<h1>Current lesson:</h1>
|
||||||
|
<p>{current_lesson.name}</p>
|
||||||
|
<progress value={current_lesson.start_timestamp} max={current_lesson.end_timestamp}></progress>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
<hr style={{width: "75%"}}/>
|
||||||
|
<br/>
|
||||||
|
<h2 style={{textAlign: "center"}}>Full timetable:</h2>
|
||||||
|
<div className={style.todaysTimeTable}>
|
||||||
|
<div>
|
||||||
|
<h3 style={{textAlign: "center"}}>{days[dayOfTheWeek]}</h3>
|
||||||
|
</div>
|
||||||
|
<div style={{display: "flex", justifyContent: "space-between"}}>
|
||||||
|
<button onClick={() => {incrementDay(-1)}}>Previous day</button>
|
||||||
|
<button onClick={() => {incrementDay(1)}}>Next day</button>
|
||||||
|
</div>
|
||||||
|
{
|
||||||
|
currentTimeTable(dayOfTheWeek).map(
|
||||||
|
(lesson) => {
|
||||||
|
return <TimeTableBlock key={lesson.name} lesson={lesson}/>
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
BIN
website/public/favicon.ico
Normal file
BIN
website/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
4
website/public/vercel.svg
Normal file
4
website/public/vercel.svg
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<svg width="283" height="64" viewBox="0 0 283 64" fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="#000"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
31
website/styles/Home.module.css
Normal file
31
website/styles/Home.module.css
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
ul.timetableList {
|
||||||
|
background-color: #2F3136;
|
||||||
|
padding: 2rem;
|
||||||
|
border-radius: 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.timetableListContainer {
|
||||||
|
background-color: #202225;
|
||||||
|
border-radius: 10%;
|
||||||
|
padding: 2rem;
|
||||||
|
margin: 2rem;
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.timetableList_Old {
|
||||||
|
opacity: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.todaysTimeTable {
|
||||||
|
display: grid;
|
||||||
|
/*flex-direction: column;*/
|
||||||
|
/*align-items: center;*/
|
||||||
|
/*justify-content: space-evenly;*/
|
||||||
|
justify-content: center;
|
||||||
|
background-color: #2A2E32;
|
||||||
|
margin-left: 10%;
|
||||||
|
margin-right: 10%;
|
||||||
|
box-shadow: 5px 5px 5px 0 rgba(0, 0, 0, 0.3);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
border: 1px black
|
||||||
|
}
|
26
website/styles/globals.css
Normal file
26
website/styles/globals.css
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
|
||||||
|
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
html {
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
color: white;
|
||||||
|
background: #36393F;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue