1
0
Fork 0
forked from CRSS/Website

feat: Next.js rewrite

This commit is contained in:
TheClashFruit 2024-08-29 15:20:28 +02:00
parent 36853a4723
commit 844a9060de
Signed by: TheClashFruit
GPG key ID: 09BB24C34C2F3204
66 changed files with 7996 additions and 2206 deletions

View file

@ -1,45 +0,0 @@
[
{
"id": 786634586452787201,
"role": 0,
"name": "Blurryface (aka Clyde)",
"picture": "https://crss.fra1.cdn.digitaloceanspaces.com/avatars/786634586452787201.png",
"banner": "linear-gradient(40deg, #a657fa, #7447e4)",
"links": [
{
"icon": {
"id": "lucide.globe"
},
"name": "Website",
"url": "https://blurryface.xyz/"
}
]
},
{
"id": 394888268446957569,
"role": 1,
"name": "TheClashFruit",
"picture": "https://crss.fra1.cdn.digitaloceanspaces.com/avatars/394888268446957569.png",
"links": [
{
"icon": {
"id": "lucide.globe"
},
"name": "Website",
"url": "https://theclashfruit.me/"
},
{
"icon": {
"id": "simpleicons.mastodon",
"extra": {
"width": "24",
"height": "24",
"fill": "currentColor"
}
},
"name": "Mastodon",
"url": "https://wetdry.world/@TheClashFruit"
}
]
}
]

View file

@ -1,9 +1,13 @@
DISCORD_CLIENT=
DISCORD_SECRET=
DISCORD_REDIRECT=
DISCORD_OAUTH=
DISCORD_REDIRECT="http://localhost:3000/api/v1/auth"
MYSQL_HOST=
MYSQL_DB=
MYSQL_USER=
MYSQL_PASS=
DISCORD_API="https://discord.com/api/v10"
DB_NAME=
DB_USER=
DB_PASS=
DB_HOST=
DB_PORT=
AUTH_SECRET=

17
.eslintrc.json Normal file
View file

@ -0,0 +1,17 @@
{
"extends": "next/core-web-vitals",
"rules": {
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}

View file

@ -0,0 +1,24 @@
name: Lint Codebase
on:
push:
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout The Repository
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install PNPM
uses: https://github.com/pnpm/action-setup@v3.0.0
with:
version: 9
- name: Lint
run: |
pnpm install
pnpm lint

View file

@ -1,25 +0,0 @@
name: Deploy Website
on:
push:
branches:
- main
jobs:
lint:
uses: ./.gitea/workflows/lint.yml
deploy:
runs-on: ubuntu-latest
needs: [ lint ]
steps:
- name: Deploy Website
uses: https://github.com/nekiro/ssh-job@main
with:
host: ${{ secrets.HOST }}
user: ${{ secrets.USER }}
password: ${{ secrets.PASSWORD }}
command: |
cd /var/www/crss
git pull
composer install --no-dev --optimize-autoloader
php .scripts/deploy.php

View file

@ -1,18 +0,0 @@
name: Lint PHP Code
on:
- push
- pull_request
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Lint PHP Code
run: php -l *.php **/*.php

125
.gitignore vendored
View file

@ -1,107 +1,36 @@
# Created by https://www.toptal.com/developers/gitignore/api/phpstorm+all,composer,dotenv
# Edit at https://www.toptal.com/developers/gitignore?templates=phpstorm+all,composer,dotenv
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
### Composer ###
composer.phar
/vendor/
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
# testing
/coverage
### dotenv ###
.env
# next.js
/.next/
/out/
### PhpStorm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# production
/build
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# misc
.DS_Store
*.pem
# AWS User-specific
.idea/**/aws.xml
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Generated files
.idea/**/contentModel.xml
# local env files
.env*.local
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# vercel
.vercel
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### PhpStorm+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.
.idea/*
!.idea/codeStyles
!.idea/runConfigurations
# End of https://www.toptal.com/developers/gitignore/api/phpstorm+all,composer,dotenv
.build.json
style.css*
style.min.css*
# typescript
*.tsbuildinfo
next-env.d.ts

View file

@ -1,49 +0,0 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use JShrink\Minifier;
$buildId = uniqid();
$_CONFIG = Array(
'paths' => Array(
'main' => str_replace('/.scripts/deploy.php', '', __FILE__),
'css' => str_replace('/.scripts/deploy.php', '', __FILE__) . '/css',
'js' => str_replace('/.scripts/deploy.php', '', __FILE__) . '/js'
)
);
require_once '_config.php';
// "Compile" SCSS
exec("sass {$_CONFIG['paths']['css']}/src/style.scss:{$_CONFIG['paths']['css']}/style.min.css --style compressed", $sassOutput);
// Get Git Data
exec('git rev-parse --abbrev-ref HEAD', $gitBranch);
exec('git rev-parse HEAD', $gitCommitSha);
exec('git show -s --format=%ct', $gitCommitTime);
// Write the contents to the file build file
file_put_contents('.build.json', json_encode([
'build' => [
'time' => date('c'),
'id' => $buildId
],
'git' => [
'branch' => $gitBranch[0],
'commit' => [
'sha' => $gitCommitSha[0],
'created' => date('c', $gitCommitTime[0])
]
]
]));
echo implode(PHP_EOL, $sassOutput) . PHP_EOL;
echo '`git rev-parse --abbrev-ref HEAD`: ' . implode(PHP_EOL, $gitBranch) . PHP_EOL;
echo '`git rev-parse HEAD`: ' . implode(PHP_EOL, $gitCommitSha) . PHP_EOL;
echo '`git show -s --format=%ct`: ' . implode(PHP_EOL, $gitCommitTime) . PHP_EOL;
echo PHP_EOL . "Deployment completed with build id: `$buildId`!" . PHP_EOL;
exit(0);

156
LICENSE
View file

@ -1,156 +0,0 @@
Creative Commons Attribution 4.0 International
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 Definitions.
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part; and
B. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. Term. The term of this Public License is specified in Section 6(a).
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
5. Downstream recipients.
A. Offer from the Licensor Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
Section 4 Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 Disclaimer of Warranties and Limitation of Liability.
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
Creative Commons may be contacted at creativecommons.org.

View file

@ -1,17 +1,40 @@
# CRSS Server's Website
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).
This is the official website for the CRSS Server.
## Getting Started
## Documentation
First, run the development server:
### Contributing
tba
## License
```
This work is licensed under CC BY 4.0.
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
See the [LICENSE](LICENSE) file for more information.
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.tsx`. 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.ts`.
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.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
## 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.

View file

@ -1,18 +0,0 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/vendor/autoload.php';
use Dotenv\Dotenv;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$loader = new FilesystemLoader('template');
$twig = new Environment($loader);

29
components/AdBanner.tsx Normal file
View file

@ -0,0 +1,29 @@
'use client';
import styles from '@/styles/AdBanner.module.scss';
import { Info } from 'lucide-react';
export default function AdBanner() {
return (
<div className={styles.container} style={{ display: 'flex', justifyContent: 'center', marginBottom: '1.5rem' }}>
<iframe id='a4962f15' name='a4962f15' src='https://ads.theclashfruit.me/www/delivery/afr.php?zoneid=3&amp;cb=75234' frameBorder='0' scrolling='no' width='468' height='60' allow='autoplay'></iframe>
</div>
);
/*
return (
<div className={styles.adBanner}>
<div className={styles.adContent}>
</div>
<div className={styles.adRevive}>
<iframe id='a4962f15' name='a4962f15' src='https://ads.theclashfruit.me/www/delivery/afr.php?zoneid=3&amp;cb=75234' frameBorder='0' scrolling='no' width='468' height='60' allow='autoplay'></iframe>
</div>
<button className={styles.adInfo}>
<Info />
</button>
</div>
);
*/
}

10
components/Card.tsx Normal file
View file

@ -0,0 +1,10 @@
import styles from '@/styles/Card.module.scss';
export default function Card({ children, className }: { children: React.ReactNode, className?: string }) {
return (
<div className={`${styles.card} ${className}`}>
{ children }
</div>
);
}

43
components/Dropdown.tsx Normal file
View file

@ -0,0 +1,43 @@
import styles from '@/styles/Dropdown.module.scss';
import Link from 'next/link';
import { useRef } from 'react';
export default function Dropdown({ children, items, className }: { children: React.ReactNode, items: { divider?: boolean, icon?: any, label?: string, href?: string }[], className: string }) {
const dropDownRef = useRef<HTMLDivElement>(null);
const handleClick = () => {
dropDownRef.current?.classList.toggle(styles.open);
};
return (
<div className={`${styles.dropDown} ${className}`} ref={dropDownRef}>
<label onClick={handleClick}>
{children}
</label>
<div className={styles.dropDownMenu}>
<ul>
{items.map((item, i) => (
(item.divider &&
<li key={i}>
<div className={styles.divider}></div>
</li>
) || (
<li key={i}>
<Link href={item.href!}>
{item.icon && <item.icon />}
{item.label}
</Link>
</li>
)
))}
</ul>
</div>
<div className={styles.mobileOverlay} onClick={handleClick} />
</div>
);
}

71
components/Footer.tsx Normal file
View file

@ -0,0 +1,71 @@
import {
SiModrinth,
SiForgejo,
SiYoutube,
SiDiscord
} from '@icons-pack/react-simple-icons';
import Link from 'next/link';
import styles from '@/styles/Footer.module.scss';
import AdBanner from './AdBanner';
export default function Footer() {
const git = {
branch: 'dev/nextjs',
commit: {
sha: 'aa1ece3db89e03e169c0031e9319e50bd4626ffb',
},
};
return (
<>
<AdBanner />
<footer className={styles.pageFooter}>
<div className={styles.container}>
<div>
<p>
Copyright &copy; {new Date().getFullYear()} CRSS
</p>
<p>
Website originally designed by Myadeleines, heavily modified and rewritten by TheClashFruit.
</p>
</div>
<div>
<ul>
<li>
<Link href="https://modrinth.com/organization/crss" target="_blank">
<SiModrinth />
</Link>
</li>
<li>
<Link href="https://git.theclashfruit.me/crss" target="_blank">
<SiForgejo />
</Link>
</li>
<li>
<Link href="https://youtube.com/@CRSS666" target="_blank">
<SiYoutube />
</Link>
</li>
<li>
<Link href="https://discord.gg/rGjCKawPkS" target="_blank">
<SiDiscord />
</Link>
</li>
</ul>
<p>
CRSS/Website
<br />
{git.branch}@<a href={`https://git.theclashfruit.me/CRSS/Website/commit/${git.commit.sha}`}>{git.commit.sha.slice(0, 7)}</a>
</p>
</div>
</div>
</footer>
</>
);
}

