Redmine 3.4.4
This commit is contained in:
commit
64924a6376
2112 changed files with 259028 additions and 0 deletions
5
lib/generators/redmine_plugin_controller/USAGE
Normal file
5
lib/generators/redmine_plugin_controller/USAGE
Normal file
|
@ -0,0 +1,5 @@
|
|||
Description:
|
||||
Generates a plugin controller.
|
||||
|
||||
Example:
|
||||
./script/rails generate redmine_plugin_controller meetings pools index show vote
|
|
@ -0,0 +1,27 @@
|
|||
class RedminePluginControllerGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path("../templates", __FILE__)
|
||||
argument :controller, :type => :string
|
||||
argument :actions, :type => :array, :default => [], :banner => "ACTION ACTION ..."
|
||||
|
||||
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
@plugin_name = file_name.underscore
|
||||
@plugin_pretty_name = plugin_name.titleize
|
||||
@plugin_path = File.join(Redmine::Plugin.directory, plugin_name)
|
||||
@controller_class = controller.camelize
|
||||
end
|
||||
|
||||
def copy_templates
|
||||
template 'controller.rb.erb', "#{plugin_path}/app/controllers/#{controller}_controller.rb"
|
||||
template 'helper.rb.erb', "#{plugin_path}/app/helpers/#{controller}_helper.rb"
|
||||
template 'functional_test.rb.erb', "#{plugin_path}/test/functional/#{controller}_controller_test.rb"
|
||||
# View template for each action.
|
||||
actions.each do |action|
|
||||
path = "#{plugin_path}/app/views/#{controller}/#{action}.html.erb"
|
||||
@action_name = action
|
||||
template 'view.html.erb', path
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
class <%= @controller_class %>Controller < ApplicationController
|
||||
<% actions.each do |action| -%>
|
||||
|
||||
def <%= action %>
|
||||
end
|
||||
<% end -%>
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class <%= @controller_class %>ControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module <%= @controller_class %>Helper
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
<h2><%= @controller_class %>Controller#<%= @action_name %></h2>
|
Loading…
Add table
Add a link
Reference in a new issue