redmine_plugins_helper 0.16.3 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/initializers/assets.rb +0 -1
- data/lib/redmine_plugins_helper/fix_migrations.rb +8 -4
- data/lib/redmine_plugins_helper/hooks/add_assets.rb +10 -3
- data/lib/redmine_plugins_helper/hooks/after_plugins_loaded.rb +3 -0
- data/lib/redmine_plugins_helper/migration/database.rb +3 -2
- data/lib/redmine_plugins_helper/migration.rb +4 -3
- data/lib/redmine_plugins_helper/patches/redmine/plugin/assets.rb +1 -1
- data/lib/redmine_plugins_helper/plugins_autoload_assets.rb +69 -0
- data/lib/redmine_plugins_helper/version.rb +1 -1
- data/lib/redmine_plugins_helper.rb +0 -2
- metadata +35 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1030a544c09ce36b0f1e51c6b5e1e877a3f83163f581cf675474bb52f93a256f
|
|
4
|
+
data.tar.gz: 5f4b58f856c234bf3e20f634ac26a27caf4b5246c2b71a13aaa8044988c91e15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e4ad6ec7462ee78b196a280cde211c74de3aaa97b4bafb9f2fb5254b3ae0224fa81e7160df96b4c6560ea879890ea7e2d08117f8f2765925b5f2c1f75faf4f8
|
|
7
|
+
data.tar.gz: e4d91a701e7a9b91d4dfdab46dc601b1217a47ec34e9a8f13cbcfe103f54d268b56ddc807a0ff89aeff46fb492d8af50ceeab7054f179c8f995b9a54368af0f4
|
|
@@ -29,18 +29,22 @@ module RedminePluginsHelper
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def database_version?(version)
|
|
32
|
-
|
|
32
|
+
schema_migration.versions.include?(version)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def remove_plugin_version(source_version)
|
|
36
36
|
Rails.logger.info("Removing #{source_version}")
|
|
37
|
-
|
|
37
|
+
schema_migration.delete_version(source_version)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def move_plugin_version(source_version, target_version)
|
|
41
41
|
Rails.logger.info("Moving #{source_version} to plugin \"#{target_version}\"")
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
schema_migration.delete_version(source_version)
|
|
43
|
+
schema_migration.create_version(target_version)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def schema_migration
|
|
47
|
+
@schema_migration ||= ::ActiveRecord::Base.connection_pool.schema_migration
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def local_version(timestamp)
|
|
@@ -10,12 +10,19 @@ module RedminePluginsHelper
|
|
|
10
10
|
private
|
|
11
11
|
|
|
12
12
|
def plugins_autoload_stylesheet_tag
|
|
13
|
-
tag.link(
|
|
14
|
-
|
|
13
|
+
tag.link(
|
|
14
|
+
media: 'all',
|
|
15
|
+
rel: 'stylesheet',
|
|
16
|
+
href: asset_path(::RedminePluginsHelper::PluginsAutoloadAssets::CSS_OUTPUT_SUBPATH)
|
|
17
|
+
)
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
def plugins_autoload_script_tag
|
|
18
|
-
content_tag(
|
|
21
|
+
content_tag(
|
|
22
|
+
'script',
|
|
23
|
+
"\n",
|
|
24
|
+
src: asset_path(::RedminePluginsHelper::PluginsAutoloadAssets::JS_OUTPUT_SUBPATH)
|
|
25
|
+
)
|
|
19
26
|
end
|
|
20
27
|
end
|
|
21
28
|
end
|
|
@@ -7,6 +7,9 @@ module RedminePluginsHelper
|
|
|
7
7
|
require 'redmine_plugins_helper/patches'
|
|
8
8
|
Redmine::Plugin.all.sort.each(&:add_assets_paths)
|
|
9
9
|
Redmine::Plugin.all.sort.each(&:load_initializers)
|
|
10
|
+
Rails.application.config.after_initialize do
|
|
11
|
+
RedminePluginsHelper::PluginsAutoloadAssets.instance.generate
|
|
12
|
+
end
|
|
10
13
|
end
|
|
11
14
|
end
|
|
12
15
|
end
|
|
@@ -13,8 +13,9 @@ module RedminePluginsHelper
|
|
|
13
13
|
module ClassMethods
|
|
14
14
|
# @return [Enumerable<RedminePluginsHelper::Migration>]
|
|
15
15
|
def from_database
|
|
16
|
-
::ActiveRecord::
|
|
17
|
-
|
|
16
|
+
schema_migration = ::ActiveRecord::Base.connection_pool.schema_migration
|
|
17
|
+
schema_migration.create_table
|
|
18
|
+
schema_migration.versions.map do |version|
|
|
18
19
|
from_database_version(version)
|
|
19
20
|
end
|
|
20
21
|
end
|
|
@@ -26,8 +26,9 @@ module RedminePluginsHelper
|
|
|
26
26
|
|
|
27
27
|
# @return [Boolean]
|
|
28
28
|
def applied?
|
|
29
|
-
::ActiveRecord::
|
|
30
|
-
|
|
29
|
+
schema_migration = ::ActiveRecord::Base.connection_pool.schema_migration
|
|
30
|
+
schema_migration.create_table
|
|
31
|
+
schema_migration.versions.include?(database_version)
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
# @return [String]
|
|
@@ -57,7 +58,7 @@ module RedminePluginsHelper
|
|
|
57
58
|
if ::Rails.version < '6'
|
|
58
59
|
[plugin.migration_directory]
|
|
59
60
|
else
|
|
60
|
-
[plugin.migration_directory, ActiveRecord::Base.
|
|
61
|
+
[plugin.migration_directory, ActiveRecord::Base.connection_pool.schema_migration]
|
|
61
62
|
end
|
|
62
63
|
end
|
|
63
64
|
end
|
|
@@ -40,7 +40,7 @@ module RedminePluginsHelper
|
|
|
40
40
|
extensions.each do |extension|
|
|
41
41
|
['', '.erb'].each do |erb_extension|
|
|
42
42
|
path = ::File.join(assets_directory, "#{id}.#{extension}#{erb_extension}")
|
|
43
|
-
return id if ::File.exist?(path)
|
|
43
|
+
return id.to_s if ::File.exist?(path)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
nil
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sprockets'
|
|
4
|
+
require 'sprockets/rails/context'
|
|
5
|
+
require 'sassc'
|
|
6
|
+
require 'sassc/rails/version'
|
|
7
|
+
require 'sassc/rails/functions'
|
|
8
|
+
require 'sassc/rails/importer'
|
|
9
|
+
require 'sassc/rails/template'
|
|
10
|
+
|
|
11
|
+
module RedminePluginsHelper
|
|
12
|
+
# Compiles "plugins_autoload.css"/".js", bundling every registered Redmine plugin's main
|
|
13
|
+
# stylesheet/javascript asset, and writes the result as static files that Propshaft serves.
|
|
14
|
+
class PluginsAutoloadAssets
|
|
15
|
+
include ::Singleton
|
|
16
|
+
|
|
17
|
+
enable_memoized
|
|
18
|
+
|
|
19
|
+
CSS_OUTPUT_SUBPATH = 'plugins_autoload.css'
|
|
20
|
+
JS_OUTPUT_SUBPATH = 'plugins_autoload.js'
|
|
21
|
+
OUTPUT_DIRECTORY_SUBPATH = 'tmp/plugins_autoload_assets'
|
|
22
|
+
|
|
23
|
+
# @return [void]
|
|
24
|
+
def generate
|
|
25
|
+
Rails.application.config.sass = ActiveSupport::OrderedOptions.new
|
|
26
|
+
output_directory.join(CSS_OUTPUT_SUBPATH).write(environment[CSS_OUTPUT_SUBPATH].to_s)
|
|
27
|
+
output_directory.join(JS_OUTPUT_SUBPATH).write(environment[JS_OUTPUT_SUBPATH].to_s)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @return [Pathname]
|
|
31
|
+
memoize def output_directory
|
|
32
|
+
Rails.root.join(OUTPUT_DIRECTORY_SUBPATH).tap do |v|
|
|
33
|
+
v.mkpath
|
|
34
|
+
paths = ::Rails.application.config.assets.paths
|
|
35
|
+
paths << v.to_s unless paths.include?(v.to_s)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
protected
|
|
40
|
+
|
|
41
|
+
# @return [Sprockets::Environment]
|
|
42
|
+
def environment # rubocop:disable Metrics/AbcSize
|
|
43
|
+
Sprockets::Environment.new.tap do |env|
|
|
44
|
+
env.register_transformer('text/scss', 'text/css', ::SassC::Rails::ScssTemplate.new)
|
|
45
|
+
env.register_transformer('text/sass', 'text/css', ::SassC::Rails::SassTemplate.new)
|
|
46
|
+
env.context_class.class_eval { include ::Sprockets::Rails::Context }
|
|
47
|
+
env.context_class.assets_prefix = ::Rails.application.config.assets.prefix
|
|
48
|
+
env.context_class.config = ::Rails.application.config.action_controller
|
|
49
|
+
source_paths.each { |path| env.append_path(path) }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @return [Pathname]
|
|
54
|
+
def self_assets_directory
|
|
55
|
+
__FILE__.to_pathname.dirname.dirname.dirname.join('app/assets')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Reuses the same load paths Propshaft already collected from every engine/gem
|
|
59
|
+
# (app/assets, lib/assets, vendor/assets) plus the ones "add_assets_paths" added for
|
|
60
|
+
# each Redmine plugin.
|
|
61
|
+
#
|
|
62
|
+
# @return [Enumerable<String>]
|
|
63
|
+
def source_paths
|
|
64
|
+
[self_assets_directory.join('stylesheets').to_path,
|
|
65
|
+
self_assets_directory.join('javascripts').to_path] +
|
|
66
|
+
::Rails.application.config.assets.paths
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: redmine_plugins_helper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.17.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- 0.
|
|
7
|
+
- 0.17.0
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: eac_rails_gem_support
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: '0.13'
|
|
20
20
|
- - ">="
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0.13.
|
|
22
|
+
version: 0.13.2
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +29,7 @@ dependencies:
|
|
|
29
29
|
version: '0.13'
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.13.
|
|
32
|
+
version: 0.13.2
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: eac_ruby_utils
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -71,19 +71,45 @@ dependencies:
|
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
72
|
version: 2.5.2
|
|
73
73
|
- !ruby/object:Gem::Dependency
|
|
74
|
-
name:
|
|
74
|
+
name: sassc-rails
|
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
|
76
76
|
requirements:
|
|
77
77
|
- - "~>"
|
|
78
78
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: '
|
|
79
|
+
version: '2.1'
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 2.1.2
|
|
80
83
|
type: :runtime
|
|
81
84
|
prerelease: false
|
|
82
85
|
version_requirements: !ruby/object:Gem::Requirement
|
|
83
86
|
requirements:
|
|
84
87
|
- - "~>"
|
|
85
88
|
- !ruby/object:Gem::Version
|
|
86
|
-
version: '
|
|
89
|
+
version: '2.1'
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: 2.1.2
|
|
93
|
+
- !ruby/object:Gem::Dependency
|
|
94
|
+
name: sprockets
|
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - "~>"
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '4.2'
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: 4.2.2
|
|
103
|
+
type: :runtime
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '4.2'
|
|
110
|
+
- - ">="
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: 4.2.2
|
|
87
113
|
description:
|
|
88
114
|
email:
|
|
89
115
|
executables: []
|
|
@@ -114,6 +140,7 @@ files:
|
|
|
114
140
|
- lib/redmine_plugins_helper/patches/redmine/plugin/initializers.rb
|
|
115
141
|
- lib/redmine_plugins_helper/patches/redmine/plugin_migration_context.rb
|
|
116
142
|
- lib/redmine_plugins_helper/patches/test_case_patch.rb
|
|
143
|
+
- lib/redmine_plugins_helper/plugins_autoload_assets.rb
|
|
117
144
|
- lib/redmine_plugins_helper/settings.rb
|
|
118
145
|
- lib/redmine_plugins_helper/status_migrations.rb
|
|
119
146
|
- lib/redmine_plugins_helper/test_config.rb
|