From dbcf2065b86d610bc714b362d253664d81166e87 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 23 Sep 2007 18:50:53 +0000 Subject: [PATCH] Added a sample plugin. git-svn-id: http://redmine.rubyforge.org/svn/trunk@753 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- extra/sample_plugin/README | 24 +++++++++++++++++ .../app/controllers/example_controller.rb | 17 ++++++++++++ .../app/views/example/say_goodbye.rhtml | 5 ++++ .../app/views/example/say_hello.rhtml | 9 +++++++ .../app/views/settings/_settings.rhtml | 3 +++ .../sample_plugin/assets/images/it_works.png | Bin 0 -> 3593 bytes .../assets/stylesheets/example.css | 1 + .../db/migrate/001_create_some_models.rb | 13 +++++++++ extra/sample_plugin/init.rb | 25 ++++++++++++++++++ extra/sample_plugin/lang/en.yml | 4 +++ extra/sample_plugin/lang/fr.yml | 4 +++ 11 files changed, 105 insertions(+) create mode 100644 extra/sample_plugin/README create mode 100644 extra/sample_plugin/app/controllers/example_controller.rb create mode 100644 extra/sample_plugin/app/views/example/say_goodbye.rhtml create mode 100644 extra/sample_plugin/app/views/example/say_hello.rhtml create mode 100644 extra/sample_plugin/app/views/settings/_settings.rhtml create mode 100644 extra/sample_plugin/assets/images/it_works.png create mode 100644 extra/sample_plugin/assets/stylesheets/example.css create mode 100644 extra/sample_plugin/db/migrate/001_create_some_models.rb create mode 100644 extra/sample_plugin/init.rb create mode 100644 extra/sample_plugin/lang/en.yml create mode 100644 extra/sample_plugin/lang/fr.yml diff --git a/extra/sample_plugin/README b/extra/sample_plugin/README new file mode 100644 index 000000000..eed8b9a23 --- /dev/null +++ b/extra/sample_plugin/README @@ -0,0 +1,24 @@ +== Sample plugin + +This is a sample plugin for Redmine + +== Installation + +=== Adding plugin support to Redmine + +1. Install engines plugin + See: http://rails-engines.org/ + +2. Uncomment this line in config/environment.rb: + config.plugins = ["engines", "*"] + +=== Plugin installation + +1. Copy the plugin directory into the vendor/plugins directory + +2. Migrate plugin: + rake db:migrate_plugins + +3. Start Redmine + +Installed plugins are listed on 'Admin -> Information' screen. diff --git a/extra/sample_plugin/app/controllers/example_controller.rb b/extra/sample_plugin/app/controllers/example_controller.rb new file mode 100644 index 000000000..9bdaf448e --- /dev/null +++ b/extra/sample_plugin/app/controllers/example_controller.rb @@ -0,0 +1,17 @@ +# Sample plugin controller +class ExampleController < ApplicationController + layout 'base' + before_filter :find_project, :authorize + + def say_hello + @value = Setting.plugin_sample_plugin['sample_setting'] + end + + def say_goodbye + end + +private + def find_project + @project=Project.find(params[:id]) + end +end diff --git a/extra/sample_plugin/app/views/example/say_goodbye.rhtml b/extra/sample_plugin/app/views/example/say_goodbye.rhtml new file mode 100644 index 000000000..3f4d63dae --- /dev/null +++ b/extra/sample_plugin/app/views/example/say_goodbye.rhtml @@ -0,0 +1,5 @@ +

<%= l(:text_say_goodbye) %>

+ +<% content_for :header_tags do %> + <%= stylesheet_link_tag "example.css", :plugin => "sample_plugin", :media => "screen" %> +<% end %> diff --git a/extra/sample_plugin/app/views/example/say_hello.rhtml b/extra/sample_plugin/app/views/example/say_hello.rhtml new file mode 100644 index 000000000..17aca7bc4 --- /dev/null +++ b/extra/sample_plugin/app/views/example/say_hello.rhtml @@ -0,0 +1,9 @@ +

<%= l(:text_say_hello) %>

+ +

: <%= @value %>

+ +<%= link_to_if_authorized 'Good bye', :action => 'say_goodbye', :id => @project %> + +<% content_for :header_tags do %> + <%= stylesheet_link_tag "example.css", :plugin => "sample_plugin", :media => "screen" %> +<% end %> diff --git a/extra/sample_plugin/app/views/settings/_settings.rhtml b/extra/sample_plugin/app/views/settings/_settings.rhtml new file mode 100644 index 000000000..bf06e2666 --- /dev/null +++ b/extra/sample_plugin/app/views/settings/_settings.rhtml @@ -0,0 +1,3 @@ +

