Skip to content

Commit

Permalink
loading content for each episode using markdown files (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
nour-massri authored Oct 12, 2024
1 parent d5dccba commit ba855bb
Show file tree
Hide file tree
Showing 16 changed files with 829 additions and 110 deletions.
8 changes: 4 additions & 4 deletions frontend2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@types/node": "^16.18.26",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"highcharts": "^11.4.0",
"highcharts": "^11.4.8",
"highcharts-react-official": "^3.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
7 changes: 6 additions & 1 deletion frontend2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import MyTeam from "./views/MyTeam";
import Tournaments from "./views/Tournaments";
import TournamentPage from "./views/Tournament";
import Submissions from "./views/Submissions";
import DebuggingTips from "./views/DebuggingTips";
import CommonIssues from "./views/CommonIssues";

import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { toast, Toaster } from "react-hot-toast";
import { ResponseError } from "./api/_autogen/runtime";
Expand Down Expand Up @@ -199,7 +202,7 @@ const router = createBrowserRouter([
loader: homeLoader(queryClient),
},
{ path: "resources", element: <Resources /> },
{ path: "quickstart", element: <QuickStart /> },
{ path: "quick_start", element: <QuickStart /> },
{
path: "rankings",
element: <Rankings />,
Expand All @@ -225,6 +228,8 @@ const router = createBrowserRouter([
element: <TeamProfile />,
loader: teamProfileLoader(queryClient),
},
{ path: "debugging_tips", element: <DebuggingTips /> },
{ path: "common_issues", element: <CommonIssues /> },
{
path: "*",
element: <PageNotFound />,
Expand Down
31 changes: 31 additions & 0 deletions frontend2/src/components/OptionalSectionCardMarkdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react";
import type { Key } from "react";
import Markdown from "./elements/Markdown";
import SectionCard from "./SectionCard";

interface OptionalSectionCardMarkdownProps<T extends Key> {
children?: React.ReactNode;
title: T;
textRecord: Partial<Record<T, string>>;
}

const OptionalSectionCardMarkdown: React.FC<
OptionalSectionCardMarkdownProps<string>
> = <T extends string>({
children,
title,
textRecord,
}: OptionalSectionCardMarkdownProps<T>) => {
if (textRecord[title] !== undefined) {
return (
<SectionCard title={title}>
<Markdown text={textRecord[title] ?? ""} />
{children}
</SectionCard>
);
} else {
return <></>;
}
};

export default OptionalSectionCardMarkdown;
2 changes: 1 addition & 1 deletion frontend2/src/components/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const SIDEBAR_ITEM_DATA: Array<{
{
iconName: "map",
text: "Quick Start",
linkTo: "quickstart",
linkTo: "quick_start",
},
{
iconName: "clipboard_document",
Expand Down
47 changes: 47 additions & 0 deletions frontend2/src/content/ContentStruct.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export enum QuickStartPage {
OVERVIEW = "Overview",
ACCOUNT_AND_TEAM_CREATION = "Account and Team Creation",
INSTALLATION = "Installation",
RESOURCES = "Resources",
JOIN_THE_COMMUNITY = "Join the Community!",
}
export type QuickStartPageKey = `${QuickStartPage}`;

export enum ResourcesPage {
GAME_SPECIFICATION = "Game Specifications",
CODING_RESOURCES = "Coding Resources",
THIRD_PARTY_TOOLS = "Third-party Tools",
LECTURES = "Lectures",
}
export type ResourcesPageKey = `${ResourcesPage}`;

export enum CommonIssuesPage {
INSTALLATION_ISSUES = "Installation Issues",
CLIENT_ISSUES = "Client Issues",
OTHER_ISSUES = "Other Issues",
THINGS_TO_TRY = "Things to Try When Nothing Else Helps",
}
export type CommonIssuesPageKey = `${CommonIssuesPage}`;

export enum DebuggingTipsPage {
DEBUGGING = "Debugging",
INTELLIJ = "Debugging in IntelliJ",
ECLIPSE = "Debugging in Eclipse",
SECOND_METHOD = "Second Method: Debugging in IntelliJ",
}
export type DebuggingTipsPageKey = `${DebuggingTipsPage}`;

export enum TourneyPage {
SCHEDULE = "Tournament Schedule",
PRIZES = "Prizes",
FORMAT = "Tournament Format",
RULES = "Eligibility Rules",
}
export type TourneyPageKey = `${TourneyPage}`;

export type PageKey =
| QuickStartPageKey
| ResourcesPageKey
| TourneyPageKey
| DebuggingTipsPageKey
| CommonIssuesPageKey;
37 changes: 37 additions & 0 deletions frontend2/src/content/ManageContent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type {
DebuggingTipsPageKey,
TourneyPageKey,
QuickStartPageKey,
ResourcesPageKey,
CommonIssuesPageKey,
PageKey,
} from "./ContentStruct";

import * as BC24 from "./bc24";
import * as BC23 from "./bc23";
import * as BC22 from "./bc22";

const bcVersions: Record<string, typeof BC24 | typeof BC23 | typeof BC22> = {
bc24: BC24,
bc23: BC23,
bc22: BC22,
};

function createTextRecord<K extends PageKey>(
key: string,
): Record<string, Partial<Record<K, string>>> {
return Object.fromEntries(
Object.entries(bcVersions).map(([version, content]) => [
version,
content[key as keyof typeof content] as Partial<Record<K, string>>,
]),
) as Record<string, Partial<Record<K, string>>>;
}

export const quickStartText = createTextRecord<QuickStartPageKey>("QUICKSTART");
export const resourcesText = createTextRecord<ResourcesPageKey>("RESOURCES");
export const tournamentsText = createTextRecord<TourneyPageKey>("TOURNAMENTS");
export const debuggingTipsText =
createTextRecord<DebuggingTipsPageKey>("DEBUGGINGTIPS");
export const commonIssuesText =
createTextRecord<CommonIssuesPageKey>("COMMONISSUES");
77 changes: 77 additions & 0 deletions frontend2/src/content/bc22.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import type {
CommonIssuesPageKey,
DebuggingTipsPageKey,
QuickStartPageKey,
ResourcesPageKey,
TourneyPageKey,
} from "./ContentStruct";

export const QUICKSTART: Partial<Record<QuickStartPageKey, string>> = {};

export const RESOURCES: Partial<Record<ResourcesPageKey, string>> = {};

export const DEBUGGINGTIPS: Partial<Record<DebuggingTipsPageKey, string>> = {};

export const COMMONISSUES: Partial<Record<CommonIssuesPageKey, string>> = {};

export const TOURNAMENTS: Partial<Record<TourneyPageKey, string>> = {
"Tournament Schedule": `# Battlecode 2022 Tournament Schedule
Battlecode 2022 will have several tournaments throughout the month! We stream and commentate all tournaments online. The deadline to submit code for each non-final tournament is usually 7 pm EST the day before the tournament.
`,
Prizes: `# Prizes
Prize amounts are approximate and will be finalized soon!
* __Final Tournament prizes:__ Prizes will range from $5000 for 1st place to $600 for 16th place.
* __Sprint prizes:__ Winner of each tournament will receive $250.
* __Newbie, High School prizes:__ Prizes will range from $700 to $200 for the top 4 teams.
* __[Best Devlog Series Prize](https://www.regression.gg/battlecode):__ $800 prize given by our Gold Sponsor,
[Regression Games](https://www.regression.gg/). First place will receive $800, and all winners will receive a chance to interview for
internships.
* We want to see what you are building during the Battlecode season! Share your Battlecode development
experience on your favorite social media platform over the course of the tournament. Post your
learnings, fun moments, hardships, and progress! You must tag Battlecode and Regression Games in
the post to be eligible for this prize (see [regression.gg/battlecode](https://regression.gg/battlecode) for more info, ideas, and social media handles).
* __Best Strategy Report Prize:__ $800 prize given by our Gold Sponsor, [Argus Labs](https://argus.gg/).
First place will receive $800, and all winners will receive a chance to interview for internships and a swag box.
* Submit a strategy report detailing the strategies you used to develop your bot! We'd love to see how you handled
communication, resource allocation, battling, and more. Tell us what unique strategies your team came up with!
A link for submitting reports will be provided later.
If you are an international participant, please note that [US export regulations](https://www.bis.doc.gov/index.php/policy-guidance/country-guidance/sanctioned-destinations)
may restrict our ability to award prizes to students from certain countries.
`,
"Tournament Format": `# Tournament Format
Each match within a tournament will consist of at least 3 games, each on a different map, and the team that wins the most games will advance.
Scrimmage rankings will be used to determine seeds for all tournaments. Ties will be broken by Sprint tournament rankings.
Tournaments will be in a double elimination format, with the exception of both Sprint Tournaments, which are single elimination. The Final Tournament will start with a blank slate (any losses from the Qualifying Tournament are reset).
Even if you miss earlier tournaments, you can participate in later tournaments (except the Final Tournament). This includes the Qualifying Tournament — you can participate even if you miss every other tournament (your seed will be determined by your scrimmage rank).
`,
"Eligibility Rules": `# Eligibility Rules
Anyone can write a bot, create a team, and participate in scrimmage matches/rankings. The Sprint Tournaments are
open to everyone, but the other tournaments have stricter eligibility rules.
Your team must meet __all three conditions__ by a tournament's submission deadline to be eligible for it:
1. Have uploaded a bot
1. Have correctly indicated your eligibility on your Team Profile page
1. Have all members upload a resume, at your personal profile page (This condition does not apply to the Sprint Tournaments).
Additionally, tournament specific eligibility is listed below:
* __Sprint Tournament:__ All teams are eligible.
* __US Qualifier:__ Teams must __consist entirely of US college students__ studying full-time, or in a transition phase.
* __International Qualifier:__ Teams must __consist entirely of college students__ studying full-time, or in a transition phase,
where at least one team member is not a US student.
* __MIT Newbie Tournament:__ Teams must __consist entirely of MIT students__ who have never competed in Battlecode before.
* __High School Tournament:__ Teams must __consist entirely of high school students__.
* __Final Tournament:__ Teams must have qualified via the US or International Qualifier. The final match of the Newbie and High School tournaments will also be played at the final tournament.
Contact us on [Discord](https://discord.gg/N86mxkH) or at [[email protected]](mailto:[email protected]) if you are unsure of your eligibility.
`,
};
94 changes: 16 additions & 78 deletions frontend2/src/content/bc23.ts
Original file line number Diff line number Diff line change
@@ -1,87 +1,25 @@
export const BC23_QUICKSTART = `# Quick Start
import type {
CommonIssuesPageKey,
DebuggingTipsPageKey,
QuickStartPageKey,
ResourcesPageKey,
TourneyPageKey,
} from "./ContentStruct";

This is the Battlecode 2023 contest website, which will be your main hub for all Battlecode-related things for the duration of the contest. For a general overview of what Battlecode is, visit [our landing page](https://battlecode.org/).
export const QUICKSTART: Partial<Record<QuickStartPageKey, string>> = {};

## Create an account and team
export const RESOURCES: Partial<Record<ResourcesPageKey, string>> = {};

To participate in Battlecode, you need an account and a team. Each team can consist of 1 to 4 people.
export const DEBUGGINGTIPS: Partial<Record<DebuggingTipsPageKey, string>> = {};

[Create an account](/register) on this website, and then go to the [team section](/bc23/team) to either create or join a team.
export const COMMONISSUES: Partial<Record<CommonIssuesPageKey, string>> = {};

## Installation
### Step 1: Install Java
You'll need a Java Development Kit (JDK) version 8. Unfortunately, higher versions will not work. [Download it here](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). You may need to create an Oracle account.
- Alternatively, you can install a JDK yourself using your favorite package manager. Make sure it's an Oracle JDK — we don't support anything else — and is compatible with Java 8.
If you're unsure how to install the JDK, you can find instructions for all operating systems [here](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html) (pay attention to \`PATH\` and \`CLASSPATH\`).
### Step 2: Download Battlecode
Next, you should download the [Battlecode 2023 scaffold](https://github.com/battlecode/battlecode23-scaffold). To get up and running quickly, you can click "Clone or download" and then "Download ZIP," and move on to the next step.
TODO: the rest of the page
`;

export const BC23_RESOURCES = `# Markdown syntax guide
# This is a Heading h1
## This is a Heading h2
###### This is a Heading h6
*This text will be italic*
_This will also be italic_
**This text will be bold**
__This will also be bold__
_You **can** combine them_
### Unordered List
* Item 1
* Item 2
* Item 2a
* Item 2b
### Ordered List
1. Item 1
1. Item 2
1. Item 3
1. Item 3a
1. Item 3b
![This is an alt text for an image.](/image/sample.png "This is a sample image.")
[This links to example.com](https://example.com).
\`\`\`
let message = 'Hello world';
alert(message);
\`\`\`
this is \`an inline code block\`
`;

type TourneyPageKey = "schedule" | "prizes" | "format" | "rules";

export enum TourneyPage {
SCHEDULE = "schedule",
PRIZES = "prizes",
FORMAT = "format",
RULES = "rules",
}

export const BC23_TOURNAMENTS: Record<TourneyPageKey, string> = {
schedule: `# Battlecode 2023 Tournament Schedule
export const TOURNAMENTS: Partial<Record<TourneyPageKey, string>> = {
"Tournament Schedule": `
Battlecode 2023 will have several tournaments throughout the month! We stream and commentate all tournaments online. The deadline to submit code for each non-final tournament is usually 7 pm EST the day before the tournament.
`,
prizes: `# Prizes
Prizes: `# Prizes
Prize amounts are approximate and will be finalized soon!
Expand All @@ -103,7 +41,7 @@ export const BC23_TOURNAMENTS: Record<TourneyPageKey, string> = {
If you are an international participant, please note that [US export regulations](https://www.bis.doc.gov/index.php/policy-guidance/country-guidance/sanctioned-destinations)
may restrict our ability to award prizes to students from certain countries.
`,
format: `# Tournament Format
"Tournament Format": `# Tournament Format
Each match within a tournament will consist of at least 3 games, each on a different map, and the team that wins the most games will advance.
Expand All @@ -113,7 +51,7 @@ export const BC23_TOURNAMENTS: Record<TourneyPageKey, string> = {
Even if you miss earlier tournaments, you can participate in later tournaments (except the Final Tournament). This includes the Qualifying Tournament — you can participate even if you miss every other tournament (your seed will be determined by your scrimmage rank).
`,
rules: `# Eligibility Rules
"Eligibility Rules": `# Eligibility Rules
Anyone can write a bot, create a team, and participate in scrimmage matches/rankings. The Sprint Tournaments are
open to everyone, but the other tournaments have stricter eligibility rules.
Expand Down
Loading

0 comments on commit ba855bb

Please sign in to comment.