Skip to content

Commit 7226289

Browse files
committed
init
0 parents  commit 7226289

13 files changed

Lines changed: 411 additions & 0 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v4
19+
with:
20+
enable-cache: true
21+
cache-dependency-glob: "pyproject.toml"
22+
23+
- name: Install dependencies
24+
run: uv sync
25+
26+
- name: Build site
27+
run: uv run python build.py
28+
29+
- name: Deploy
30+
uses: JamesIves/github-pages-deploy-action@v4
31+
with:
32+
folder: dist
33+
branch: gh-pages
34+
clean: true

CNAME

Whitespace-only changes.

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Simple Makefile for CodeClash website
2+
3+
.PHONY: help install build serve clean
4+
5+
# Default target: show help
6+
default: help
7+
8+
help:
9+
@echo "Available commands:"
10+
@echo " make install - Install Python dependencies using uv"
11+
@echo " make build - Generate all HTML pages from templates"
12+
@echo " make serve - Start a local development server (http://localhost:8000)"
13+
@echo " make clean - Remove generated HTML files"
14+
15+
install:
16+
@echo "Installing dependencies with uv..."
17+
uv sync
18+
19+
build:
20+
@echo "Building HTML pages..."
21+
uv run python build.py
22+
@echo "Build complete."
23+
24+
serve:
25+
make build
26+
@echo "Starting local server at http://localhost:8000 ... Press Ctrl+C to stop."
27+
cd dist && uv run python -m http.server 8000
28+
29+
clean:
30+
@echo "Cleaning generated files..."
31+
rm -rf dist
32+
@echo "Removing virtual environment..."
33+
rm -rf .venv
34+
@echo "Clean complete."

build.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python3
2+
import json
3+
import pathlib
4+
import shutil
5+
from jinja2 import Environment, FileSystemLoader, select_autoescape
6+
7+
8+
ROOT = pathlib.Path(__file__).parent
9+
TEMPLATES = ROOT / "templates"
10+
DIST = ROOT / "dist"
11+
12+
def get_pages():
13+
pages = {}
14+
pages_dir = TEMPLATES / "pages"
15+
for file in pages_dir.glob("*.html"):
16+
template_path = f"pages/{file.name}"
17+
output_file = file.name
18+
pages[template_path] = output_file
19+
return pages
20+
21+
PAGES = get_pages()
22+
23+
24+
def main() -> None:
25+
# set up Jinja environment
26+
env = Environment(
27+
loader=FileSystemLoader(TEMPLATES),
28+
autoescape=select_autoescape(["html"])
29+
)
30+
31+
# start fresh each run
32+
if DIST.exists():
33+
shutil.rmtree(DIST)
34+
DIST.mkdir()
35+
36+
# copy static assets
37+
if (ROOT / "css").exists():
38+
shutil.copytree(ROOT / "css", DIST / "css")
39+
if (ROOT / "img").exists():
40+
shutil.copytree(ROOT / "img", DIST / "img")
41+
if (ROOT / "js").exists():
42+
shutil.copytree(ROOT / "js", DIST / "js")
43+
if (ROOT / "favicon.ico").exists():
44+
shutil.copy(ROOT / "favicon.ico", DIST / "favicon.ico")
45+
if (ROOT / "CNAME").exists():
46+
shutil.copy(ROOT / "CNAME", DIST / "CNAME")
47+
else:
48+
raise FileNotFoundError("CNAME file not found. Please create a CNAME file in the root directory.")
49+
50+
# load data as needed
51+
52+
# render all pages
53+
for tpl_name, out_name in PAGES.items():
54+
tpl = env.get_template(tpl_name)
55+
html = tpl.render(
56+
title="CodeClash",
57+
)
58+
(DIST / out_name).write_text(html)
59+
print(f"built {out_name}")
60+
61+
print("All pages generated successfully!")
62+
63+
if __name__ == "__main__":
64+
main()

css/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.main-container {
2+
width: 80%;
3+
margin: 0 auto;
4+
}

dist/CNAME

Whitespace-only changes.

dist/css/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.main-container {
2+
width: 80%;
3+
margin: 0 auto;
4+
}

dist/index.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>CodeClash</title>
7+
<link rel="stylesheet" href="css/main.css">
8+
<script
9+
async
10+
src="https://www.googletagmanager.com/gtag/js?id=G-H9XFCMDPNS"
11+
></script>
12+
<script>
13+
window.dataLayer = window.dataLayer || [];
14+
function gtag() {
15+
dataLayer.push(arguments);
16+
}
17+
gtag("js", new Date());
18+
19+
gtag("config", "G-H9XFCMDPNS");
20+
</script>
21+
22+
</head>
23+
<body>
24+
25+
26+
<div class="main-container">
27+
28+
Hi
29+
30+
</div>
31+
</body>
32+
</html>

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[project]
2+
name = "codeclash-website"
3+
readme = "README.md"
4+
version = "0"
5+
license = { file = "LICENSE" }
6+
requires-python = ">=3.8"
7+
dependencies = [
8+
"jinja2>=3.0.0",
9+
]

templates/_topnav.html

Whitespace-only changes.

0 commit comments

Comments
 (0)