diff options
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/deprecated.rake | 1 | ||||
-rw-r--r-- | lib/tasks/initializers.rake | 30 | ||||
-rw-r--r-- | lib/tasks/migrate_plugins.rake | 15 | ||||
-rw-r--r-- | lib/tasks/plugins.rake | 38 | ||||
-rw-r--r-- | lib/tasks/redmine.rake | 24 |
5 files changed, 35 insertions, 73 deletions
diff --git a/lib/tasks/deprecated.rake b/lib/tasks/deprecated.rake index dca43ddc7..2588ae8b2 100644 --- a/lib/tasks/deprecated.rake +++ b/lib/tasks/deprecated.rake @@ -7,3 +7,4 @@ end deprecated_task :load_default_data, "redmine:load_default_data" deprecated_task :migrate_from_mantis, "redmine:migrate_from_mantis" deprecated_task :migrate_from_trac, "redmine:migrate_from_trac" +deprecated_task "db:migrate_plugins", "redmine:plugins:migrate" diff --git a/lib/tasks/initializers.rake b/lib/tasks/initializers.rake index a80bd1d1b..c1fdc7bf5 100644 --- a/lib/tasks/initializers.rake +++ b/lib/tasks/initializers.rake @@ -1,34 +1,24 @@ -desc 'Generates a configuration file for cookie store sessions.' +desc 'Generates a secret token for the application.' -file 'config/initializers/session_store.rb' do - path = File.join(Rails.root, 'config', 'initializers', 'session_store.rb') - secret = ActiveSupport::SecureRandom.hex(40) +file 'config/initializers/secret_token.rb' do + path = File.join(Rails.root, 'config', 'initializers', 'secret_token.rb') + secret = SecureRandom.hex(40) File.open(path, 'w') do |f| f.write <<"EOF" -# This file was generated by 'rake config/initializers/session_store.rb', -# and should not be made visible to public. +# This file was generated by 'rake generate_secret_token', and should +# not be made visible to public. # If you have a load-balancing Redmine cluster, you will need to use the # same version of this file on each machine. And be sure to restart your # server when you modify this file. - +# # Your secret key for verifying cookie session data integrity. If you # change this key, all old sessions will become invalid! Make sure the # secret is at least 30 characters and all random, no regular words or # you'll be exposed to dictionary attacks. -ActionController::Base.session = { - :key => '_redmine_session', - # - # Uncomment and edit the :session_path below if are hosting your Redmine - # at a suburi and don't want the top level path to access the cookies - # - # See: http://www.redmine.org/issues/3968 - # - # :session_path => '/url_path_to/your/redmine/', - :secret => '#{secret}' -} +RedmineApp::Application.config.secret_token = '#{secret}' EOF end end -desc 'Generates a configuration file for cookie store sessions.' -task :generate_session_store => ['config/initializers/session_store.rb'] +desc 'Generates a secret token for the application.' +task :generate_secret_token => ['config/initializers/secret_token.rb'] diff --git a/lib/tasks/migrate_plugins.rake b/lib/tasks/migrate_plugins.rake deleted file mode 100644 index 0516d8306..000000000 --- a/lib/tasks/migrate_plugins.rake +++ /dev/null @@ -1,15 +0,0 @@ -namespace :db do - desc 'Migrates installed plugins.' - task :migrate_plugins => :environment do - if Rails.respond_to?('plugins') - Rails.plugins.each do |plugin| - next unless plugin.respond_to?('migrate') - puts "Migrating #{plugin.name}..." - plugin.migrate - end - else - puts "Undefined method plugins for Rails!" - puts "Make sure engines plugin is installed." - end - end -end diff --git a/lib/tasks/plugins.rake b/lib/tasks/plugins.rake deleted file mode 100644 index 136877164..000000000 --- a/lib/tasks/plugins.rake +++ /dev/null @@ -1,38 +0,0 @@ -require 'source_annotation_extractor' - -# Modified version of the SourceAnnotationExtractor in railties -# Will search for runable code that uses <tt>call_hook</tt> -class PluginSourceAnnotationExtractor < SourceAnnotationExtractor - # Returns a hash that maps filenames under +dir+ (recursively) to arrays - # with their annotations. Only files with annotations are included, and only - # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+ - # are taken into account. - def find_in(dir) - results = {} - - Dir.glob("#{dir}/*") do |item| - next if File.basename(item)[0] == ?. - - if File.directory?(item) - results.update(find_in(item)) - elsif item =~ /(hook|test)\.rb/ - # skip - elsif item =~ /\.(builder|(r(?:b|xml|js)))$/ - results.update(extract_annotations_from(item, /\s*(#{tag})\(?\s*(.*)$/)) - elsif item =~ /\.(rhtml|erb)$/ - results.update(extract_annotations_from(item, /<%=\s*\s*(#{tag})\(?\s*(.*?)\s*%>/)) - end - end - - results - end -end - -namespace :redmine do - namespace :plugins do - desc "Enumerate all Redmine plugin hooks and their context parameters" - task :hook_list do - PluginSourceAnnotationExtractor.enumerate 'call_hook' - end - end -end diff --git a/lib/tasks/redmine.rake b/lib/tasks/redmine.rake index 3e9faea70..8a6b98b44 100644 --- a/lib/tasks/redmine.rake +++ b/lib/tasks/redmine.rake @@ -41,4 +41,28 @@ namespace :redmine do task :fetch_changesets => :environment do Repository.fetch_changesets end + + desc 'Migrates and copies plugins assets.' + task :plugins do + Rake::Task["redmine:plugins:migrate"].invoke + Rake::Task["redmine:plugins:assets"].invoke + end + + namespace :plugins do + desc 'Migrates installed plugins.' + task :migrate => :environment do + Redmine::Plugin.all.each do |plugin| + puts "Migrating #{plugin.name}..." + plugin.migrate + end + end + + desc 'Copies plugins assets into the public directory.' + task :assets => :environment do + Redmine::Plugin.all.each do |plugin| + puts "Copying #{plugin.name} assets..." + plugin.mirror_assets + end + end + end end |