summaryrefslogtreecommitdiffstats
path: root/extra
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-23 18:50:53 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-23 18:50:53 +0000
commitdbcf2065b86d610bc714b362d253664d81166e87 (patch)
treea217cfdd7756ad499f2b9c4ccec0d3dc88e8acbb /extra
parente4f0864e3a7f17f0e8a282aad29202f53bf11139 (diff)
downloadredmine-dbcf2065b86d610bc714b362d253664d81166e87.tar.gz
redmine-dbcf2065b86d610bc714b362d253664d81166e87.zip
Added a sample plugin.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@753 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'extra')
-rw-r--r--extra/sample_plugin/README24
-rw-r--r--extra/sample_plugin/app/controllers/example_controller.rb17
-rw-r--r--extra/sample_plugin/app/views/example/say_goodbye.rhtml5
-rw-r--r--extra/sample_plugin/app/views/example/say_hello.rhtml9
-rw-r--r--extra/sample_plugin/app/views/settings/_settings.rhtml3
-rw-r--r--extra/sample_plugin/assets/images/it_works.pngbin0 -> 3593 bytes
-rw-r--r--extra/sample_plugin/assets/stylesheets/example.css1
-rw-r--r--extra/sample_plugin/db/migrate/001_create_some_models.rb13
-rw-r--r--extra/sample_plugin/init.rb25
-rw-r--r--extra/sample_plugin/lang/en.yml4
-rw-r--r--extra/sample_plugin/lang/fr.yml4
11 files changed, 105 insertions, 0 deletions
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 @@
+<p class="icon icon-example-works"><%= l(:text_say_goodbye) %></p>
+
+<% 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 @@
+<p class="icon icon-example-works"><%= l(:text_say_hello) %></p>
+
+<p><label>Example setting</label>: <%= @value %></p>
+
+<%= 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 @@
+<p><label>Example setting</label><%= text_field_tag 'settings[sample_setting]', @settings['sample_setting'] %></p>
+
+<p><label>Foo</label><%= text_field_tag 'settings[foo]', @settings['foo'] %></p>
diff --git a/extra/sample_plugin/assets/images/it_works.png b/extra/sample_plugin/assets/images/it_works.png
new file mode 100644
index 000000000..441f368d2
--- /dev/null
+++ b/extra/sample_plugin/assets/images/it_works.png
Binary files differ
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'