74
components/Meta.tsx Normal file
View file

@ -0,0 +1,74 @@
import Head from 'next/head';
import { useRouter } from 'next/router';
export default function Meta({ page }: { page: { title: string, user?: any } }) {
const router = useRouter();
let ldJson: any = {
'@context': 'https://schema.org',
'@type': 'WebSite',
name: 'Clyde\'s Real Survival SMP',
alternateName: [ 'CRSS' ],
url: 'https://crss.cc'
};
if (page.user) {
ldJson = {
'@context': 'https://schema.org',
'@type': 'ProfilePage',
mainEntity: {
'@type': 'Person',
name: page.user.global_name,
alternateName: page.user.username,
identifier: page.user.did,
image: `https://cdn.discordapp.com/avatars/${page.user.did}/${page.user.avatar}.png`,
}
};
}
return (
<Head>
<title>{page.title} &bull; Clyde&apos;s Real Survival SMP</title>
<meta name="name" content={`${page.title} &bull; Clyde's Real Survival SMP`} />
<meta name="description" content="A very cool minecraft SMP that updates to every version starting from b1.0." />
<meta name="keywords" content="crss, minecraft, beta, alpha, release, new, 1.0, version" />
<meta name="theme-color" content="#537F53" />
<meta property="og:site_name" content="Clyde's Real Survival SMP" />
<meta property="og:title" content={page.title} />
<meta property="og:type" content="website" />
<meta property="og:locale" content="en_GB" />
<meta property="og:image" content="https://crss.fra1.cdn.digitaloceanspaces.com/img/social_image.png" />
<meta property="og:description" content="A very cool minecraft SMP that updates to every version starting from b1.0." />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={`${page.title} &bull; Clyde's Real Survival SMP`} />
<meta name="twitter:description" content="A very cool minecraft SMP that updates to every version starting from b1.0." />
<meta name="twitter:image" content="https://crss.fra1.cdn.digitaloceanspaces.com/img/social_image.png" />
<meta property="twitter:domain" content="crss.cc" />
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(ldJson) }} />
{!page.user && (
<>
<meta property="og:url" content={`https://crss.cc${router.pathname}`} />
<meta property="twitter:url" content={`https://crss.cc${router.pathname}`} />
<link rel="canonical" href={`https://crss.cc${router.pathname}`} />
</>
) || (
<>
<meta property="og:url" content={`https://crss.cc/u/${page.user!.username}`} />
<meta property="twitter:url" content={`https://crss.cc/u/${page.user!.username}`} />
<link rel="canonical" href={`https://crss.cc/u/${page.user!.username}`} />
</>
)}
<link rel="icon" href="/favicon.ico" />
</Head>
);
}

207
components/NavBar.tsx Normal file
View file

@ -0,0 +1,207 @@
import {
Menu,
Home,
AtSign,
Images,
Map,
Gamepad,
User,
Settings,
LayoutDashboard,
LogOut,
LogIn,
Earth,
X
} from 'lucide-react';
import Link from 'next/link';
import styles from '@/styles/NavBar.module.scss';
import { getCookie } from '@/utils/cookies';
import Logo from '@/public/logo.svg';
import { useRouter } from 'next/router';
import getConfig from 'next/config';
import { useEffect, useRef, useState } from 'react';
import Dropdown from './Dropdown';
import { useUser } from '@/context/UserContext';
import {
Roles,
hasRole
} from '@/utils/permissions';
export default function NavBar({ currentPage }: { currentPage: string }) {
const { user, isLoggedIn } = useUser();
const [ navOpen, setNavOpen ] = useState(false);
const { publicRuntimeConfig } = getConfig();
const server = {
version: '1.12.2'
};
const buildDiscordUrl = (): string => {
const url = new URL('https://discord.com/api/oauth2/authorize');
url.searchParams.append('client_id', publicRuntimeConfig.discord.clientId);
url.searchParams.append('response_type', 'code');
url.searchParams.append('redirect_uri', publicRuntimeConfig.discord.redirectUri);
url.searchParams.append('scope', publicRuntimeConfig.discord.scopes.join(' '));
return url.toString();
};
return (
<>
<header className={styles.pageHero}>
<div className={styles.heroOverlay}>
<div className={styles.container}>
<div>
<Logo />
<h1>Clyde&apos;s Real Survival SMP!</h1>
</div>
<div>
<label htmlFor="ip">
Server Address:
</label>
<input type="text" value="play.crss.cc" id="ip" readOnly size={8} />
<label htmlFor="ip">
Version: {server.version}
</label>
</div>
</div>
</div>
</header>
<nav className={`${styles.navBar} ${navOpen ? styles.navOpen : ''}`}>
<div className={styles.container}>
<div className={styles.navMobileContainer}>
<button className={styles.navToggle} onClick={() => { setNavOpen(!navOpen); }}>
{ !navOpen ? <Menu /> : <X /> }
</button>
</div>
<div className={styles.navCollapse}>
<ul>
<li>
<Link href={currentPage == 'home' ? '#' : '/'} className={currentPage == 'home' ? styles.active : ''}>
<Home />
Home
</Link>
</li>
<li>
<Link href={currentPage == 'about' ? '#' : '/about'} className={currentPage == 'about' ? styles.active : ''}>
<AtSign />
About
</Link>
</li>
<li>
<Link href={currentPage == 'gallery' ? '#' : '/gallery'} className={currentPage == 'gallery' ? styles.active : ''}>
<Images />
Gallery
</Link>
</li>
<li>
<Link href={currentPage == 'map' ? '#' : '/map'} className={currentPage == 'map' ? styles.active : ''}>
<Map />
Map
</Link>
</li>
<li>
<Link href={currentPage == 'nations' ? '#' : '/nations'} className={currentPage == 'nations' ? styles.active : ''}>
<Earth />
Nations
</Link>
</li>
</ul>
<ul>
{(isLoggedIn && user) && (
<li>
{hasRole(user.permissions, Roles.Admin) && (
<Dropdown items={[
{
icon: User,
label: 'Profile',
href: `/u/${user ? user.names.username : 'Loading...'}`
},
{
icon: Settings,
label: 'Settings',
href: '/settings'
},
{
divider: true
},
{
icon: LayoutDashboard,
label: 'Admin',
href: '/admin'
},
{
icon: LogOut,
label: 'Logout',
href: '/logout'
}
]} className={styles.dropDown}>
<User />
{user ? user.names.global_name : 'Loading...'}
</Dropdown>
) || (
<Dropdown items={[
{
icon: User,
label: 'Profile',
href: `/u/${user ? user.names.username : 'Loading...'}`
},
{
icon: Settings,
label: 'Settings',
href: '/settings'
},
{
divider: true
},
{
icon: LogOut,
label: 'Logout',
href: '/logout'
}
]} className={styles.dropDown}>
<User />
{user ? user.names.global_name : 'Loading...'}
</Dropdown>
)}
</li>
)}
{(!isLoggedIn && !user) && (
<li>
<Link href={buildDiscordUrl()}>
<LogIn />
Login
</Link>
</li>
)}
</ul>
</div>
</div>
</nav>
</>
);
}

View file

@ -0,0 +1,21 @@
import { motion } from 'framer-motion';
import styles from '@/styles/global.module.scss';
export default function PageContent({ children }: { children: React.ReactNode }) {
return (
<motion.main
className={styles.pageContent}
initial={{ scale: 0.96, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.96, opacity: 0 }}
transition={{ duration: 0.24, ease: 'easeInOut', bounce: 0.45, type: 'spring', stiffness: 100, opacity: { bounce: 0 } }}
>
<div className={styles.container}>
{children}
</div>
</motion.main>
);
}

View file

@ -1,11 +0,0 @@
{
"require": {
"twig/twig": "^3.9",
"anlutro/curl": "^1.5",
"vlucas/phpdotenv": "^5.6",
"bramus/router": "^1.6",
"tedivm/jshrink": "^1.7",
"simple-icons/simple-icons": "^12.2",
"theclashfruit/lucide-static-php": "^0.390.0"
}
}

849
composer.lock generated
View file

