Merge pull request #5141 from opf/fix/openproject_plugin_generator

updated generated plugin and docs
pull/5144/head
Oliver Günther 8 years ago committed by GitHub
commit f1b6f41f8a
  1. 28
      doc/development/create-openproject-plugin.md
  2. 10
      lib/generators/open_project/plugin/templates/%full_name%.gemspec.tt
  3. 4
      lib/generators/open_project/plugin/templates/lib/open_project/%plugin_name%/engine.rb.tt

@ -7,20 +7,26 @@ OpenProject plugins are special ruby gems. You may include them in your `Gemfile
You can generate a new plugin directly from OpenProject. Think of a good name and a place (in your filesystem) where the plugin should go. In this example, we have a `plugins` directory right next to the `openproject` directory. Then do
```bash
bundle exec rails generate open_project:plugin a_good_name ../plugins/
bundle exec rails generate open_project:plugin my_plugin ../plugins/
```
This generates the plugins `openproject-a_good_name` into the directory `../plugins/openproject-a_good_name`. The new plugin is a rails engine, which can be published as a gem. Please edit the `openproject-a_good_name.gemspec` file to be ready.
This generates the plugins `openproject-my_plugin` into the directory `../plugins/openproject-my_plugin`. The new plugin is a rails engine, which can be published as a gem.
You may want to update the generated plugin's gemspec (`openproject-my_plugin.gemspec`).
## Hook the new plugin into OpenProject
To include the new plugin into OpenProject, we have to add it into `Gemfile.plugins` like any other OpenProject plugin. Add the following line to `Gemfile.plugins`:
To include the new plugin into OpenProject, we have to add it into `Gemfile.plugins` like any other OpenProject plugin. Add the following lines to `Gemfile.plugins`:
```
gem "openproject-a_good_name", :path => '../plugins/openproject-a_good_name'
group :opf_plugins do
gem "openproject-a_good_name", :path => '../plugins/openproject-a_good_name'
end
```
and install it via
If there already is an `opf_plugins` group, just add the `gem` line to it.
Once you've done that install it via
```bash
bundle install
@ -131,13 +137,8 @@ images, styles and I18n translations.
Translations are processed by I18n.js through Rails and will be picked up from `config/locales/js-<locale>.js`.
Pure frontend plugins should be considered _a work in progress_. As such, it is
currently recommended to create hybrid plugins (see below).
**To use a frontend plugin:**
* You will currently need to modify the `package.json` of OpenProject core
directly. A more robust solution is currently in planning.
Pure frontend plugins are currently not possible without modifications to the OpenProject core `package.json`.
We instead recommend to create a hybrid gem plugin instead (see below).
## Hybrid plugins
@ -153,6 +154,5 @@ _CAVEAT: npm dependencies for hybrid plugins are not yet resolved._
* then run `bundle install`.
You **do not** need to modify the `package.json` of OpenProject core. Provided
Ruby Bundler is aware of these plugins, Webpack (our node-based build pipeline)
Provided Ruby Bundler is aware of these plugins, Webpack (our node-based build pipeline)
will bundle their assets.

@ -6,14 +6,14 @@ require 'open_project/<%= plugin_name %>/version'
Gem::Specification.new do |s|
s.name = "<%= full_name %>"
s.version = OpenProject::<%= plugin_name.camelcase %>::VERSION
s.authors = "Finn GmbH"
s.email = "info@finn.de"
s.authors = "OpenProject GmbH"
s.email = "info@openproject.org"
s.homepage = "https://community.openproject.org/projects/<%= plugin_name.gsub('_','-') %>" # TODO check this URL
s.summary = 'OpenProject <%= plugin_name.gsub('_', ' ').titleize %>'
s.description = FIXME
s.license = FIXME # e.g. "MIT" or "GPLv3"
s.description = "FIXME"
s.license = "FIXME" # e.g. "MIT" or "GPLv3"
s.files = Dir["{app,config,db,lib}/**/*"] + %w(CHANGELOG.md README.md)
s.add_dependency "rails", "~> 3.2.14"
s.add_dependency "rails", "~> 5.0"
end

@ -9,8 +9,8 @@ module OpenProject::<%= plugin_name.camelcase %>
include OpenProject::Plugins::ActsAsOpEngine
register '<%= full_name %>',
:author_url => 'http://finn.de',
:requires_openproject => '>= 3.0.0pre13'
:author_url => 'https://openproject.org',
:requires_openproject => '>= 6.0.0'
end
end

Loading…
Cancel
Save