Skip to content

Commit 37dc1a6

Browse files
authored
Merge pull request #17 from BentoBoxWorld/feature/admin-interface-and-site-refresh
Admin interface, Blueprints catalog, and site visual refresh
2 parents b028ae8 + db19ffa commit 37dc1a6

49 files changed

Lines changed: 13921 additions & 1145 deletions

Some content is hidden

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

.gitignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ yarn-error.log
55
.idea
66
.env
77
env.json
8-
jarcache.sqlite
9-
downloads.sqlite
8+
*.sqlite
109
*.old*
1110
/.project
11+
12+
# macOS Finder metadata
13+
.DS_Store
14+
15+
# Runtime data (Auth DB, the auto-cloned weblink mirror, etc.)
16+
/data/
17+
18+
# Design hand-off bundles dropped at the repo root
19+
/design_handoff_*/
20+
/BentoBox Download Site*.zip

CLAUDE.md

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,30 @@ yarn site # Frontend-only dev rebuild + start server
3030

3131
**Frontend** (`src/web/`):
3232
- React 17 SPA with React Router, styled with Tailwind CSS + twin.macro/styled-components
33-
- Three pages: Presets (`/`), Custom builder (`/custom`), Third-party catalog (`/thirdparty`)
33+
- Pages: Presets (`/`), Custom builder (`/custom`), Third-party catalog (`/thirdparty`), Blueprints (`/blueprints`), Submit (`/submit`), Account (`/account`), Terms (`/terms`), Privacy (`/privacy`)
3434
- Components in `src/web/components/`, API calls via `src/web/ApiRequestManager.ts` using SWR
3535

3636
**Configuration files** (project root, read at runtime from `../` relative to `dist/`):
3737
- `config.json` — addon and preset definitions (the primary data source for all addons)
3838
- `thirdparty.json` — third-party addon registry
39-
- `env.json` (optional, from `env.example.json`) — GitHub token, Discord webhook, port settings
39+
- `env.json` (optional, from `env.example.json`) — GitHub token, Discord webhook, port settings, optional `weblink` block (url/path/branch) for the blueprint sync
4040
- `Installation-Guide.txt` — bundled in generated ZIP files
4141