@ -1,849 +0,0 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a76a73e4e249ed4a4f8f065d207b4037",
"packages": [
{
"name": "anlutro/curl",
"version": "1.5.2",
"source": {
"type": "git",
"url": "https://github.com/anlutro/php-curl.git",
"reference": "1c569768a106dd40f5160ebebb703f09c6b58c8b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/anlutro/php-curl/zipball/1c569768a106dd40f5160ebebb703f09c6b58c8b",
"reference": "1c569768a106dd40f5160ebebb703f09c6b58c8b",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "4.*"
},
"type": "library",
"autoload": {
"psr-4": {
"anlutro\\cURL\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Lutro",
"email": "anlutro@gmail.com"
}
],
"description": "Simple OOP cURL wrapper.",
"support": {
"issues": "https://github.com/anlutro/php-curl/issues",
"source": "https://github.com/anlutro/php-curl/tree/1.5.2"
},
"time": "2023-06-27T07:39:41+00:00"
},
{
"name": "bramus/router",
"version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/bramus/router.git",
"reference": "55657b76da8a0a509250fb55b9dd24e1aa237eba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bramus/router/zipball/55657b76da8a0a509250fb55b9dd24e1aa237eba",
"reference": "55657b76da8a0a509250fb55b9dd24e1aa237eba",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.14",
"phpunit/php-code-coverage": "~2.0",
"phpunit/phpunit": "~4.8"
},
"type": "library",
"autoload": {
"psr-0": {
"Bramus": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bram(us) Van Damme",
"email": "bramus@bram.us",
"homepage": "http://www.bram.us"
}
],
"description": "A lightweight and simple object oriented PHP Router",
"homepage": "https://github.com/bramus/router",
"keywords": [
"router",
"routing"
],
"support": {
"issues": "https://github.com/bramus/router/issues",
"source": "https://github.com/bramus/router/tree/1.6.1"
},
"time": "2021-11-18T19:24:07+00:00"
},
{
"name": "graham-campbell/result-type",
"version": "v1.1.2",
"source": {
"type": "git",
"url": "https://github.com/GrahamCampbell/Result-Type.git",
"reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/fbd48bce38f73f8a4ec8583362e732e4095e5862",
"reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0",
"phpoption/phpoption": "^1.9.2"
},
"require-dev": {
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
},
"type": "library",
"autoload": {
"psr-4": {
"GrahamCampbell\\ResultType\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
}
],
"description": "An Implementation Of The Result Type",
"keywords": [
"Graham Campbell",
"GrahamCampbell",
"Result Type",
"Result-Type",
"result"
],
"support": {
"issues": "https://github.com/GrahamCampbell/Result-Type/issues",
"source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.2"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
"type": "tidelift"
}
],
"time": "2023-11-12T22:16:48+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.2",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/php-option.git",
"reference": "80735db690fe4fc5c76dfa7f9b770634285fa820"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/80735db690fe4fc5c76dfa7f9b770634285fa820",
"reference": "80735db690fe4fc5c76dfa7f9b770634285fa820",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": true
},
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"autoload": {
"psr-4": {
"PhpOption\\": "src/PhpOption/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh"
},
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
}
],
"description": "Option Type for PHP",
"keywords": [
"language",
"option",
"php",
"type"
],
"support": {
"issues": "https://github.com/schmittjoh/php-option/issues",
"source": "https://github.com/schmittjoh/php-option/tree/1.9.2"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
"type": "tidelift"
}
],
"time": "2023-11-12T21:59:55+00:00"
},
{
"name": "simple-icons/simple-icons",
"version": "12.2.0",
"source": {
"type": "git",
"url": "https://github.com/simple-icons/simple-icons.git",
"reference": "45b0840f6a15e4912c61a9415dcb85f4bb583f23"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/simple-icons/simple-icons/zipball/45b0840f6a15e4912c61a9415dcb85f4bb583f23",
"reference": "45b0840f6a15e4912c61a9415dcb85f4bb583f23",
"shasum": ""
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"CC0-1.0"
],
"description": "SVG icons for popular brands",
"homepage": "https://simpleicons.org/",
"keywords": [
"icons",
"svg"
],
"support": {
"docs": "https://github.com/simple-icons/simple-icons#php-usage-",
"issues": "https://github.com/simple-icons/simple-icons/issues",
"source": "https://github.com/simple-icons/simple-icons"
},
"funding": [
{
"url": "https://opencollective.com/simple-icons",
"type": "opencollective"
}
],
"time": "2024-06-09T06:49:44+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.5.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-04-18T09:32:20+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.29.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4",
"reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"provide": {
"ext-ctype": "*"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-01-29T20:11:03+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.29.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"provide": {
"ext-mbstring": "*"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-01-29T20:11:03+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.29.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
"reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-01-29T20:11:03+00:00"
},
{
"name": "tedivm/jshrink",
"version": "v1.7.0",
"source": {
"type": "git",
"url": "https://github.com/tedious/JShrink.git",
"reference": "7a35f5a4651ca2ce77295eb8a3b4e133ba47e19e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tedious/JShrink/zipball/7a35f5a4651ca2ce77295eb8a3b4e133ba47e19e",
"reference": "7a35f5a4651ca2ce77295eb8a3b4e133ba47e19e",
"shasum": ""
},
"require": {
"php": "^7.0|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.14",
"php-coveralls/php-coveralls": "^2.5.0",
"phpunit/phpunit": "^9|^10"
},
"type": "library",
"autoload": {
"psr-0": {
"JShrink": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Robert Hafner",
"email": "tedivm@tedivm.com"
}
],
"description": "Javascript Minifier built in PHP",
"homepage": "http://github.com/tedious/JShrink",
"keywords": [
"javascript",
"minifier"
],
"support": {
"issues": "https://github.com/tedious/JShrink/issues",
"source": "https://github.com/tedious/JShrink/tree/v1.7.0"
},
"funding": [
{
"url": "https://github.com/tedivm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/tedivm/jshrink",
"type": "tidelift"
}
],
"time": "2023-10-04T17:23:23+00:00"
},
{
"name": "theclashfruit/lucide-static-php",
"version": "0.390.0",
"source": {
"type": "git",
"url": "https://github.com/TheClashFruit/lucide-static-php.git",
"reference": "2b6e1f1fd054afdbb8931d493422e93c04315dde"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TheClashFruit/lucide-static-php/zipball/2b6e1f1fd054afdbb8931d493422e93c04315dde",
"reference": "2b6e1f1fd054afdbb8931d493422e93c04315dde",
"shasum": ""
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"ISC"
],
"authors": [
{
"name": "TheClashFruit",
"email": "admin@theclashfruit.me"
}
],
"support": {
"issues": "https://github.com/TheClashFruit/lucide-static-php/issues",
"source": "https://github.com/TheClashFruit/lucide-static-php/tree/0.390.0"
},
"time": "2024-06-09T10:46:54+00:00"
},
{
"name": "twig/twig",
"version": "v3.10.3",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "67f29781ffafa520b0bbfbd8384674b42db04572"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/67f29781ffafa520b0bbfbd8384674b42db04572",
"reference": "67f29781ffafa520b0bbfbd8384674b42db04572",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-mbstring": "^1.3",
"symfony/polyfill-php80": "^1.22"
},
"require-dev": {
"psr/container": "^1.0|^2.0",
"symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0"
},
"type": "library",
"autoload": {
"files": [
"src/Resources/core.php",
"src/Resources/debug.php",
"src/Resources/escaper.php",
"src/Resources/string_loader.php"
],
"psr-4": {
"Twig\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Twig Team",
"role": "Contributors"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com",
"role": "Project Founder"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "https://twig.symfony.com",
"keywords": [
"templating"
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.10.3"
},
"funding": [
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
"type": "tidelift"
}
],
"time": "2024-05-16T10:04:27+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v5.6.0",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4",
"reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4",
"shasum": ""
},
"require": {
"ext-pcre": "*",
"graham-campbell/result-type": "^1.1.2",
"php": "^7.2.5 || ^8.0",
"phpoption/phpoption": "^1.9.2",
"symfony/polyfill-ctype": "^1.24",
"symfony/polyfill-mbstring": "^1.24",
"symfony/polyfill-php80": "^1.24"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"ext-filter": "*",
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
},
"suggest": {
"ext-filter": "Required to use the boolean validator."
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": true
},
"branch-alias": {
"dev-master": "5.6-dev"
}
},
"autoload": {
"psr-4": {
"Dotenv\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Vance Lucas",
"email": "vance@vancelucas.com",
"homepage": "https://github.com/vlucas"
}
],
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
"keywords": [
"dotenv",
"env",
"environment"
],
"support": {
"issues": "https://github.com/vlucas/phpdotenv/issues",
"source": "https://github.com/vlucas/phpdotenv/tree/v5.6.0"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
"type": "tidelift"
}
],
"time": "2023-11-12T22:43:29+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.6.0"
}

49
context/UserContext.tsx Normal file
View file

@ -0,0 +1,49 @@
import { getCookie } from '@/utils/cookies';
import getConfig from 'next/config';
import { createContext, useContext, useEffect, useState } from 'react';
interface UserContextType {
user: any;
isLoggedIn: boolean;
}
const UserContext = createContext<UserContextType>({ user: null, isLoggedIn: false });
export const UserProvider = ({ children }: { children: React.ReactNode }) => {
const [ user, setUser ] = useState(null);
const [ isLoggedIn, setIsLoggedIn ] = useState(false);
const { publicRuntimeConfig } = getConfig();
useEffect(() => {
const fetchUser = async () => {
const sessionCookie = getCookie('session');
if (sessionCookie) {
setIsLoggedIn(true);
try {
const res = await fetch('/api/v1/user/@me');
if (res.ok) {
const userData = await res.json();
setUser(userData);
}
} catch (error) {
console.error('Error fetching user data:', error);
}
}
};
fetchUser();
}, []);
return (
<UserContext.Provider value={{ user, isLoggedIn }}>
{children}
</UserContext.Provider>
);
};
export const useUser = () => useContext(UserContext);

126
index.php
View file

@ -1,126 +0,0 @@
<?php
global $twig;
require_once '_config.php';
use Bramus\Router\Router;
use anlutro\cURL\cURL;
use Twig\TwigFilter;
use Twig\TwigFunction;
$curl = new cURL();
$router = new Router();
session_start([
'cookie_lifetime' => 86400,
]);
$buildData = json_decode(file_get_contents('.build.json'));
$iconsFun = new TwigFunction('icon', function($icon, $attributes = []) {
$iconName = str_replace('/', '', $icon);
if (str_starts_with($iconName, 'simpleicons')) {
$iconName = str_replace('simpleicons.', '', $iconName);
$iconData = file_get_contents("./vendor/simple-icons/simple-icons/icons/$iconName.svg");
} else if (str_starts_with($iconName, 'lucide')) {
$iconName = str_replace('lucide.', '', $iconName);
$iconData = file_get_contents("./vendor/theclashfruit/lucide-static-php/icons/$iconName.svg");
} else {
$iconName = str_replace('.', '/', $iconName);
$iconData = file_get_contents("./icons/$iconName.svg");
}
foreach ($attributes as $key => $value) {
if ($key == 'class')
$iconData = preg_replace('/(class="\b[^"]*)"/i', '$1 ' . $value . '"', $iconData);
else
$iconData = preg_replace('/(<svg\b[^><]*)>/i', '$1 ' . $key . '="' . $value . '">', $iconData);
}
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = false;
$dom->loadXML($iconData);
$iconData = $dom->saveHTML();
$iconData = preg_replace('/(<!--\s.*)-->/i', '', $iconData);
$iconData = preg_replace('/\n/', ' ', $iconData);
return $iconData;
});
// override the default merge filter to add type casting
$mergeOverride = new TwigFilter('merge', function($array1, $array2) {
return array_merge((array) $array1, (array) $array2);
});
$twig->addFunction($iconsFun);
$twig->addFilter($mergeOverride);
$twig->addGlobal('git', $buildData->git);
$twig->addGlobal('server', [
'version' => '1.11.2',
]);
// recommended to start a five-server server for live reloading
if (isset($_ENV['IS_DEV']))
$twig->addGlobal('is_dev', true);
/*
$twig->addGlobal('user', [
'name' => 'John Doe'
]);
*/
$router->get('/', function() {
global $twig;
echo $twig->render('index.twig', [
'page' => [
'title' => 'Home',
'path' => '/',
'id' => 'home'
]
]);
});
$router->get('/about', function() {
global $twig;
echo $twig->render('about.twig', [
'page' => [
'title' => 'About Us',
'path' => '/about',
'id' => 'about'
],
'props' => [
'team' => json_decode(file_get_contents('.data/team.json'))
]
]);
});
$router->get('/helloworld', function() {
echo '<!DOCTYPE html>';
echo '<h1>Hello World!!</h1>';
});
$router->set404(function() {
global $twig;
echo $twig->render('404.twig', [
'page' => [
'title' => '404 Not Found',
'path' => $_SERVER['REQUEST_URI'],
'id' => '404'
]
]);
});
$router->run();