<%= text_field_tag 'settings[sample_setting]', @settings['sample_setting'] %>

+ +

<%= text_field_tag 'settings[foo]', @settings['foo'] %>

diff --git a/extra/sample_plugin/assets/images/it_works.png b/extra/sample_plugin/assets/images/it_works.png new file mode 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Q-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=00004XF*Lt006O$eEU(80000WV@Og>004R=004l4008;_004mL004C` z008P>0026e000+nl3&F}0009dNkl%Jnm=d-(?)?U{Nz5PcO#Rs#5)7XIaI(m;!v{mNtXq1R~o6rflJXL1T z?g0kVqu@u;MWHX1JEnC>*hjMj?j~0G9`$mKy@&c4A4`Ko!11Y+n>6YTUVf$r9xQ^A zgJ>@aMIF|>j^$Im4S_)_-oCs~#5h{(2EYw?Pl*%?2|EQR&*aB(-f(YZo8v7pUWxcAf zxY%K(=+LQnq?8yW^GGyBv1u1)wwYFEmvEmNbJp_F`0;FENJWc->(Q-w4D3=E&PFL@ zRMNR5U4=nVRc@Bn?4N7(iBHaRM+LZio#lfE%vLhwrA#WNDXA>z-Jt29>yXYsu9qP2 zS-N|tJ-c2#`Sv-!{b$O6Jo_uxH})Af>)Si~yDTfGhMt0=5ujjOHl_O;-cQSGzt2}2 zZ=L*%ZvX*^JbbFj6ZF*_j>JOc#V#Vlcu3umwH+t?F&1I&^Q&zAJOAeZp*D?Qv7s2r P00000NkvXXu0mjfWW&m) literal 0 HcmV?d00001 diff --git a/extra/sample_plugin/assets/stylesheets/example.css b/extra/sample_plugin/assets/stylesheets/example.css new file mode 100644 index 000000000..8038567a4 --- /dev/null +++ b/extra/sample_plugin/assets/stylesheets/example.css @@ -0,0 +1 @@ +.icon-example-works { background-image: url(../images/it_works.png); } diff --git a/extra/sample_plugin/db/migrate/001_create_some_models.rb b/extra/sample_plugin/db/migrate/001_create_some_models.rb new file mode 100644 index 000000000..39d58a649 --- /dev/null +++ b/extra/sample_plugin/db/migrate/001_create_some_models.rb @@ -0,0 +1,13 @@ +# Sample plugin migration +# Use rake db:migrate_plugins to migrate installed plugins +class CreateSomeModels < ActiveRecord::Migration + def self.up + create_table :example_plugin_model, :force => true do |t| + t.column "example_attribute", :integer + end + end + + def self.down + drop_table :example_plugin_model + end +end diff --git a/extra/sample_plugin/init.rb b/extra/sample_plugin/init.rb new file mode 100644 index 000000000..48a5d935c --- /dev/null +++ b/extra/sample_plugin/init.rb @@ -0,0 +1,25 @@ +# Redmine sample plugin +require 'redmine' + +RAILS_DEFAULT_LOGGER.info 'Starting Example plugin for RedMine' + +Redmine::Plugin.register :sample_plugin do + name 'Example plugin' + author 'Author name' + description 'This is a sample plugin for Redmine' + version '0.0.1' + settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'settings/settings' + + # This plugin adds a project module + # It can be enabled/disabled at project level (Project settings -> Modules) + project_module :example_module do + # A public action + permission :example_say_hello, {:example => [:say_hello]}, :public => true + # This permission has to be explicitly given + # It will be listed on the permissions screen + permission :example_say_goodbye, {:example => [:say_goodbye]} + end + + # A new item is added to the project menu + menu :project_menu, :label_plugin_example, :controller => 'example', :action => 'say_hello' +end diff --git a/extra/sample_plugin/lang/en.yml b/extra/sample_plugin/lang/en.yml new file mode 100644 index 000000000..bf62bc344 --- /dev/null +++ b/extra/sample_plugin/lang/en.yml @@ -0,0 +1,4 @@ +# Sample plugin +label_plugin_example: Sample Plugin +text_say_hello: Plugin say 'Hello' +text_say_goodbye: Plugin say 'Good bye' diff --git a/extra/sample_plugin/lang/fr.yml b/extra/sample_plugin/lang/fr.yml new file mode 100644 index 000000000..2c0829c32 --- /dev/null +++ b/extra/sample_plugin/lang/fr.yml @@ -0,0 +1,4 @@ +# Sample plugin +label_plugin_example: Plugin exemple +text_say_hello: Plugin dit 'Bonjour' +text_say_goodbye: Plugin dit 'Au revoir'