[PR #2170] [MERGED] Site: downloads and 1-5 star ratings on /mods #4069

Closed
opened 2026-11-03 04:14:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2170
Author: @ludovic111
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: feat/mods-site-stats


📝 Commits (1)

  • f49d5d9 Site: downloads and 1-5 star ratings on /mods

📊 Changes

6 files changed (+229 additions, -18 deletions)

View changed files

📝 docs/mods.md (+4 -0)
📝 website/build.mjs (+3 -2)
📝 website/src/mods-page.js (+89 -9)
📝 website/src/mods.js (+66 -6)
📝 website/src/mods.test.mjs (+48 -1)
📝 website/src/style.css (+19 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What and why

Ludovic asked for a download count on each mod and a 1-5 star rating, on playhorizon.dev/mods and in the launcher. This PR does the website part.

  • List (/mods). Each card shows its rating, as stars plus the mean and count, and its downloads (e.g. "12.3k downloads"). The list is ordered by downloads by default. A new Order menu also sorts by rating or by name (?sort=rating|name works too).
  • Project page (/mods/<id>). The same line, then the rating control:
    • signed in: five stars, with the account's own rating lit; pressing one sets or changes the rating;
    • signed out: "Sign in with GitHub to rate", which returns to the same page after sign-in;
    • the project's owners see a note instead, because they can't rate their own project.
  • Where the data comes from. Downloads come from the index's downloads field (ludovic111/horizon-mods#7). Ratings come from GET /api/mods/ratings (#2167). A rating is POSTed with the session's CSRF token, the same way the submit form does it. Until the service answers, the pages show downloads only. Nobody can see who rated.

Depends on #2167 for ratings. Without it, the pages behave as before plus the download counts.

Tests

  • node --test src/ scripts/: 44 pass. New tests cover: count formatting; an invalid downloads value treated as 0; reading ratings, including malformed answers and __proto__; star rendering; the three sort orders; the rate control signed out, signed in and for an owner; no stars before the ratings arrive.
  • I built the site locally with a counted index (the live index plus the downloads that horizon-mods#7 writes), served it with a mock /api/mods/*, and took screenshots: the list in dark and light, the signed-in page (dark) and the signed-out page (light). They are on the Mac mini in ~/scratch/mod-stats-1/site-*.png.

Needs Ludovic

Nothing.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2170 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/mods-site-stats` --- ### 📝 Commits (1) - [`f49d5d9`](https://github.com/horizon-rust/horizon/commit/f49d5d91e6ca96ca70804fc0e8778d20b32d5fb5) Site: downloads and 1-5 star ratings on /mods ### 📊 Changes **6 files changed** (+229 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `docs/mods.md` (+4 -0) 📝 `website/build.mjs` (+3 -2) 📝 `website/src/mods-page.js` (+89 -9) 📝 `website/src/mods.js` (+66 -6) 📝 `website/src/mods.test.mjs` (+48 -1) 📝 `website/src/style.css` (+19 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why Ludovic asked for a download count on each mod and a 1-5 star rating, on playhorizon.dev/mods and in the launcher. This PR does the website part. - **List (`/mods`).** Each card shows its rating, as stars plus the mean and count, and its downloads (e.g. "12.3k downloads"). The list is ordered by downloads by default. A new Order menu also sorts by rating or by name (`?sort=rating|name` works too). - **Project page (`/mods/<id>`).** The same line, then the rating control: - signed in: five stars, with the account's own rating lit; pressing one sets or changes the rating; - signed out: "Sign in with GitHub to rate", which returns to the same page after sign-in; - the project's owners see a note instead, because they can't rate their own project. - **Where the data comes from.** Downloads come from the index's `downloads` field (ludovic111/horizon-mods#7). Ratings come from `GET /api/mods/ratings` (#2167). A rating is POSTed with the session's CSRF token, the same way the submit form does it. Until the service answers, the pages show downloads only. Nobody can see who rated. Depends on #2167 for ratings. Without it, the pages behave as before plus the download counts. ## Tests - `node --test src/ scripts/`: 44 pass. New tests cover: count formatting; an invalid `downloads` value treated as 0; reading ratings, including malformed answers and `__proto__`; star rendering; the three sort orders; the rate control signed out, signed in and for an owner; no stars before the ratings arrive. - I built the site locally with a counted index (the live index plus the `downloads` that horizon-mods#7 writes), served it with a mock `/api/mods/*`, and took screenshots: the list in dark and light, the signed-in page (dark) and the signed-out page (light). They are on the Mac mini in `~/scratch/mod-stats-1/site-*.png`. ## Needs Ludovic Nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:27 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4069
No description provided.