View file

@ -1,24 +0,0 @@
const $ = _ => document.querySelector(_);
const $$ = _ => document.querySelectorAll(_);
const dropDowns = $$('.dropDown');
dropDowns.forEach(dropDown => {
dropDown.children[0].addEventListener('click', () => {
dropDown.classList.toggle('open');
});
});
// ------------ //
const navBar = $('.navBar');
const navToggle = $('.navToggle');
const navCollapse = $('.navCollapse');
navToggle.addEventListener('click', () => {
navBar.classList.toggle('navOpen');
navToggle.innerHTML = navBar.classList.contains('navOpen') ?
'<svg xmlns="http://www.w3.org/2000/svg" class="lucide lucide-x icon" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg>' :
'<svg xmlns="http://www.w3.org/2000/svg" class="lucide lucide-menu icon" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" x2="20" y1="12" y2="12"></line><line x1="4" x2="20" y1="6" y2="6"></line><line x1="4" x2="20" y1="18" y2="18"></line></svg>';
});

178
lib/Database.ts Normal file
View file

@ -0,0 +1,178 @@
import { Role } from '@/utils/permissions';
import mysql, { Pool, QueryResult } from 'mysql2/promise';
import crypto from 'node:crypto';
interface DiscordTokenData {
token_type: string;
access_token: string;
expires_in: number;
refresh_token: string;
scope: string;
id_token: string;
}
interface UserTable {
id: number;
did: string;
username: string;
global_name: string;
email: string;
avatar: string;
banner: string;
accent_color: number;
permissions: number;
}
interface TeamMember {
id: number;
uid: number;
did: string;
username: string;
global_name: string;
email: string;
avatar: string;
banner: string;
accent_color: number;
permissions: number;
role: Role;
}
class Database {
static instance: (Database | null) = null;
mysqlPool: (Pool | null) = null;
constructor() {
if(Database.instance)
return Database.instance;
this.mysqlPool = mysql.createPool({
database: process.env.DB_NAME,
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASS,
waitForConnections: true,
supportBigNumbers: true,
connectionLimit: 10,
queueLimit: 0
});
Database.instance = this;
}
// Auth Stuff
async createUser(user: any): Promise<number> {
const [ result ] = await this.mysqlPool!.execute('SELECT * FROM users WHERE did = ?', [ user.id ]);
if ((result as any).length > 0) {
return (result as any)[0].id;
}
const [ res ] = await this.mysqlPool!.execute('INSERT INTO users (did, username, global_name, email, avatar, banner, accent_color) VALUES (?, ?, ?, ?, ?, ?, ?)', [
user.id,
user.username,
user.global_name,
user.email,
user.avatar,
user.banner,
user.accent_color
]);
return (res as any).insertId;
}
/**
* Creates a session for the user.
*
* Should only be called by backend!
*
* @param userData The data returned from the `/oauth2/token` endpoint.
* @param userAgent The user agent of the user.
*
* @returns `string` The session token.
*/
async createSession(userData: DiscordTokenData, userAgent?: string): Promise<string | null> {
const res = await fetch(`${process.env.DISCORD_API}/users/@me`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${userData.access_token}`,
},
});
if (res.ok) {
const user = await res.json();
const uid = await this.createUser(user);
const sum = crypto.createHmac('sha256', process.env.AUTH_SECRET!);
const base = Buffer.from(user.id).toString('base64');
sum.update(userData.access_token);
const sid = base + '.' + sum.digest('hex');
const [ result ] = await this.mysqlPool!.execute('INSERT INTO sessions (sid, uid, access_token, refresh_token, id_token, user_agent, expires) VALUES (?, ?, ?, ?, ?, ?, ?)', [
sid,
uid,
userData.access_token,
userData.refresh_token,
userData.id_token,
userAgent,
new Date(Date.now() + (userData.expires_in * 1000)),
]);
return sid;
} else {
throw new Error('Error Fetching Discord User Data');
}
}
async getSession(sid: string): Promise<any> {
const [ rows ] = await this.mysqlPool!.execute('SELECT * FROM sessions WHERE sid = ?', [ sid ]);
return (rows as any)[0];
}
// End of Auth Stuff
async getUser(id: number): Promise<UserTable> {
const [ rows ] = await this.mysqlPool!.execute('SELECT * FROM users WHERE id = ?', [ id ]);
return (rows as UserTable[])[0];
}
async getUserUsername(username: string): Promise<UserTable> {
const [ rows ] = await this.mysqlPool!.execute('SELECT * FROM users WHERE username = ?', [ username ]);
return (rows as UserTable[])[0];
}
async getUserSessions(uid: number): Promise<any> {
const [ rows ] = await this.mysqlPool!.execute('SELECT * FROM sessions WHERE uid = ?', [ uid ]);
return rows;
}
async getTeam(): Promise<TeamMember[]> {
const [ rows ] = await this.mysqlPool!.execute('SELECT team_members.id AS tid, team_members.uid AS uid, users.did, users.username, users.global_name, users.email, users.avatar, users.banner, users.accent_color, users.permissions, team_members.role FROM team_members JOIN users ON team_members.uid = users.id;');
return (rows as any).map((row: any) => {
return {
id: row.tid,
uid: row.uid,
did: row.did,
username: row.username,
global_name: row.global_name,
email: row.email,
avatar: row.avatar,
banner: row.banner,
accent_color: row.accent_color,
permissions: row.permissions,
role: (row.role as Role),
};
});
}
}
export default Database;

63
next.config.js Normal file
View file

@ -0,0 +1,63 @@
const path = require('path');
const childProcess = require('child_process');
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
sassOptions: {
includePaths: [ path.join(__dirname, 'styles') ]
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'cdn.discordapp.com',
port: '',
pathname: '/**',
}
]
},
publicRuntimeConfig: {
modifiedDate: new Date().getTime(),
discord: {
clientId: process.env.DISCORD_CLIENT,
redirectUri: process.env.DISCORD_REDIRECT,
api: process.env.DISCORD_API,
scopes: [
'identify',
'guilds',
'email',
'openid'
]
}
},
generateBuildId: async () => {
return childProcess.execSync('git rev-parse HEAD').toString().trim();
},
headers: async () => {
return [
{
source: '/api/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*'
}
]
}
];
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: [ '@svgr/webpack' ]
});
return config;
},
experimental: {
optimizePackageImports: [ '@icons-pack/react-simple-icons' ]
}
};
module.exports = nextConfig;

35
package.json Normal file
View file

@ -0,0 +1,35 @@
{
"name": "crss-website",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@icons-pack/react-simple-icons": "^10.0.0",
"@svgr/webpack": "^8.1.0",
"bcrypt": "^5.1.1",
"cookie": "^0.6.0",
"framer-motion": "^11.3.31",
"jose": "^5.8.0",
"lucide-react": "^0.429.0",
"mysql2": "^3.11.0",
"next": "14.2.6",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"showdown": "^2.1.0"
},
"devDependencies": {
"@types/cookie": "^0.6.0",
"@types/node": "^20.16.2",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.6",
"sass": "^1.77.8",
"typescript": "^5.5.4"
}
}

25
pages/404.tsx Normal file
View file

@ -0,0 +1,25 @@
import Footer from '@/components/Footer';
import Meta from '@/components/Meta';
import NavBar from '@/components/NavBar';
import PageContent from '@/components/PageContent';
export default function NotFound() {
return (
<>
<Meta page={{ title: '404' }} />
<NavBar currentPage="404" />
<PageContent>
<div className="container">
<h1 id="404-not-found">404 Not Found</h1>
<p>
We couldn&apos;t find this page :(
</p>
</div>
</PageContent>
<Footer />
</>
);
}

16
pages/_app.tsx Normal file
View file

@ -0,0 +1,16 @@
import '@/styles/globals.scss';
import { UserProvider } from '@/context/UserContext';
import { AnimatePresence } from 'framer-motion';
import type { AppProps } from 'next/app';
export default function App({ Component, pageProps, router }: AppProps) {
return (
<UserProvider>
<AnimatePresence mode="wait" initial={false} onExitComplete={() => window.scrollTo(0, 0)}>
<Component {...pageProps} key={router.asPath} />
</AnimatePresence>
</UserProvider>
);
}

13
pages/_document.tsx Normal file
View file

@ -0,0 +1,13 @@
import { Html, Head, Main, NextScript } from 'next/document';
export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}

78
pages/about.tsx Normal file
View file

@ -0,0 +1,78 @@
import Card from '@/components/Card';
import Footer from '@/components/Footer';
import NavBar from '@/components/NavBar';
import PageContent from '@/components/PageContent';
import Database from '@/lib/Database';
import Image from 'next/image';
import Link from 'next/link';
import { Role } from '@/utils/permissions';
import styles from '@/styles/About.module.scss';
import { Globe } from 'lucide-react';
import Meta from '@/components/Meta';
export default function About({ teamMembers }: { teamMembers: any[] }) {
return (
<>
<Meta page={{ title: 'About' }} />
<NavBar currentPage="about" />
<PageContent>
<h1>About</h1>
<p>
We are a small team running this server.
</p>
<h2>Team</h2>
<div className={styles.teamList}>
{teamMembers.map((member, i) => (
<Card key={i} className={styles.teamCard}>
<div className={styles.memberBanner}>
<Image src={`https://cdn.discordapp.com/avatars/${member.did}/a_${member.avatar}.png`} alt={member.global_name} width={128} height={128} />
</div>
<div className={styles.memberContent}>
<ul className={styles.memberLinks}>
<li>
<Link href="#" title="Website">
<Globe />
</Link>
</li>
</ul>
<h3>{member.global_name}</h3>
{member.role === Role.Owner && <label>Owner</label>}
{member.role === Role.Admin && <label>Admin</label>}
</div>
</Card>
))}
</div>
</PageContent>
<Footer />
</>
);
}
export async function getServerSideProps(context: any) {
const db = new Database();
const teamMembers = await db.getTeam();
if (!teamMembers)
return {
notFound: true
};
return {
props: {
teamMembers
}
};
}

