Skip to content

Move code platform definition to config#97

Merged
egrace479 merged 7 commits into
mainfrom
feat/code-platform-generalization
May 14, 2026
Merged

Move code platform definition to config#97
egrace479 merged 7 commits into
mainfrom
feat/code-platform-generalization

Conversation

@egrace479
Copy link
Copy Markdown
Member

Add functions to define API URLs and ribbon values based on config-defined platform.

This is a first step toward #96. The support for other platforms is being added because this is a re-usable template. Once the configs are set, they won't be changed for that implementation. As such, it's easiest for downstream users if we keep required changes in a single file. We don't want to introduce more if statements than necessary because there will be a fixed implementation each time it's used.

Add functions to define API URLs and ribbon values based on config-defined platform
@egrace479 egrace479 requested a review from Copilot May 13, 2026 18:59
@egrace479 egrace479 added enhancement New feature or request structure Refactoring or architecture, general code organization javascript Pull requests that update javascript code labels May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a PLATFORM configuration key (currently only github accepted) and centralizes platform-specific API URLs and ribbon display data into two new modules (src/defineApiUrls.js, src/defineRibbonVals.js). The hard-coded GitHub URLs in main.js, scripts/fetch-releases.js, and scripts/export-tags.js are routed through these helpers, and the index.html ribbon is parameterized to swap icon/name/link based on the selected platform. This is foundational work toward Codeberg/GitLab support (issue #96), with those branches stubbed out as commented-out entries.

Changes:

  • Introduce PLATFORM config key with validation, README docs, and config.yaml default.
  • Add getPlatformApiUrls and getPlatformDisplay helpers and wire them into main.js, both scripts, and the ribbon markup.
  • Generalize GitHub-specific UI text, IDs, and comments to platform-agnostic equivalents.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/defineApiUrls.js New helper returning org/repo URLs per platform
src/defineRibbonVals.js New helper returning ribbon SVG path / name / color per platform
src/validateConfig.js Validate presence and allowlist of PLATFORM
tests/validateConfig.test.js New tests for missing/unrecognized PLATFORM
main.js Use platform helpers; rename GitHub ribbon → repo ribbon; assign module-scope URLs
scripts/fetch-releases.js Replace hard-coded URLs with getPlatformApiUrls
scripts/export-tags.js Same, plus log messages parameterized (incorrect import path)
index.html Generalize ribbon element IDs and inject icon/name at runtime
public/config.yaml Add PLATFORM: github with explanatory comments
README.md Document the new PLATFORM config key
Comments suppressed due to low confidence (1)

main.js:718

  • getPlatformApiUrls(PLATFORM, ORGANIZATION_NAME) is invoked twice in successive lines, each time rebuilding the platform-URLs object. Call it once and destructure (e.g., const { org, repo } = getPlatformApiUrls(...)) for clarity and a small efficiency gain — also matches the destructuring pattern used in scripts/fetch-releases.js and scripts/export-tags.js.
    ORG_API_URL           = getPlatformApiUrls(PLATFORM, ORGANIZATION_NAME).org;
    REPO_API_URL          = getPlatformApiUrls(PLATFORM, ORGANIZATION_NAME).repo;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/export-tags.js Outdated
Comment thread src/defineApiUrls.js Outdated
Comment thread main.js Outdated
Comment thread main.js Outdated
Comment thread main.js
// Paginate through all public repos (Platform determines API max returns per page)
let allRepos = [];
let nextUrl = `https://api.github.com/orgs/${ORGANIZATION_NAME}/repos?type=public&per_page=100`;
let nextUrl = `${ORG_API_URL}`;
Comment thread main.js Outdated
Comment thread main.js
Comment thread index.html
Comment thread src/validateConfig.js
@egrace479 egrace479 requested a review from EmersonFras May 13, 2026 19:42
@egrace479
Copy link
Copy Markdown
Member Author

@EmersonFras, I removed the redundant tests and reformatted the defineRibbonUrl function/file to match the API URL one. Could you quickly check it once more?

@EmersonFras
Copy link
Copy Markdown
Contributor

@EmersonFras, I removed the redundant tests and reformatted the defineRibbonUrl function/file to match the API URL one. Could you quickly check it once more?

Tested it out everything LGTM!

@egrace479 egrace479 merged commit 9f0afdd into main May 14, 2026
1 check passed
@egrace479 egrace479 deleted the feat/code-platform-generalization branch May 14, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request javascript Pull requests that update javascript code structure Refactoring or architecture, general code organization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants