Ok, I just pushed an update that should fix the icons that weren’t working. I specifically checked it against all three of those icons and they work now. I also made the badge names case-insensitive while I was digging into the code.
Locale support will be #1 priority next time I get a chance to look at this.
This was very confusing to me, because it implies it is searching the list of site badges and not finding it. Tried a hard refresh to get it to find my new badges, etc. Glad it works, but maybe the UI can be changed to make it just a plain text box, rather than doing that non-functional search? I think that would make it less confusing to use.
Is it normal to get a “These local changes will be erased by the update. Are you sure you want to continue?” message when updating a theme component? I’m 99.9% sure I haven’t made any changes, and the git commit info looks like it is stuff related to the update, not to local changes:
diff --git a/discourse-post-badges/about.json b/discourse-post-badges/about.json
new file mode 100644
index 0000000..eb86c4b
--- /dev/null
+++ b/discourse-post-badges/about.json
@@ -0,0 +1,15 @@
+{
+ "name": "Post Badges",
+ "component": true,
+ "license_url": "https://github.com/tshenry/discourse-post-badges/blob/master/LICENSE",
+ "about_url": "https://meta.discourse.org/t/post-badges-component/114722",
+ "authors": null,
+ "theme_version": null,
+ "minimum_discourse_version": null,
+ "maximum_discourse_version": null,
+ "assets": {
+ },
+ "color_schemes": {
+ },
+ "learn_more": "https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966"
+}
\ No newline at end of file
diff --git a/common/common.scss b/discourse-post-badges/common/common.scss
similarity index 100%
rename from common/common.scss
rename to discourse-post-badges/common/common.scss
diff --git a/common/head_tag.html b/discourse-post-badges/common/head_tag.html
similarity index 100%
rename from common/head_tag.html
rename to discourse-post-badges/common/head_tag.html
diff --git a/discourse-post-badges/settings.yml b/discourse-post-badges/settings.yml
new file mode 100644
index 0000000..7e7e250
--- /dev/null
+++ b/discourse-post-badges/settings.yml
@@ -0,0 +1,21 @@
+badges:
+ type: list
+ default: ""
+ description:
+ en: 'Use the name of the badge as it appears on the
+ <a href="/admin/badges">list of badges</a>.
+ Post badges will appear in the order they are
+ added to this setting.'
+badge_link_destination:
+ type: enum
+ default: "user's badge page"
+ choices:
+ - "badge overview page"
+ description:
+ en: "Where a user will be taken when they click on a post badge."
+only_show_highest_trust_level:
+ type: bool
+ default: false
+ description:
+ en: "When including trust level badges (Basic, Member, Regular, Leader),
+ only show the highest trust level a user has earned."
Edited to add: I ran the update and it works fine. So…
The theme setting UI is common to core Discourse, so I can’t do anything to improve that setting in the component itself. It’s definitely something I’d like to see become a little more intuitive, or perhaps even have the ability to dynamically populate a searchable list at some point.
I realise this code will be lost when the component is updated, so I wonder if there’s a better way to do this? Can I override the buildBadge function somehow, for example?
Background information: we only want to show this icon for users who actually HAVE a portfolio, meaning they have created at least one topic in our Artwork category. This is easily done using a badge query, and since we’re already using the Post Badges component on our site this seemed a reasonable approach.
@bartv, I’d definitely like to do an improvement/refactor pass on this component in the not too distant future. I’ll see what I can do about restructuring things in a way that will allow you to handle overrides in a separate theme component. I’m not sure when I’ll get around to looking at this, but I’ll be sure to update this topic when there’s news.
Not at this point, but I’ll keep it in mind next time I’m working on the component.
Correct, see:
When I work on updating this component, I’ll see if I can come up with a more graceful solution for this.