From e81bb0494621fac69d31b10df0d40d02ae178628 Mon Sep 17 00:00:00 2001 From: Kris Date: Mon, 27 Jan 2025 10:04:22 -0500 Subject: [PATCH] UX: make leaderboard ID configurable (#48) --- .../discourse/components/blocks/top-contributors.gjs | 8 ++++++-- locales/en.yml | 2 ++ settings.yml | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/javascripts/discourse/components/blocks/top-contributors.gjs b/javascripts/discourse/components/blocks/top-contributors.gjs index 2ee579e..56cfe33 100644 --- a/javascripts/discourse/components/blocks/top-contributors.gjs +++ b/javascripts/discourse/components/blocks/top-contributors.gjs @@ -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( @@ -126,7 +128,9 @@ export default class TopContributors extends Component {
- + {{i18n "js.show_more"}}
diff --git a/locales/en.yml b/locales/en.yml index a7d8445..6a4537f 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -1,6 +1,8 @@ en: theme_metadata: description: "" + settings: + leaderboard_id: "Leaderboard to display when the Discourse Gamification plugin is installed. The ID can be found in the leaderboard's URL." user: view_your_profile: "View your profile" post: diff --git a/settings.yml b/settings.yml index 645837e..07fc356 100644 --- a/settings.yml +++ b/settings.yml @@ -3,6 +3,10 @@ topic_list_show_usernames: type: bool required: true +leaderboard_id: + default: 7 + type: integer + blocks: default: [