Skip to content

Commit 1a0866b

Browse files
Refactor entire website into jinja based template (#14)
* Refactor entire website into jinja based template * copy CNAME to dist directory * Add GitHub Pages deployment workflow
1 parent 0eca043 commit 1a0866b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4718
-7370
lines changed

.github/workflows/deploy.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Setup Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.x'
19+
20+
- name: Install dependencies
21+
run: pip install -r requirements.txt
22+
23+
- name: Build site
24+
run: python build.py
25+
26+
- name: Deploy
27+
uses: JamesIves/github-pages-deploy-action@v4
28+
with:
29+
folder: dist
30+
branch: gh-pages
31+
clean: true

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
.DS_Store
22

3+
# Python
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
venv/
8+
9+
# Distribution / packaging
10+
dist/
11+
12+
# IDE files
13+
.vscode/
14+
.idea/
15+
*.swp
16+
*.swo
17+

Makefile

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

build.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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
51+
with open(ROOT / "data/leaderboards.json", "r") as f:
52+
leaderboards = json.load(f)
53+
54+
# render all pages
55+
for tpl_name, out_name in PAGES.items():
56+
tpl = env.get_template(tpl_name)
57+
html = tpl.render(
58+
title="SWE-bench",
59+
leaderboards=leaderboards["leaderboards"] if isinstance(leaderboards, dict) else leaderboards
60+
)
61+
(DIST / out_name).write_text(html)
62+
print(f"built {out_name}")
63+
64+
print("All pages generated successfully!")
65+
66+
67+
if __name__ == "__main__":
68+
main()

css/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SWE-bench CSS Architecture
2+
3+
This CSS architecture follows a simplified component-based approach with a focus on maintainability and reusability.
4+
5+
## Structure
6+
7+
```
8+
css/
9+
|
10+
|– core.css # Core styles (variables, fonts, typography, base)
11+
|– layout.css # Layout components (grid, containers, spacing)
12+
|– components.css # UI components (buttons, forms, tables, cards)
13+
|– pages.css # Page-specific styles
14+
|– utilities.css # Utility classes
15+
|– vendors/ # Third-party CSS
16+
| |– normalize.css # Normalize.css (reset)
17+
|
18+
|– dmsans/ # DM Sans font files
19+
|
20+
`– main.css # Primary CSS file that imports all modules
21+
```
22+
23+
## Usage
24+
25+
All styles are imported through the main.css file. Individual CSS files are modular and focus on a specific category of styles.
26+
27+
## Design Tokens
28+
29+
Global design tokens are defined in the core.css file, including:
30+
31+
- Colors
32+
- Typography
33+
- Spacing
34+
- Border radius
35+
- Shadows
36+
- Z-index
37+
- Animations/transitions
38+
39+
## Naming Conventions
40+
41+
- Component-based naming convention is used for component classes
42+
- Utility classes follow a consistent pattern:
43+
- `.d-` for display utilities
44+
- `.m-` and `.p-` for margin and padding
45+
- `.text-` for text utilities
46+
- `.bg-` for background colors
47+
- `.border-` for border utilities
48+
- `.position-` for positioning utilities
49+
50+
## Responsive Design
51+
52+
The layout is mobile-first with breakpoints:
53+
54+
- Small: up to 576px
55+
- Medium: 577px to 768px
56+
- Large: 769px to 992px
57+
- X-Large: 993px and up
58+
59+
## Advantages of This Architecture
60+
61+
1. **Simplified structure**: Reduces the number of files while maintaining separation of concerns
62+
2. **Easier maintenance**: Related styles are grouped together
63+
3. **Reduced file size**: Less duplication and overhead
64+
4. **Better organization**: Clear categorization of styles
65+
5. **Faster development**: Utility classes enable rapid prototyping

0 commit comments

Comments
 (0)