42+
**Blueprint catalog** (`src/api/weblink.ts`, `src/api/blueprintCatalog.ts`):
43+
- `WeblinkSync` shallow-clones `BentoBoxWorld/weblink` into `data/weblink/` on startup and `git pull --ff-only`s it on the same 6-minute cron used for addon refresh. Default branch is `master`.
44+
- `buildCatalog()` scans `weblink/blueprints/<gameMode>/`, parses `.blueprint` files and bundle `.json` files (per BentoBox's `blueprint.schema.json` / `blueprint-bundle.schema.json`), and derives stats: dimensions, block-type counts, entity-type counts, air count, biome list, sinking flag.
45+
- The optional `blueprints/catalog.json` overlay in weblink supplies curation fields (`displayName`, `description`, `author`, `authorLink`, `tags`, `license`, `image`) plus tag colours and game-mode display names; overlay fields take precedence over what is in the `.blueprint` file.
46+
- Images live at `weblink/blueprints/images/<gameMode>/<name>.png` (recommended 800×450, with optional `<name>.thumb.png` at 400×225). The catalog auto-detects them at sync time when the overlay does not specify `image`. The Express handler at `src/index.ts` serves them under `/blueprints/images/...` with a path-traversal guard and PNG-only whitelist.
47+
- Endpoints: `GET /api/blueprints` (full catalog), `GET /api/blueprints/download?id=<gameMode>/<name>&type=blueprint|bundle` (single file), `GET /api/blueprints/zip?ids=[...]|gameMode=<gm>` (multi-select or whole-game-mode zip). IDs are validated against a strict regex and resolved paths are checked against the blueprints root before any read.
48+
49+
**Auth + submissions** (`src/api/auth.ts`, `src/api/submissions.ts`, `src/api/models/auth.ts`):
50+
- Discord OAuth (server-side authorization-code flow, `identify` scope only). Sessions stored in `data/Auth.sqlite` via Sequelize (`User`, `Session`, `Submission` tables). Session cookie is HttpOnly, `SameSite=Lax`, `Secure` in production, and carries an opaque server-generated session id. 30-day TTL, max 5 concurrent sessions per user, daily prune cron.
51+
- CSRF: per-session token returned by `GET /api/me`, required as `X-Csrf-Token` on every POST.
52+
- Rate limits: 30 OAuth callbacks/min/IP; 3 submissions/hour, 10/day per Discord user.
53+
- `POST /api/blueprints/submit` accepts a multipart upload (max 5 MB), JSON-parses, ajv-validates against `src/api/schemas/blueprint.schema.json` (vendored from `bentobox/`), runs `validateBlueprintSubmission` (rejects command-block materials and opaque `inventory` payloads), checks slug collision against the local clone, then opens a PR on `BentoBoxWorld/weblink` via Octokit using `env.weblink_github_token` — branch `submit/<discordId>/<slug>-<ts>` with two file commits (the `.blueprint` and the patched `catalog.json`).
54+
- Helmet config in `src/index.ts` is the canonical CSP — Discord OAuth navigation works without an explicit allowlist because helmet's CSP does not constrain top-level navigation.
55+
- `env.json` keys: `discord_client_id`, `discord_client_secret`, `discord_redirect_uri`, `weblink_github_token` (fine-grained PAT scoped to `BentoBoxWorld/weblink` with `contents: write` + `pull-requests: write`).
56+
4257
## Key Patterns
4358

4459
- All addon metadata is configuration-driven via `config.json`; adding an addon means editing that file
@@ -49,4 +64,93 @@ yarn site # Frontend-only dev rebuild + start server
4964

5065
## CI
5166

52-
GitHub Actions (`.github/workflows/build.yml`) runs on push/PR to `develop`: tests Node.js 12.x/14.x/16.x with `yarn && yarn add sqlite3 && yarn build`.
67+
GitHub Actions (`.github/workflows/build.yml`) runs on push/PR to `develop`: tests Node.js 20.x/22.x with `yarn && yarn add sqlite3 && yarn build`.
68+
69+
## Dependency Source Lookup
70+
71+
When you need to inspect source code for a dependency (e.g., BentoBox, addons):
72+
73+
1. **Check local Maven repo first**: `~/.m2/repository/` — sources jars are named `*-sources.jar`
74+
2. **Check the workspace**: Look for sibling directories or Git submodules that may contain the dependency as a local project (e.g., `../bentoBox`, `../addon-*`)
75+
3. **Check Maven local cache for already-extracted sources** before downloading anything
76+
4. Only download a jar or fetch from the internet if the above steps yield nothing useful
77+
78+
Prefer reading `.java` source files directly from a local Git clone over decompiling or extracting a jar.
79+
80+
In general, the latest version of BentoBox should be targeted.
81+
82+
## Project Layout
83+
84+
Related projects are checked out as siblings under `~/git/`:
85+
86+
**Core:**
87+
- `bentobox/` — core BentoBox framework
88+
89+
**Game modes:**
90+
- `addon-acidisland/` — AcidIsland game mode
91+
- `addon-bskyblock/` — BSkyBlock game mode
92+
- `Boxed/` — Boxed game mode (expandable box area)
93+
- `CaveBlock/` — CaveBlock game mode
94+
- `OneBlock/` — AOneBlock game mode
95+
- `SkyGrid/` — SkyGrid game mode
96+
- `RaftMode/` — Raft survival game mode
97+
- `StrangerRealms/` — StrangerRealms game mode
98+
- `Brix/` — plot game mode
99+
- `parkour/` — Parkour game mode
100+
- `poseidon/` — Poseidon game mode
101+
- `gg/` — gg game mode
102+
103+
**Addons:**
104+
- `addon-level/` — island level calculation
105+
- `addon-challenges/` — challenges system
106+
- `addon-welcomewarpsigns/` — warp signs
107+
- `addon-limits/` — block/entity limits
108+
- `addon-invSwitcher/` / `invSwitcher/` — inventory switcher
109+
- `addon-biomes/` / `Biomes/` — biomes management
110+
- `Bank/` — island bank
111+
- `Border/` — world border for islands
112+
- `Chat/` — island chat
113+
- `CheckMeOut/` — island submission/voting
114+
- `ControlPanel/` — game mode control panel
115+
- `Converter/` — ASkyBlock to BSkyBlock converter
116+
- `DimensionalTrees/` — dimension-specific trees
117+
- `discordwebhook/` — Discord integration
118+
- `Downloads/` — BentoBox downloads site
119+
- `DragonFights/` — per-island ender dragon fights
120+
- `ExtraMobs/` — additional mob spawning rules
121+
- `FarmersDance/` — twerking crop growth
122+
- `GravityFlux/` — gravity addon
123+
- `Greenhouses-addon/` — greenhouse biomes
124+
- `IslandFly/` — island flight permission
125+
- `IslandRankup/` — island rankup system
126+
- `Likes/` — island likes/dislikes
127+
- `Limits/` — block/entity limits
128+
- `lost-sheep/` — lost sheep adventure
129+
- `MagicCobblestoneGenerator/` — custom cobblestone generator
130+
- `PortalStart/` — portal-based island start
131+
- `pp/` — pp addon
132+
- `Regionerator/` — region management
133+
- `Residence/` — residence addon
134+
- `TopBlock/` — top ten for OneBlock
135+
- `TwerkingForTrees/` — twerking tree growth
136+
- `Upgrades/` — island upgrades (Vault)
137+
- `Visit/` — island visiting
138+
- `weblink/` — data repo (blueprints, challenges, MCG configs, addon downloads matrix); the Downloads server clones a copy of this for the Blueprints tab
139+
- `CrowdBound/` — CrowdBound addon
140+
141+
**Data packs:**
142+
- `BoxedDataPack/` — advancement datapack for Boxed
143+
144+
**Documentation & tools:**
145+
- `docs/` — main documentation site
146+
- `docs-chinese/` — Chinese documentation
147+
- `docs-french/` — French documentation
148+
- `BentoBoxWorld.github.io/` — GitHub Pages site
149+
- `website/` — website
150+
- `translation-tool/` — translation tool
151+
152+
Check these for source before any network fetch.
153+
154+
## Key Dependencies (source locations)
155+
156+
- `world.bentobox:bentobox``~/git/bentobox/src/`

env.example.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,21 @@
22
"github_token": "ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
33
"github_downloads": 2,
44
"discord_error_webhook_url": "/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxx",
5-
"port": 8080
5+
"port": 8080,
6+
"weblink": {
7+
"url": "https://github.com/BentoBoxWorld/weblink.git",
8+
"path": "./../data/weblink",
9+
"branch": "master"
10+
},
11+
"discord_client_id": "0000000000000000000",
12+
"discord_client_secret": "REPLACE_ME",
13+
"discord_redirect_uri": "https://download.bentobox.world/api/auth/discord/callback",
14+
"weblink_github_token": "github_pat_REPLACE_ME",
15+
"admin_discord_ids": ["REPLACE_WITH_DISCORD_USER_ID"],
16+
"admin_github": {
17+
"owner": "BentoBoxWorld",
18+
"repo": "Downloads",
19+
"branch": "develop",
20+
"token": "github_pat_REPLACE_ME"
21+
}
622
}

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"build": "tsc --project tsconfig.compile.json && webpack --config webpack.config.cjs --env env=production",
1010
"start": "cd dist && node index.js",
1111
"dev": "yarn clean && tsc --project tsconfig.compile.json && webpack --config webpack.config.cjs --env env=development && yarn start",
12-
"site": "webpack --config webpack.config.cjs --env env=development && yarn start"
12+
"site": "webpack --config webpack.config.cjs --env env=development && yarn start",
13+
"prime-cache": "cd dist && node scripts/prime-cache.js"
1314
},
1415
"keywords": [],
1516
"author": "Fredthedoggy",
@@ -25,20 +26,25 @@
2526
"@octokit/plugin-throttling": "^3.5.1",
2627
"@tailwindcss/custom-forms": "^0.2.1",
2728
"@types/archiver": "^5.1.1",
28-
"@types/express": "^4.17.13",
29+
"@types/cookie-parser": "^1.4.10",
30+
"@types/express": "^4.17.21",
2931
"@types/jenkins": "^0.23.2",
3032
"@types/mime-types": "^2.1.0",
3133
"@types/node-cron": "^2.0.4",
3234
"@types/react-router-dom": "^5.1.8",
3335
"@types/styled-components": "^5.1.11",
36+
"ajv": "^8.20.0",
37+
"ajv-formats": "^3.0.1",
3438
"archiver": "^5.3.0",
3539
"axios": "^0.21.1",
3640
"clean-webpack-plugin": "^4.0.0-alpha.0",
41+
"cookie-parser": "^1.4.7",
3742
"copy-webpack-plugin": "^9.0.1",
3843
"express": "^4.17.1",
3944
"helmet": "^4.6.0",
4045
"jenkins": "^0.28.1",
4146
"mime-types": "^2.1.31",
47+
"multer": "^2.1.1",
4248
"node-cron": "^3.0.0",
4349
"octokit": "^1.1.0",
4450
"react": "^17.0.2",
@@ -50,7 +56,7 @@
5056
"remark-breaks": "^2.0.2",
5157
"sequelize": "^6.6.5",
5258
"source-map-loader": "^3.0.0",
53-
"sqlite3": "^5.0.2",
59+
"sqlite3": "^6.0.1",
5460
"styled-components": "^5.3.0",
5561
"swr": "^0.5.6",
5662
"tailwind": "^4.0.0",
@@ -64,6 +70,7 @@
6470
"@babel/preset-react": "^7.13.13",
6571
"@babel/preset-typescript": "^7.13.0",
6672
"@babel/runtime": "^7.13.16",
73+
"@types/multer": "^2.1.0",
6774
"@types/react": "^17.0.15",
6875
"@types/react-dom": "^17.0.3",
6976
"@typescript-eslint/eslint-plugin": "^4.28.5",

0 commit comments

Comments
 (0)