Redmine 3.4.4
This commit is contained in:
commit
64924a6376
2112 changed files with 259028 additions and 0 deletions
26
lib/generators/redmine_plugin/USAGE
Normal file
26
lib/generators/redmine_plugin/USAGE
Normal file
|
@ -0,0 +1,26 @@
|
|||
Description:
|
||||
The plugin generator creates stubs for a new Redmine plugin.
|
||||
|
||||
Example:
|
||||
./script/rails generate redmine_plugin meetings
|
||||
create plugins/meetings/app
|
||||
create plugins/meetings/app/controllers
|
||||
create plugins/meetings/app/helpers
|
||||
create plugins/meetings/app/models
|
||||
create plugins/meetings/app/views
|
||||
create plugins/meetings/db/migrate
|
||||
create plugins/meetings/lib/tasks
|
||||
create plugins/meetings/assets/images
|
||||
create plugins/meetings/assets/javascripts
|
||||
create plugins/meetings/assets/stylesheets
|
||||
create plugins/meetings/config/locales
|
||||
create plugins/meetings/test
|
||||
create plugins/meetings/test/fixtures
|
||||
create plugins/meetings/test/unit
|
||||
create plugins/meetings/test/functional
|
||||
create plugins/meetings/test/integration
|
||||
create plugins/meetings/README.rdoc
|
||||
create plugins/meetings/init.rb
|
||||
create plugins/meetings/config/routes.rb
|
||||
create plugins/meetings/config/locales/en.yml
|
||||
create plugins/meetings/test/test_helper.rb
|
37
lib/generators/redmine_plugin/redmine_plugin_generator.rb
Normal file
37
lib/generators/redmine_plugin/redmine_plugin_generator.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
class RedminePluginGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path("../templates", __FILE__)
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
def copy_templates
|
||||
empty_directory "#{plugin_path}/app"
|
||||
empty_directory "#{plugin_path}/app/controllers"
|
||||
empty_directory "#{plugin_path}/app/helpers"
|
||||
empty_directory "#{plugin_path}/app/models"
|
||||
empty_directory "#{plugin_path}/app/views"
|
||||
empty_directory "#{plugin_path}/db/migrate"
|
||||
empty_directory "#{plugin_path}/lib/tasks"
|
||||
empty_directory "#{plugin_path}/assets/images"
|
||||
empty_directory "#{plugin_path}/assets/javascripts"
|
||||
empty_directory "#{plugin_path}/assets/stylesheets"
|
||||
empty_directory "#{plugin_path}/config/locales"
|
||||
empty_directory "#{plugin_path}/test"
|
||||
empty_directory "#{plugin_path}/test/fixtures"
|
||||
empty_directory "#{plugin_path}/test/unit"
|
||||
empty_directory "#{plugin_path}/test/functional"
|
||||
empty_directory "#{plugin_path}/test/integration"
|
||||
|
||||
template 'README.rdoc', "#{plugin_path}/README.rdoc"
|
||||
template 'init.rb.erb', "#{plugin_path}/init.rb"
|
||||
template 'routes.rb', "#{plugin_path}/config/routes.rb"
|
||||
template 'en_rails_i18n.yml', "#{plugin_path}/config/locales/en.yml"
|
||||
template 'test_helper.rb.erb', "#{plugin_path}/test/test_helper.rb"
|
||||
end
|
||||
end
|
3
lib/generators/redmine_plugin/templates/README.rdoc
Normal file
3
lib/generators/redmine_plugin/templates/README.rdoc
Normal file
|
@ -0,0 +1,3 @@
|
|||
= <%= file_name %>
|
||||
|
||||
Description goes here
|
|
@ -0,0 +1,3 @@
|
|||
# English strings go here for Rails i18n
|
||||
en:
|
||||
# my_label: "My label"
|
8
lib/generators/redmine_plugin/templates/init.rb.erb
Normal file
8
lib/generators/redmine_plugin/templates/init.rb.erb
Normal file
|
@ -0,0 +1,8 @@
|
|||
Redmine::Plugin.register :<%= plugin_name %> do
|
||||
name '<%= plugin_pretty_name %> plugin'
|
||||
author 'Author name'
|
||||
description 'This is a plugin for Redmine'
|
||||
version '0.0.1'
|
||||
url 'http://example.com/path/to/plugin'
|
||||
author_url 'http://example.com/about'
|
||||
end
|
2
lib/generators/redmine_plugin/templates/routes.rb
Normal file
2
lib/generators/redmine_plugin/templates/routes.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Plugin's routes
|
||||
# See: http://guides.rubyonrails.org/routing.html
|
|
@ -0,0 +1,2 @@
|
|||
# Load the Redmine helper
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
|
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>
|
5
lib/generators/redmine_plugin_model/USAGE
Normal file
5
lib/generators/redmine_plugin_model/USAGE
Normal file
|
@ -0,0 +1,5 @@
|
|||
Description:
|
||||
Generates a plugin model.
|
||||
|
||||
Examples:
|
||||
./script/rails generate redmine_plugin_model meetings pool
|
|
@ -0,0 +1,41 @@
|
|||
class RedminePluginModelGenerator < Rails::Generators::NamedBase
|
||||
|
||||
source_root File.expand_path("../templates", __FILE__)
|
||||
argument :model, :type => :string
|
||||
argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"
|
||||
class_option :migration, :type => :boolean
|
||||
class_option :timestamps, :type => :boolean
|
||||
class_option :parent, :type => :string, :desc => "The parent class for the generated model"
|
||||
class_option :indexes, :type => :boolean, :default => true, :desc => "Add indexes for references and belongs_to columns"
|
||||
|
||||
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)
|
||||
@model_class = model.camelize
|
||||
@table_name = @model_class.tableize
|
||||
@migration_filename = "create_#{@table_name}"
|
||||
@migration_class_name = @migration_filename.camelize
|
||||
end
|
||||
|
||||
def copy_templates
|
||||
template 'model.rb.erb', "#{plugin_path}/app/models/#{model.underscore}.rb"
|
||||
template 'unit_test.rb.erb', "#{plugin_path}/test/unit/#{model.underscore}_test.rb"
|
||||
|
||||
migration_filename = "%03i_#{@migration_filename}.rb" % (migration_number + 1)
|
||||
template "migration.rb", "#{plugin_path}/db/migrate/#{migration_filename}"
|
||||
end
|
||||
|
||||
def attributes_with_index
|
||||
attributes.select { |a| a.has_index? || (a.reference? && options[:indexes]) }
|
||||
end
|
||||
|
||||
def migration_number
|
||||
current = Dir.glob("#{plugin_path}/db/migrate/*.rb").map do |file|
|
||||
File.basename(file).split("_").first.to_i
|
||||
end.max.to_i
|
||||
end
|
||||
end
|
15
lib/generators/redmine_plugin_model/templates/migration.rb
Normal file
15
lib/generators/redmine_plugin_model/templates/migration.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class <%= @migration_class_name %> < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :<%= @table_name %> do |t|
|
||||
<% attributes.each do |attribute| -%>
|
||||
t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
|
||||
<% end -%>
|
||||
<% if options[:timestamps] %>
|
||||
t.timestamps
|
||||
<% end -%>
|
||||
end
|
||||
<% attributes_with_index.each do |attribute| -%>
|
||||
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
|
||||
<% end -%>
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
class <%= @model_class %> < ActiveRecord::Base
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class <%= @model_class %>Test < ActiveSupport::TestCase
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue