GitHub Badge Plugin
A small first-party plugin that renders a live star-count badge for a GitHub repository, wherever you drop a data-github-repo attribute. This is the plugin powering the star badge on this documentation site.
π‘ Site-only plugin.
onigiri-plugin-github.js ships with this documentation site's own source, under static/js/plugins/ - it isn't part of the core framework repository. It's registered through the same Onigiri.use() mechanism as any other plugin.
Quick Start
1. Include Core and the Plugin
<script src="https://cdn.jsdelivr.net/gh/OnigiriJS/onigirijs@v1.0.0/src/framework/core/onigiri-core.js"></script>
<script src="/static/js/plugins/onigiri-plugin-github.js"></script>
The plugin registers and initializes itself immediately via Onigiri.use() - there's no separate .init() call.
2. Mark Up a Badge
<span data-github-repo="OnigiriJS/onigirijs"></span>
β
That's it! On page load (and after PJAX navigation, if you re-run the init logic), every element with
data-github-repo="owner/repo" is fetched from the GitHub API and replaced with a star-count badge.
How It Works
- Reads the
owner/repovalue fromdata-github-repo - Calls the public GitHub REST API (
GET https://api.github.com/repos/<owner>/<repo>) - unauthenticated, so it's subject to GitHub's public rate limit - Caches the response via Onigiri.storage (when loaded) for 5 minutes by default, to stay well under that rate limit
- Renders a small badge linking to the repo's stargazers page
- Re-colors the badge automatically on
onigiri:mode:changeif Onigiri.mode is loaded - falls back to a light-theme color scheme if it isn't
Configuration
Pass options through Onigiri.use() if you're registering the plugin yourself rather than relying on its auto-init:
| Option | Type | Default | Description |
|---|---|---|---|
apiBase | String | 'https://api.github.com/repos' | Base URL for the GitHub API |
cache | Boolean | true | Cache API responses via Onigiri.storage |
cacheTTL | Number | 300000 (5 minutes) | How long a cached response is considered fresh, in ms |
Dependencies
| Module | Required? | Effect if missing |
|---|---|---|
| onigiri-core.js | Required | Plugin throws on load |
| onigiri-storage.js | Optional | No caching - every badge re-fetches from the GitHub API on each page load |
| onigiri-mode.js | Optional | Badge always renders in its light-theme colors |
Security Notes
- The badge's link URL is validated as a genuine
https://github.com/...URL before being written into the page, rather than trusted as-is from the (possibly stale or, in principle, tampered-with) storage cache. - All external links open with
rel="noopener noreferrer".
β Development Roadmap
Track the progress of OnigiriJS modules. Tasks are marked complete by the development team.
OnigiriJS Module Roadmap
Implementation progress of planned modules
6 / 21 completed (29%)
onigiri-state
Shared global & scoped state management
onigiri-directives
Declarative DOM bindings (o-show, o-model, etc.)
onigiri-resource
REST-style data models over AJAX
onigiri-observe
Intersection & Mutation observer helpers
onigiri-humhub-ui
Standard HumHub UI abstractions (modal, notify, confirm)
onigiri-lifecycle
Component lifecycle hooks
onigiri-guard
Debounce, throttle, single-run guards
onigiri-scroll
Scroll save/restore & helpers (PJAX-friendly)
onigiri-permission
Client-side permission awareness
onigiri-portal
DOM teleport / overlay mounting
onigiri-router
Micro router (non-SPA, PJAX-first)
onigiri-sanitize
HTML & input sanitization
onigiri-shortcut
Keyboard shortcut manager
onigiri-queue
Sequential async task runner
onigiri-gesture
Touch & swipe helpers
onigiri-devtools
Debugging & inspection helpers
onigiri-plugin
Plugin registration system
onigiri-time
Relative time & timezone utilities
onigiri-emojis
Emoji Picker and Manager
onigiri-tasks
Task Management
onigiri-polls
Polls creation and management
Note: Task completion is managed by the OnigiriJS development team.