52
pages/admin/index.tsx Normal file
View file

@ -0,0 +1,52 @@
import PageContent from '@/components/PageContent';
import { useUser } from '@/context/UserContext';
import { getCookieFromContext } from '@/utils/cookies';
export default function Admin() {
const { user, isLoggedIn } = useUser();
if (!isLoggedIn) {
return null;
}
return (
<>
<nav>
<ul>
<li>tba</li>
</ul>
</nav>
<PageContent>
<h1>Admin</h1>
<p>Welcome, {user.global_name}!</p>
<p>What are we doin&apos; today?</p>
</PageContent>
</>
);
}
export async function getServerSideProps(context: any) {
const { req } = context;
const cookie = req.headers.cookie;
let isLoggedIn = false;
if (cookie) {
const sessionCookie = getCookieFromContext('session', cookie);
if (sessionCookie) {
isLoggedIn = true;
}
}
if (!isLoggedIn) {
return {
notFound: true,
};
}
return {
props: {},
};
}

13
pages/api/hello.ts Normal file
View file

@ -0,0 +1,13 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next';
type Data = {
name: string;
};
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>,
) {
res.status(200).json({ name: 'John Doe' });
}

63
pages/api/v1/auth.ts Normal file
View file

@ -0,0 +1,63 @@
import Database from '@/lib/Database';
import { serialize } from 'cookie';
import type { NextApiRequest, NextApiResponse } from 'next';
type Data = {
sid: string | null;
};
type Error = {
error: string;
};
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Data | Error>,
) {
const db = new Database();
const { code } = req.query;
const discordApi = process.env.DISCORD_API!;
try {
if (typeof code === 'string') {
const data = await fetch(`${discordApi}/oauth2/token`, {
method: 'POST',
body: new URLSearchParams({
client_id: process.env.DISCORD_CLIENT!,
client_secret: process.env.DISCORD_SECRET!,
grant_type: 'authorization_code',
code,
redirect_uri: process.env.DISCORD_REDIRECT!,
}),
});
const json = await data.json();
const sid = await db.createSession(json, req.headers['user-agent']);
if (sid) {
const cookie = serialize('session', sid, {
secure: process.env.NODE_ENV === 'production',
sameSite: 'strict',
path: '/',
expires: new Date(Date.now() + json.expires_in * 1000),
});
res.setHeader('Set-Cookie', cookie);
res.redirect('/');
}
return;
}
} catch (error) {
res.status(500).json(
{ error: 'Internal Server Error' }
);
}
res.status(400).json(
{ error: 'Invalid code' }
);
}

52
pages/api/v1/user/@me.ts Normal file
View file

@ -0,0 +1,52 @@
import Database from '@/lib/Database';
import type { NextApiRequest, NextApiResponse } from 'next';
type Data = {
id: number;
discord_id: string;
names: {
username: string;
global_name: string;
};
email: string;
avatar: string;
banner: string;
accent_color: number;
permissions: number;
};
interface Error {
error: string;
}
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Data | Error>,
) {
const db = new Database();
const sid = req.cookies.session;
if (!sid)
return res.status(401).json({ error: 'Unauthorized' });
const session = await db.getSession(sid!);
if (!session)
return res.status(401).json({ error: 'Unauthorized' });
const user = await db.getUser(session.uid);
res.status(200).json({
id: user.id,
discord_id: user.did,
names: {
username: user.username,
global_name: user.global_name
},
email: user.email,
avatar: user.avatar,
banner: user.banner,
accent_color: user.accent_color,
permissions: user.permissions
});
}

View file

@ -0,0 +1,45 @@
import Database from '@/lib/Database';
import type { NextApiRequest, NextApiResponse } from 'next';
type Data = {
id: number;
discord_id: string;
names: {
username: string;
global_name: string;
};
avatar: string;
banner: string;
accent_color: number;
permissions: number;
};
interface Error {
error: string;
}
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Data | Error>,
) {
const db = new Database();
const user = await db.getUserUsername(req.query.username as string);
if (!user) {
return res.status(404).json({ error: 'Not Found' });
}
res.status(200).json({
id: user.id,
discord_id: user.did,
names: {
username: user.username,
global_name: user.global_name
},
avatar: user.avatar,
banner: user.banner,
accent_color: user.accent_color,
permissions: user.permissions
});
}

25
pages/gallery.tsx Normal file
View file

@ -0,0 +1,25 @@
import Footer from '@/components/Footer';
import Meta from '@/components/Meta';
import NavBar from '@/components/NavBar';
import PageContent from '@/components/PageContent';
export default function Gallery() {
return (
<>
<Meta page={{ title: 'Gallery' }} />
<NavBar currentPage="gallery" />
<PageContent>
<div className="container">
<h1>Gallery</h1>
<p>
Under Construction
</p>
</div>
</PageContent>
<Footer />
</>
);
}

94
pages/index.tsx Normal file
View file

@ -0,0 +1,94 @@
import AdBanner from '@/components/AdBanner';
import Footer from '@/components/Footer';
import Meta from '@/components/Meta';
import NavBar from '@/components/NavBar';
import PageContent from '@/components/PageContent';
export default function Home() {
const nations = [ ];
return (
<>
<Meta page={{ title: 'Home' }} />
<NavBar currentPage="home" />
<PageContent>
<h1>Home</h1>
<p>
Welcome to Clyde&apos;s Real Survival SMP, CRSS for short. We are a small SMP server that updates to every version starting from b1.0 on the 1st of every month. We have a small community of players that are very friendly and welcoming to new players. We have a few rules that you should follow to make the server a better place for everyone, you can find them at the bottom of the page.
</p>
<p>
The server is built on the idea of nations, featuring { nations.length } nations so far, with the oldest being Panorama Socialist Federation, which was originally known as Republic of Panorama. These nations are scattered around the map, with some being more active than others. You can be sure to find a nation that fits your playstyle, if not you can just start your own!
</p>
<h2 id="modpacl">Modpack</h2>
<p>
We have a client-side modpack to make your experince on CRSS better, the mods included are intended to be small, simple, and follow the rules of CRSS.
</p>
<p>
You can download it from Modrinth: <a href="https://modrinth.com/modpack/crsspack">https://modrinth.com/modpack/crsspack</a>.
</p>
<h2 id="rules">Rules</h2>
<ol>
<li>
The use of modified clients that give an unfair advantage to players, such as hacked clients, is not permitted.
<ul>
<li>
You are not allowed to use them even for their legitimate features, such as a fullbright option.
</li>
<li>
If admins suspect you are hacking you will be immediately banned.
</li>
</ul>
</li>
<li>
Do not modify or destroy (grief) other player&apos;s constructions without their consent, or steal any of their items.
<ul>
<li>
You are allowed to visit any build, as long as you don&apos;t take anything, and if you do you pay them back.
</li>
<li>
You should ask permission in the discord or the in-game chat before modifying builds.
</li>
</ul>
</li>
<li>
Follow the laws of the nations you are in to avoid issues with other players and making the server unfun to play.
<ul>
<li>
If you feel the laws are too vague, feel free to ask the people in charge of them what they meanr with something, and feel free to contribute to them. Complaining that they don&apos;t make sense won&apos;t get you anywhere.
</li>
<li>
Breaking laws isn&apos;t bannable, the nation you are in will take measures and punish you for your actions as they see fit.
</li>
</ul>
</li>
<li>
Do not attempt to make nations where the territory is already owned by another nation.
<ul>
<li>
You can make it near the borders of a nation but never inside one, you can&apos;t just take existing territory as your own.
</li>
<li>
Other nations are free to claim more territory whenever they feel like it, as long as it doesnt take other nations&apos; territory with it.
</li>
</ul>
</li>
</ol>
</PageContent>
<Footer />
</>
);
}

32
pages/map.tsx Normal file
View file

@ -0,0 +1,32 @@
import Footer from '@/components/Footer';
import Meta from '@/components/Meta';
import NavBar from '@/components/NavBar';
import PageContent from '@/components/PageContent';
import { ExternalLink } from 'lucide-react';
import Link from 'next/link';
export default function Map() {
return (
<>
<Meta page={{ title: 'Map' }} />
<NavBar currentPage="map" />
<PageContent>
<h1>Map</h1>
<iframe src="https://map.crss.cc" width="100%" style={{ aspectRatio: '16/9' }} />
<p>
<Link href="https://map.crss.cc" target="_blank">
Open in New Tab
<ExternalLink />
</Link>
</p>
</PageContent>
<Footer />
</>
);
}

135
pages/settings.tsx Normal file
View file

@ -0,0 +1,135 @@
import Footer from '@/components/Footer';
import NavBar from '@/components/NavBar';
import PageContent from '@/components/PageContent';
import Database from '@/lib/Database';
import { notFound } from 'next/navigation';
import { useEffect, useState } from 'react';
import cookie from 'cookie';
import Meta from '@/components/Meta';
interface SettingsType {
animations: boolean;
ads: boolean;
language: string;
}
export default function Settings({ sessions }: { sessions: any[] }) {
const [ settings, setSettings ] = useState<SettingsType>({
animations: true,
ads: true,
language: 'en'
});
useEffect(() => {
const settings = localStorage.getItem('crss_settings');
if (settings !== null) {
setSettings(JSON.parse(settings));
}
}, []);
useEffect(() => {
localStorage.setItem('crss_settings', JSON.stringify(settings));
}, [ settings ]);
return (
<>
<Meta page={{ title: 'Settings' }} />
<NavBar currentPage="settings" />
<PageContent>
<h1>Settings</h1>
<div style={{ display: 'flex', flexDirection: 'column', gap: '.5rem' }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<label htmlFor="ani">Animations</label>
<input id="ani" type="checkbox" checked={settings.animations} onChange={e => setSettings({ ...settings, animations: e.target.checked })} />
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<label htmlFor="ads">Ads</label>
<input id="ads" type="checkbox" checked={settings.ads} onChange={e => setSettings({ ...settings, ads: e.target.checked })} />
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<label htmlFor="lang">Language</label>
<select id="lang" onChange={e => setSettings({ ...settings, language: e.target.value })}>
<option value="en">English</option>
<option value="hu">Hungarian</option>
</select>
</div>
</div>
<h2>Sessions</h2>
<table>
<thead>
<tr>
<th>User Agent</th>
<th>Created</th>
<th>Expires</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{sessions.map(session => (
<tr key={session.id}>
<td><code>{session.user_agent}</code></td>
<td>{new Date(session.created).toLocaleDateString('hu-HU')}</td>
<td>{new Date(session.expires).toLocaleDateString('hu-HU')}</td>
<td>
{session.current ? (
<label>Current Session</label>
) : (
<button>Sign Out</button>
)}
</td>
</tr>
))}
</tbody>
</table>
</PageContent>
<Footer />
</>
);
}
export async function getServerSideProps(context: any) {
const db = new Database();
const cookies = cookie.parse(context.req.headers.cookie);
if (!cookies.session)
return {
notFound: true
};
const session = await db.getSession(cookies.session);
if (!session)
return {
notFound: true
};
const sessions = await db.getUserSessions(session.uid);
if (!sessions)
return {
notFound: true
};
sessions.forEach((s: any) => {
s.current = session.id === s.id;
s.created = s.created.toISOString();
s.expires = s.expires.toISOString();
});
return {
props: {
sessions
}
};
}

65
pages/u/[username].tsx Normal file
View file

@ -0,0 +1,65 @@
import Footer from '@/components/Footer';
import Meta from '@/components/Meta';
import NavBar from '@/components/NavBar';
import PageContent from '@/components/PageContent';
import Database from '@/lib/Database';
import {
Roles,
hasRole
} from '@/utils/permissions';
import Image from 'next/image';
export default function User({ user }: { user: any }) {
return (
<>
<Meta page={{ title: user.global_name, user }} />
<NavBar currentPage="user" />
<PageContent>
<div className="container">
<h1>{user.global_name}</h1>
<Image src={`https://cdn.discordapp.com/avatars/${user.did}/a_${user.avatar}.png`} alt={user.global_name} width={128} height={128} />
<ul>
<li>Admin: {hasRole(user.permissions, Roles.Admin) ? 'Yes' : 'No'}</li>
<li>Plus: {hasRole(user.permissions, Roles.Plus) ? 'Yes' : 'No'}</li>
</ul>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Deserunt perferendis exercitationem aliquid? Corrupti, veniam nam quis, quas, reprehenderit similique perspiciatis veritatis consectetur quidem omnis iste placeat quod! Dolore, labore est.</p>
</div>
</PageContent>
<Footer />
</>
);
}
export async function getServerSideProps(context: any) {
const db = new Database();
const user = await db.getUserUsername(context.query.username as string);
if (!user) {
return {
notFound: true
};
}
return {
props: {
user: {
id: user.id,
did: user.did,
username: user.username,
global_name: user.global_name,
avatar: user.avatar,
banner: user.banner,
accent_color: user.accent_color,
permissions: user.permissions
}
}
};
}

5627
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

View file

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View file

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

94
styles/About.module.scss Normal file
View file

@ -0,0 +1,94 @@
@import 'variables.module';
@import 'global.module';
.teamList {
display: grid;
gap: 1rem;
grid-template-columns: repeat(3, minmax(200px, 1fr));
> .teamCard {
padding: 0;
width: 100%;
> .memberBanner {
position: relative;
height: 150px;
background: #537f53;
border-top-left-radius: calc(1rem - 1px);
border-top-right-radius: calc(1rem - 1px);
> img {
position: absolute;
bottom: -52px;
left: 16px;
border: 4px solid $colorSurfaceLight2;
border-radius: 1rem;
@media (prefers-color-scheme: dark) {
border-color: $colorSurfaceDark2;
}
}
&[data-has-background] {
background: var(--background);
}
}
> .memberContent {
padding: 1rem;
> .memberLinks {
display: flex;
justify-content: end;
align-items: end;
gap: .5rem;
list-style: none;
margin: 0 0 .5rem;
> li {
> a {
display: flex;
align-items: center;
padding: 4px;
color: $colorBorderLight3;
&:hover {
color: $colorPrimary;
}
@media (prefers-color-scheme: dark) {
color: $colorBorderDark3;
}
}
}
}
> h3 {
margin: 0;
}
}
}
@media (max-width: 992px) {
grid-template-columns: repeat(2, minmax(200px, 1fr));
}
@media (max-width: 768px) {
grid-template-columns: 1fr;
}
}

111
styles/AdBanner.module.scss Normal file
View file

@ -0,0 +1,111 @@
@import 'variables.module';
@import 'global.module';
.adBanner {
width: 100%;
height: 106px;
padding: 8px;
background: $colorSurfaceLight3;
border: 1px solid $colorBorderLight1;
border-radius: 1rem;
position: relative;
> .adContent {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
> .adRevive {
position: absolute;
top: 8px;
bottom: 8px;
left: 8px;
right: 8px;
display: flex;
align-items: center;
justify-content: center;
scale: 1.3;
@media (max-width: 768px) {
scale: 1;
height: 60px;
}
}
> .adInfo {
position: absolute;
top: 8px;
right: 8px;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
padding: 8px;
background: transparent;
border: none;
border-radius: 100%;
color: $colorTextLight1;
transition: 150ms;
&:hover {
background: rgba($colorPrimary, 0.25);
}
@media (max-width: 768px) {
display: none;
}
@media (prefers-color-scheme: dark) {
color: $colorTextDark1;
}
}
@media (max-width: 768px) {
border-color: transparent !important;
background: transparent !important;
height: calc(60px);
padding: 0;
> .adContent {
display: none;
}
> .adRevive {
position: initial;
}
}
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark3;
border-color: $colorBorderDark1;
}
}

17
styles/Card.module.scss Normal file
View file

@ -0,0 +1,17 @@
@import 'variables.module';
@import 'global.module';
.card {
background: $colorSurfaceLight2;
border: 1px solid $colorBorderLight1;
border-radius: 1rem;
padding: 1rem;
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark2;
border-color: $colorBorderDark1;
}
}

153
styles/Dropdown.module.scss Normal file
View file

@ -0,0 +1,153 @@
@import 'variables.module';
@import 'global.module';
.dropDown {
position: relative;
> label {
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
padding: 8px 24px;
}
> .dropDownMenu {
position: absolute;
top: calc(100% + 4px);
right: 0;
background: $colorSurfaceLight4;
border: 1px solid $colorBorderLight1;
border-radius: .5rem;
overflow: hidden;
display: none;
min-width: max(100%, 200px);
> ul {
list-style: none;
display: flex;
flex-direction: column;
margin: 0;
> li {
> a {
padding: 11px 24px;
display: flex;
flex-direction: row;
align-items: center;
gap: 24px;
text-decoration: none;
transition: 150ms;
> .icon {
width: 20px;
height: 20px;
}
&:hover {
background: rgba($colorPrimary, 0.65);
color: $colorSurfaceLight1;
}
}
> .divider {
border-bottom: 1px solid $colorBorderLight1;
width: 100%;
@media (prefers-color-scheme: dark) {
border-color: $colorBorderDark1;
}
}
}
}
@media (prefers-color-scheme: dark) {
border-color: $colorBorderDark1;
background: $colorSurfaceDark4;
}
}
> .mobileOverlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba($colorSurfaceLight1, 0.65);
display: none;
@media (prefers-color-scheme: dark) {
background: rgba($colorSurfaceDark1, 0.65);
}
}
&.open {
> label {
outline: 2px solid rgba($colorPrimary, 0.65);
color: $colorPrimary;
}
> .dropDownMenu {
display: block;
z-index: 1000000;
}
@media (max-width: 768px) {
> .mobileOverlay {
display: block;
z-index: 100000;
}
> .dropDownMenu {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
min-width: fit-content;
min-height: fit-content;
height: fit-content;
width: 80vw;
overflow-y: auto;
border-radius: 1rem;
padding: 8px 0;
> ul {
align-items: initial;
}
}
}
}
}

102
styles/Footer.module.scss Normal file
View file

@ -0,0 +1,102 @@
@import 'variables.module';
@import 'global.module';
.pageFooter {
background: $colorSurfaceLight3;
border-top: 1px solid $colorBorderLight1;
> .container {
display: flex;
justify-content: space-between;
align-items: start;
padding: 1rem 0;
p {
margin-bottom: .5rem;
}
div:first-child {
width: 420px;
}
div:last-child {
text-align: right;
> ul {
display: flex;
gap: 1rem;
list-style: none;
> li {
> a {
display: flex;
align-items: center;
justify-content: center;
width: 31px;
height: 31px;
border-radius: 50%;
padding: 4px;
transition: 150ms;
color: $colorTextLight1;
&:hover {
color: $colorPrimary;
}
@media (prefers-color-scheme: dark) {
color: $colorTextDark1;
}
}
}
}
}
@media (max-width: 768px) {
flex-direction: column;
div:first-child {
width: 100%;
text-align: center;
}
div:last-child {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
margin-top: 1rem;
}
ul {
margin: 0;
margin-bottom: 1.5rem;
}
}
}
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark3;
border-color: $colorBorderDark1;
}
}

View file

