Skip to content

Commit

Permalink
DEV: support for settings/locales in plugin generator (discourse#6341)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaffeux authored Aug 30, 2018
1 parent 103509b commit 90e67b6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/generators/plugin/plugin_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ def create_javascript_file
template 'javascript.es6.erb', File.join('plugins', dasherized_name, 'assets/javascripts/initializers', "#{dasherized_name}.es6")
end

def create_settings_file
template 'settings.yml.erb', File.join('plugins', dasherized_name, 'config', 'settings.yml')
end

def create_locales_file
template 'client.en.yml.erb', File.join('plugins', dasherized_name, 'config/locales', 'client.en.yml')
template 'server.en.yml.erb', File.join('plugins', dasherized_name, 'config/locales', 'server.en.yml')
end

def create_gitignore_entry
plugin_entry = "!/plugins/#{dasherized_name}"

Expand Down
3 changes: 3 additions & 0 deletions lib/generators/plugin/templates/client.en.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
en:
js:
<%= underscored_name %>:
3 changes: 3 additions & 0 deletions lib/generators/plugin/templates/server.en.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
en:
site_settings:
<%= underscored_name %>_enabled: "Enable <%= name %> plugin"
4 changes: 4 additions & 0 deletions lib/generators/plugin/templates/settings.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugins:
<%= underscored_name %>_enabled:
default: true
client: true

0 comments on commit 90e67b6

Please sign in to comment.