mirror of
https://github.com/redmine/redmine.git
synced 2025-11-12 00:06:01 +01:00
Remove code that is no longer needed as a result of asset pipeline implementation (#39111).
Patch by Takashi Kato (@tohosaku). git-svn-id: https://svn.redmine.org/redmine/trunk@22627 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -79,7 +79,6 @@ class AdminController < ApplicationController
|
|||||||
@checklist = [
|
@checklist = [
|
||||||
[:text_default_administrator_account_changed, User.default_admin_account_changed?],
|
[:text_default_administrator_account_changed, User.default_admin_account_changed?],
|
||||||
[:text_file_repository_writable, File.writable?(Attachment.storage_path)],
|
[:text_file_repository_writable, File.writable?(Attachment.storage_path)],
|
||||||
["#{l :text_plugin_assets_writable} (./public/plugin_assets)", File.writable?(Redmine::Plugin.public_directory)],
|
|
||||||
[:text_all_migrations_have_been_run, !ActiveRecord::Base.connection.migration_context.needs_migration?],
|
[:text_all_migrations_have_been_run, !ActiveRecord::Base.connection.migration_context.needs_migration?],
|
||||||
[:text_minimagick_available, Object.const_defined?(:MiniMagick)],
|
[:text_minimagick_available, Object.const_defined?(:MiniMagick)],
|
||||||
[:text_convert_available, Redmine::Thumbnail.convert_available?],
|
[:text_convert_available, Redmine::Thumbnail.convert_available?],
|
||||||
|
|||||||
@@ -35,43 +35,6 @@ module Redmine
|
|||||||
@dir
|
@dir
|
||||||
end
|
end
|
||||||
|
|
||||||
def mirror_assets
|
|
||||||
return unless has_assets_dir?
|
|
||||||
|
|
||||||
destination = File.join(PluginLoader.public_directory, File.basename(@dir))
|
|
||||||
|
|
||||||
source_files = Dir["#{assets_dir}/**/*"]
|
|
||||||
source_dirs = source_files.select { |d| File.directory?(d)}
|
|
||||||
source_files -= source_dirs
|
|
||||||
unless source_files.empty?
|
|
||||||
base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(assets_dir, ''))
|
|
||||||
begin
|
|
||||||
FileUtils.mkdir_p(base_target_dir)
|
|
||||||
rescue => e
|
|
||||||
raise "Could not create directory #{base_target_dir}: " + e.message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
source_dirs.each do |dir|
|
|
||||||
# strip down these paths so we have simple, relative paths we can
|
|
||||||
# add to the destination
|
|
||||||
target_dir = File.join(destination, dir.gsub(assets_dir, ''))
|
|
||||||
begin
|
|
||||||
FileUtils.mkdir_p(target_dir)
|
|
||||||
rescue => e
|
|
||||||
raise "Could not create directory #{target_dir}: " + e.message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
source_files.each do |file|
|
|
||||||
target = File.join(destination, file.gsub(assets_dir, ''))
|
|
||||||
unless File.exist?(target) && FileUtils.identical?(file, target)
|
|
||||||
FileUtils.cp(file, target)
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
raise "Could not copy #{file} to #{target}: " + e.message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def has_assets_dir?
|
def has_assets_dir?
|
||||||
File.directory?(@assets_dir)
|
File.directory?(@assets_dir)
|
||||||
end
|
end
|
||||||
@@ -90,16 +53,6 @@ module Redmine
|
|||||||
cattr_accessor :public_directory
|
cattr_accessor :public_directory
|
||||||
self.public_directory = Rails.public_path.join('plugin_assets')
|
self.public_directory = Rails.public_path.join('plugin_assets')
|
||||||
|
|
||||||
def self.create_assets_reloader
|
|
||||||
plugin_assets_dirs = {}
|
|
||||||
directories.each do |dir|
|
|
||||||
plugin_assets_dirs[dir.assets_dir] = ['*']
|
|
||||||
end
|
|
||||||
ActiveSupport::FileUpdateChecker.new([], plugin_assets_dirs) do
|
|
||||||
mirror_assets
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.load
|
def self.load
|
||||||
setup
|
setup
|
||||||
add_autoload_paths
|
add_autoload_paths
|
||||||
@@ -136,13 +89,5 @@ module Redmine
|
|||||||
def self.directories
|
def self.directories
|
||||||
@plugin_directories
|
@plugin_directories
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.mirror_assets(name=nil)
|
|
||||||
if name.present?
|
|
||||||
directories.find{|d| d.to_s == File.join(directory, name)}.mirror_assets
|
|
||||||
else
|
|
||||||
directories.each(&:mirror_assets)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class Redmine::PluginLoaderTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
@klass = Redmine::PluginLoader
|
@klass = Redmine::PluginLoader
|
||||||
@klass.directory = Rails.root.join('test/fixtures/plugins')
|
@klass.directory = Rails.root.join('test/fixtures/plugins')
|
||||||
@klass.public_directory = Rails.root.join('tmp/public/plugin_assets')
|
|
||||||
@klass.load
|
@klass.load
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -33,28 +32,6 @@ class Redmine::PluginLoaderTest < ActiveSupport::TestCase
|
|||||||
clear_public
|
clear_public
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_assets_reloader
|
|
||||||
plugin_assets = @klass.create_assets_reloader
|
|
||||||
plugin_assets.execute.inspect
|
|
||||||
|
|
||||||
assert File.exist?("#{@klass.public_directory}/foo_plugin")
|
|
||||||
assert File.exist?("#{@klass.public_directory}/foo_plugin/stylesheets/foo.css")
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_mirror_assets
|
|
||||||
Redmine::PluginLoader.mirror_assets
|
|
||||||
|
|
||||||
assert File.exist?("#{@klass.public_directory}/foo_plugin")
|
|
||||||
assert File.exist?("#{@klass.public_directory}/foo_plugin/stylesheets/foo.css")
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_mirror_assets_with_plugin_name
|
|
||||||
Redmine::PluginLoader.mirror_assets('foo_plugin')
|
|
||||||
|
|
||||||
assert File.exist?("#{@klass.public_directory}/foo_plugin")
|
|
||||||
assert File.exist?("#{@klass.public_directory}/foo_plugin/stylesheets/foo.css")
|
|
||||||
end
|
|
||||||
|
|
||||||
def clear_public
|
def clear_public
|
||||||
FileUtils.rm_rf 'tmp/public'
|
FileUtils.rm_rf 'tmp/public'
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user