@ -1,97 +1,5 @@
@import 'fonts';
@import 'colors';
* {
padding: 0;
margin: 0;
box-sizing: border-box;
scrollbar-color: $colorPrimary $colorSurfaceLight1;
@media (prefers-color-scheme: dark) {
scrollbar-color: $colorPrimary $colorSurfaceDark1;
}
}
*::selection {
background: rgba($colorPrimary, 0.75);
@media (prefers-color-scheme: dark) {
background: rgba($colorPrimary, 0.65);
}
}
body {
display: flex;
flex-direction: column;
min-height: 100svh;
background: $colorSurfaceLight1;
color: $colorTextLight1;
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark1;
color: $colorTextDark1;
}
}
main {
padding: 1.5rem 0;
flex: 1 1;
}
a {
color: $colorPrimary;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
button {
cursor: pointer;
}
ol, ul {
list-style-position: inside;
margin-left: 1rem;
}
pre {
overflow-x: scroll;
max-width: 100%;
display: block;
padding: 1rem;
background: $colorSurfaceLight2;
border: 1px solid $colorBorderLight1;
border-radius: .5rem;
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark2;
border-color: $colorBorderDark1;
}
}
.container {
max-width: 1100px;
margin: 0 auto;
@media (max-width: 1100px) {
margin: 0 1rem;
}
}
@import 'variables.module';
@import 'global.module';
.pageHero {
height: 220px;
@ -422,277 +330,4 @@ pre {
border: none;
}
}
.dropDown {
position: relative;
> label {
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
padding: 8px 24px;
}
> .dropDownMenu {
position: absolute;
top: calc(100% + 4px);
right: 0;
background: $colorSurfaceLight4;
border: 1px solid $colorBorderLight1;
border-radius: .5rem;
overflow: hidden;
display: none;
min-width: max(100%, 200px);
> ul {
list-style: none;
display: flex;
flex-direction: column;
margin: 0;
> li {
> a {
padding: 11px 24px;
display: flex;
flex-direction: row;
align-items: center;
gap: 24px;
text-decoration: none;
transition: 150ms;
> .icon {
width: 20px;
height: 20px;
}
&:hover {
background: rgba($colorPrimary, 0.65);
color: $colorSurfaceLight1;
}
}
> .divider {
border-bottom: 1px solid $colorBorderLight1;
width: 100%;
@media (prefers-color-scheme: dark) {
border-color: $colorBorderDark1;
}
}
}
}
@media (prefers-color-scheme: dark) {
border-color: $colorBorderDark1;
background: $colorSurfaceDark4;
}
}
&.open {
> label {
outline: 2px solid rgba($colorPrimary, 0.65);
color: $colorPrimary;
}
> .dropDownMenu {
display: block;
}
}
}
.pageContent {
}
.pageFooter {
background: $colorSurfaceLight3;
border-top: 1px solid $colorBorderLight1;
> .container {
display: flex;
justify-content: space-between;
align-items: start;
padding: 1rem 0;
p {
margin-bottom: .5rem;
}
div:first-child {
width: 420px;
}
div:last-child {
text-align: right;
> ul {
display: flex;
gap: 1rem;
list-style: none;
> li {
> a {
display: flex;
align-items: center;
justify-content: center;
width: 31px;
height: 31px;
border-radius: 50%;
padding: 4px;
transition: 150ms;
color: $colorTextLight1;
&:hover {
color: $colorTextLight2;
}
@media (prefers-color-scheme: dark) {
color: $colorTextDark1;
&:hover {
color: $colorTextDark2;
}
}
}
}
}
}
}
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark3;
border-color: $colorBorderDark1;
}
}
.teamList {
display: grid;
gap: 1rem;
grid-template-columns: repeat(3, minmax(200px, 1fr));
> .teamCard {
border: 1px solid $colorBorderLight1;
border-radius: 1rem;
background: $colorSurfaceLight2;
> .memberBanner {
height: 150px;
position: relative;
background: $colorPrimary;
border-top-left-radius: calc(1rem - 1px);
border-top-right-radius: calc(1rem - 1px);
> img {
position: absolute;
bottom: -52px;
left: 16px;
border-radius: 1rem;
border: 4px solid $colorSurfaceLight2;
@media (prefers-color-scheme: dark) {
border-color: $colorSurfaceDark2;
}
}
&[data-has-background] {
background: var(--background);
}
}
> .memberContent {
padding: 1rem;
> h3 {
margin: 0;
}
> .memberLinks {
display: flex;
justify-content: end;
align-items: end;
gap: .5rem;
list-style: none;
margin: 0 0 .5rem;
> li > a {
display: flex;
align-items: center;
padding: 4px;
color: $colorBorderLight3;
&:hover {
color: $colorPrimary;
}
@media (prefers-color-scheme: dark) {
color: $colorBorderDark3;
}
}
}
}
@media (prefers-color-scheme: dark) {
border-color: $colorBorderDark1;
background: $colorSurfaceDark2;
}
}
@media (max-width: 992px) {
grid-template-columns: repeat(2, minmax(200px, 1fr));
}
@media (max-width: 768px) {
grid-template-columns: 1fr;
}
}

View file

@ -1,6 +1,6 @@
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700&family=Noto+Color+Emoji&family=Noto+Emoji:wght@300..700&family=Noto+Sans+Mono:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&family=Outfit:wght@100..900&display=swap');
body, input {
body, input, textarea, select, button {
font-family: 'Noto Sans', 'Noto Color Emoji', 'Noto Emoji', sans-serif;
}
@ -40,10 +40,4 @@ p, ol, ul, label, a {
p:not(:last-child), ol:not(li > ol, li > ul, :last-child), ul:not(li > ol, li > ul, :last-child) {
margin-bottom: 1rem;
}
/*
.pageHero {
font-family: 'Comic Neue', 'Comic Sans MS', 'Noto Color Emoji', 'Noto Emoji', sans-serif;
}
*/
}

13
styles/global.module.scss Normal file
View file

@ -0,0 +1,13 @@
.container {
max-width: 1100px;
margin: 0 auto;
@media (max-width: 1100px) {
margin: 0 1rem;
}
}
.pageContent {
// trolley
}

221
styles/globals.scss Normal file
View file

@ -0,0 +1,221 @@
@import 'variables.module';
@import 'fonts.module';
@import 'global.module';
* {
padding: 0;
margin: 0;
box-sizing: border-box;
scrollbar-color: $colorPrimary $colorSurfaceLight1;
@media (prefers-color-scheme: dark) {
scrollbar-color: $colorPrimary $colorSurfaceDark1;
}
}
*::selection {
background: rgba($colorPrimary, 0.75);
@media (prefers-color-scheme: dark) {
background: rgba($colorPrimary, 0.65);
}
}
body {
background: $colorSurfaceLight1;
color: $colorTextLight1;
overflow-x: hidden;
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark1;
color: $colorTextDark1;
}
}
#__next {
display: flex;
flex-direction: column;
min-height: 100svh;
}
main {
padding: 1.5rem 0;
flex: 1 1;
}
a {
color: $colorPrimary;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
button {
cursor: pointer;
}
ol, ul {
list-style-position: inside;
margin-left: 1rem;
}
pre {
overflow-x: scroll;
max-width: 100%;
display: block;
padding: 1rem;
background: $colorSurfaceLight2;
border: 1px solid $colorBorderLight1;
border-radius: .5rem;
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark2;
border-color: $colorBorderDark1;
}
}
iframe {
background: $colorSurfaceLight2;
border: 1px solid $colorBorderLight1;
border-radius: 1rem;
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark2;
border-color: $colorBorderDark1;
}
}
// inputs
input {
&[type='checkbox'] {
appearance: none;
width: 52px;
height: 2rem;
background: $colorSurfaceLight2;
border: 1px solid $colorBorderLight1;
border-radius: 1rem;
position: relative;
cursor: pointer;
transition: 150ms;
&::before {
content: "";
position: absolute;
height: 1rem;
width: 1rem;
border-radius: 50%;
background: $colorPrimary;
top: 50%;
left: .5rem;
transform: translateY(-50%);
transition: 150ms;
}
&:checked {
background: $colorPrimary;
&::before {
background: $colorSurfaceLight2;
transform: translate(20px, -50%);
animation: thumbAnimation 150ms;
}
}
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark2;
border-color: $colorBorderDark1;
&::before {
background: $colorPrimary;
}
&:checked {
background: $colorPrimary;
&::before {
background: $colorSurfaceDark2;
transform: translate(20px, -50%);
animation: thumbAnimation 150ms;
}
}
}
}
}
select {
appearance: none;
padding: .5rem 1rem;
background: $colorSurfaceLight2;
color: $colorTextLight1;
border: 1px solid $colorBorderLight1;
border-radius: .5rem;
cursor: pointer;
transition: 150ms;
&:hover {
border-color: $colorPrimary;
}
&:focus {
outline: none;
border-color: $colorPrimary;
}
@media (prefers-color-scheme: dark) {
background: $colorSurfaceDark2;
color: $colorTextDark1;
border-color: $colorBorderDark1;
}
}
@keyframes thumbAnimation {
from {
transform: translateY(-50%);
}
to {
transform: translate(20px, -50%);
}
}

View file

@ -1,17 +0,0 @@
{% include 'includes/head.twig' %}
{% include 'includes/hero.twig' %}
{% include 'includes/nav.twig' %}
<main class="pageContent">
<div class="container">
<h1 id="404-not-found">404 Not Found</h1>
<p>
We couldn't find this page :(
</p>
</div>
</main>
{% include 'includes/footer.twig' %}
{% include 'includes/foot.twig' %}

View file

