Skip to content

Commit

Permalink
UX: make leaderboard ID configurable (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomerobot authored Jan 27, 2025
1 parent f36a95a commit e81bb04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions javascripts/discourse/components/blocks/top-contributors.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export default class TopContributors extends Component {

async fetchTopContributors() {
try {
const data = await ajax(`/leaderboard/7.json?period=${this.period}`);
const data = await ajax(
`/leaderboard/${settings.leaderboard_id}.json?period=${this.period}`
);
this.topContributors = data.users.slice(0, this.count);
} catch {
const data = await ajax(
Expand Down Expand Up @@ -126,7 +128,9 @@ export default class TopContributors extends Component {
</ol>

<div class="block-chart__expand">
<a href="/leaderboard/7&period={{this.period}}">
<a
href="/leaderboard/{{settings.leaderboard_id}}&period={{this.period}}"
>
{{i18n "js.show_more"}}
</a>
</div>
Expand Down
2 changes: 2 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
en:
theme_metadata:
description: ""
settings:
leaderboard_id: "Leaderboard to display when the <a href='https://meta.discourse.org/t/discourse-gamification/225916'>Discourse Gamification</a> plugin is installed. The ID can be found in the leaderboard's URL."
user:
view_your_profile: "View your profile"
post:
Expand Down
4 changes: 4 additions & 0 deletions settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ topic_list_show_usernames:
type: bool
required: true

leaderboard_id:
default: 7
type: integer

blocks:
default:
[
Expand Down

0 comments on commit e81bb04

Please sign in to comment.