Create a settings category for Plugins


(eriko) #1

Since the settings have move to the new and categorizes settings yml format I would like to suggest making a category to be used for plugins. I am writing a CAS plugin and working on a SAML based one. In each case they need to store SiteSettings so that they can work in multisite. I would like to avoid storing them in a pile in the uncategorized category.

Any thoughts?


(Neil Lalonde) #2

It’s even possible for each plugin to add its own category to the site settings. I think that would be fine.

Also… you had a pull request to add that support, but closed it! Wahappen?

I can add those changes myself if you don’t want to do it yourself.


(eriko) #3

The plugin category one is
https://github.com/discourse/discourse/pull/1670
The reason for this is that while plugin locale files can add translations for the plugin settings you can not name a category. I am not sure why but my thought is that it is due to a loading order of the locale files.

The closed pull request was for loading settings from a plugin and has been replaced with a better version


(Neil Lalonde) #4

I see the problem with translations from plugins. We don’t actually support translations for admin stuff in plugins yet, but we should. I’m on it!


(eriko) #5

To a certain degree you do as I am using them for the actual settings.

They work for en.site_settings.
but not for
en.admin.site_settings.


(Neil Lalonde) #6

I committed a fix to get this working. So, an example plugin that adds a site setting that can be used in javascript:

/plugins
  /new_setting
    plugin.rb
    /config
      settings.yml
      /locales
        client.en.yml
        server.en.yml

settings.yml:

pirate:
  translate_to_pirate:
    default: true
    client: true

client.en.yml:

en:
  admin_js:
    admin:
      site_settings:
        categories:
          pirate: 'Pirate'

server.en.yml:

en:
  site_settings:
    translate_to_pirate: "Translate all posts into pirate speak."

In javascript, you can use it with:

Discourse.SiteSettings.translate_to_pirate

In admin, you’ll see the setting and its category:

It’s annoying that the description of the setting has to go in server.*.yml.


(eriko) #7

Sweet and thanks.

I still think that we should come up with a convention for the naming of the a plugins category, and settings for that matter, that is not ugly. I am going to do some more work on my cas_sso see if I can come up with something better than what I am doing now.


(Erlend Sogge Heggen) #8

WordPress plugin settings are a complete mess! I hope Discourse won’t become too lenient when it comes to plugins’ presence in the panel.


(Marcin Rataj) #9

Not sure it it is wise to revive topic that is 298 days old, but I could not find anything newer about ‘Plugin’ category, and maybe someone is still interested:

https://github.com/discourse/discourse/pull/2804


(Daniel Fernández Pescetto) #10

I need to add a text area inside a new settings category because I need to add html into them. How can I do that? It this possible?

Thanks