@ -1,54 +0,0 @@
{% include 'includes/head.twig' %}
{% include 'includes/hero.twig' %}
{% include 'includes/nav.twig' %}
<main class="pageContent">
<div class="container">
<h1>About Us</h1>
<p>
We are a small team running this server.
</p>
<h2 id="rules">Team</h2>
<div class="teamList">
{% for member in props.team %}
<div class="teamCard">
<div class="memberBanner" {% if member.banner %}data-has-background="yes" style="--background: {{ member.banner }}"{% endif %}>
<img src="{{ member.picture }}" width="104" height="104" alt="{{ member.name }}'s Profile Picture" />
</div>
<div class="memberContent">
<ul class="memberLinks">
{% for link in member.links %}
<li>
{% set attributes = ({ 'class': 'icon' } | merge((link.icon.extra ? link.icon.extra : {}))) %}
<a href="{{ link.url }}" title="{{ link.name }}">
{{ icon(link.icon.id, attributes) | raw }}
</a>
</li>
{% endfor %}
</ul>
<h3>{{ member.name }}</h3>
<label>
{% if member.role == 0 %}
Owner
{% elseif member.role == 1 %}
Admin
{% else %}
N/A
{% endif %}
</label>
</div>
</div>
{% endfor %}
</div>
</div>
</main>
{% include 'includes/footer.twig' %}
{% include 'includes/foot.twig' %}

View file

@ -1,3 +0,0 @@
<script type="module" src="/js/main.js"></script>
</body>
</html>

View file

@ -1,44 +0,0 @@
<footer class="pageFooter">
<div class="container">
<div>
<p>
Copyright &copy; {{ 'now' | date('Y') }} CRSS
</p>
<p>
Website originally designed by Myadeleines, heavily modified and rewritten by TheClashFruit.
</p>
</div>
<div>
<ul>
<li>
<a href="https://modrinth.com/organization/crss">
{{ icon('simpleicons.modrinth', { 'width': '24', 'height': '24', 'fill': 'currentColor' }) | raw }}
</a>
</li>
<li>
<a href="https://git.theclashfruit.me/crss">
{{ icon('simpleicons.forgejo', { 'width': '24', 'height': '24', 'fill': 'currentColor' }) | raw }}
</a>
</li>
<li>
<a href="https://youtube.com/@CRSS666">
{{ icon('simpleicons.youtube', { 'width': '24', 'height': '24', 'fill': 'currentColor' }) | raw }}
</a>
</li>
<li>
<a href="https://discord.gg/rGjCKawPkS">
{{ icon('simpleicons.discord', { 'width': '24', 'height': '24', 'fill': 'currentColor' }) | raw }}
</a>
</li>
</ul>
<p>
CRSS/Website
<br />
{{ git.branch }}@<a href="https://git.theclashfruit.me/CRSS/Website/commit/{{ git.commit.sha }}">{{ git.commit.sha | slice(0, 7) }}</a>
</p>
</div>
</div>
</footer>

View file

@ -1,57 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<title>Clyde's Real Survival SMP &bull; {{ page.title }}</title>
<meta name="name" content="Clyde's Real Survival SMP &bull; {{ page.title }}" />
<meta name="description" content="A very cool minecraft SMP that updates to every version starting from b1.0." />
<meta name="keywords" content="crss, minecraft, beta, alpha, release, new, 1.0, version, {{ page.title }}" />
<meta name="theme-color" content="#537F53" />
<meta property="og:site_name" content="Clyde's Real Survival SMP" />
<meta property="og:title" content="{{ page.title }}" />
<meta property="og:type" content="website" />
<meta property="og:locale" content="en_GB" />
<meta property="og:url" content="https://crss.cc{{ page.path }}" />
<meta property="og:image" content="https://crss.cc/_internal/card?page={{ page.path }}" />
<meta property="og:description" content="A very cool minecraft SMP that updates to every version starting from b1.0." />
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="crss.cc" />
<meta property="twitter:url" content="https://crss.cc{{ page.path }}" />
<meta name="twitter:title" content="Clyde's Real Survival SMP &bull; {{ page.title }}" />
<meta name="twitter:description" content="A very cool minecraft SMP that updates to every version starting from b1.0." />
<meta name="twitter:image" content="https://crss.cc/_internal/card?page={{ page.path }}" />
<script type="importmap">
{
"imports": {
"@crss/": "/js/"
}
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "Clyde's Real Survival SMP",
"alternateName": [ "CRSS" ],
"url": "https://crss.cc"
}
</script>
<link rel="canonical" href="https://crss.cc{{ page.path }}" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="/css/style.min.css" />
{% if is_dev %}
<script async data-id="five-server" src="http://localhost:5500/fiveserver.js"></script>
{% endif %}
</head>
<body>

View file

@ -1,23 +0,0 @@
<header class="pageHero">
<div class="heroOverlay">
<div class="container">
<div>
{{ icon('logo') | raw }}
<h1>Clyde's Real Survival SMP!</h1>
</div>
<div>
<label for="ip">
Server Address:
</label>
<input type="text" value="play.crss.cc" id="ip" readonly size="8" />
<label for="ip">
Version: {{ server.version }}
</label>
</div>
</div>
</div>
</header>

View file

@ -1,114 +0,0 @@
<nav class="navBar">
<div class="container">
<div class="navMobileContainer">
<button class="navToggle">
{{ icon('lucide.menu', { 'class': 'icon' }) | raw }}
</button>
</div>
<div class="navCollapse">
<ul>
<li>
<a {% if page.id == 'home' %} href="#" class="active" {% else %} href="/" {% endif %}>
{{ icon('lucide.home', { 'class': 'icon' }) | raw }}
Home
</a>
</li>
<li>
<a {% if page.id == 'about' %} href="#" class="active" {% else %} href="/about" {% endif %}>
{{ icon('lucide.at-sign', { 'class': 'icon' }) | raw }}
About
</a>
</li>
<li>
<a {% if page.id == 'gallery' %} href="#" class="active" {% else %} href="/gallery" {% endif %}>
{{ icon('lucide.images', { 'class': 'icon' }) | raw }}
Gallery
</a>
</li>
<li>
<a href="/map">
{{ icon('lucide.map', { 'class': 'icon' }) | raw }}
Map
</a>
</li>
<li>
<a href="/game">
{{ icon('lucide.gamepad', { 'class': 'icon' }) | raw }}
In-Game
</a>
</li>
</ul>
<ul>
{% if user %}
<li>
<div class="dropDown">
<label>
{{ icon('lucide.user', { 'class': 'icon' }) | raw }}
{{ user.name }}
</label>
<div class="dropDownMenu">
<ul>
<li>
<a href="/u/user">
{{ icon('lucide.user', { 'class': 'icon' }) | raw }}
Profile
</a>
</li>
<li>
<a href="/settings">
{{ icon('lucide.settings', { 'class': 'icon' }) | raw }}
Settings
</a>
</li>
<li>
<div class="divider"></div>
</li>
<li>
<a href="/admin">
{{ icon('lucide.layout-dashboard', { 'class': 'icon' }) | raw }}
Admin
</a>
</li>
<li>
<div class="divider"></div>
</li>
<li>
<a href="/logout">
{{ icon('lucide.log-out', { 'class': 'icon' }) | raw }}
Logout
</a>
</li>
</ul>
</div>
</div>
</li>
{% else %}
<li>
<a href="/auth">
{{ icon('lucide.log-in', { 'class': 'icon' }) | raw }}
Login
</a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>

View file

@ -1,74 +0,0 @@
{% include 'includes/head.twig' %}
{% include 'includes/hero.twig' %}
{% include 'includes/nav.twig' %}
<main class="pageContent">
<div class="container">
<h1>Home</h1>
<p>
Welcome to Clyde's Real Survival SMP, CRSS for short. We are a small SMP server that updates to every version starting from b1.0 on the 1st of every month. We have a small community of players that are very friendly and welcoming to new players. We have a few rules that you should follow to make the server a better place for everyone, you can find them at the bottom of the page.
</p>
<p>
The server is built on the idea of nations, featuring {{ nations | length }} nations so far, with the oldest being Panorama Socialist Federation, which was originally known as Republic of Panorama. These nations are scattered around the map, with some being more active than others. You can be sure to find a nation that fits your playstyle, if not you can just start your own!
</p>
<h2 id="rules">Rules</h2>
<ol>
<li>
The use of modified clients that give an unfair advantage to players, such as hacked clients, is not permitted.
<ul>
<li>
You are not allowed to use them even for their legitimate features, such as a fullbright option.
</li>
<li>
If admins suspect you are hacking you will be immediately banned.
</li>
</ul>
</li>
<li>
Do not modify or destroy (grief) other player's constructions without their consent, or steal any of their items.
<ul>
<li>
You are allowed to visit any build, as long as you don't take anything, and if you do you pay them back.
</li>
<li>
You should ask permission in the discord or the in-game chat before modifying builds.
</li>
</ul>
</li>
<li>
Follow the laws of the nations you are in to avoid issues with other players and making the server unfun to play.
<ul>
<li>
If you feel the laws are too vague, feel free to ask the people in charge of them what they meanr with something, and feel free to contribute to them. Complaining that they don't make sense won't get you anywhere.
</li>
<li>
Breaking laws isn't bannable, the nation you are in will take measures and punish you for your actions as they see fit.
</li>
</ul>
</li>
<li>
Do not attempt to make nations where the territory is already owned by another nation.
<ul>
<li>
You can make it near the borders of a nation but never inside one, you can't just take existing territory as your own.
</li>
<li>
Other nations are free to claim more territory whenever they feel like it, as long as it doesnt take other nations' territory with it.
</li>
</ul>
</li>
</ol>
</div>
</main>
{% include 'includes/footer.twig' %}
{% include 'includes/foot.twig' %}

21
tsconfig.json Normal file
View file

@ -0,0 +1,21 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

View file

@ -1,4 +0,0 @@
<?php
class DatabaseUtil {
// TODO: Add Database Stuff
}

View file

@ -1,4 +0,0 @@
<?php
class DiscordUtil {
// TODO: Add Discord Stuff
}

19
utils/cookies.ts Normal file
View file

@ -0,0 +1,19 @@
export function getCookie(name: string): string | null {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2)
return decodeURIComponent(parts.pop()?.split(';').shift()!) || null;
return null;
}
export function getCookieFromContext(name: string, cookie: string): string | null {
const value = `; ${cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2)
return decodeURIComponent(parts.pop()?.split(';').shift()!) || null;
return null;
}

13
utils/permissions.ts Normal file
View file

@ -0,0 +1,13 @@
export enum Roles {
Admin = 1 << 0,
Plus = 1 << 1
}
export enum Role {
Owner = 'owner',
Admin = 'admin',
}
export function hasRole(permissions: number, role: Roles): boolean {
return (permissions & role) === role;
}