Skip to content

Commit

Permalink
remove chemotion rails plugin
Browse files Browse the repository at this point in the history
The use of chemotion plugins has been deprecated

TODO clean js
  • Loading branch information
PiTrem committed Sep 23, 2022
1 parent 30f8730 commit 5f66840
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 95 deletions.
8 changes: 0 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,3 @@ group :test do
gem 'webmock'
end

# gem 'nmr_sim', git: 'https://github.com/ComPlat/nmr_sim', ref: 'e2f91776aafd8eb1fa9d88c8ec2291b02201f222', group: [:plugins,:development, :test, :production]

# Chemotion plugins: list your ELN specific plugin gems in the Gemfile.plugin
eln_plugin = File.join(File.dirname(__FILE__), "Gemfile.plugin")
if File.exists?(eln_plugin)
eval_gemfile eln_plugin
end

7 changes: 0 additions & 7 deletions Gemfile.plugin.example

This file was deleted.

80 changes: 0 additions & 80 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,86 +30,6 @@ class Application < Rails::Application

config.active_job.queue_adapter = :delayed_job

# Chemotion Plugin configuration

# list of registered plugins (from the plugins group of the Gemfile):
PLUGS = Bundler.load.current_dependencies.select do |dep|
dep.groups.include?(:plugins)
end.map(&:name)

config.before_configuration do
## TODO fix this for ELN pugin
# For each registered plugin gem (group :plugins in Gemfile) browserify needs to find
# an aliasifyConfig.js file (and a package.json file ) in gem root directory.
# This create a sym link if no file exists.
node_modules_dir = File.join(Rails.root, 'node_modules')
PLUGS.each_with_index do |plugin, _|
plugin_path = File.join(Gem.loaded_specs[plugin].full_gem_path, '.').to_s
plugin_node_modules = File.join(plugin_path, 'node_modules')
`rm #{plugin_node_modules}` if File.exist?(plugin_node_modules)
`ln -s #{node_modules_dir} #{plugin_node_modules}`
pack_path = Rails.root.join('package.json')
plugin_pack_path = File.join(plugin_path, 'package.json')
`rm #{plugin_pack_path}` if File.exist?(plugin_pack_path)
`ln -s #{pack_path} #{plugin_pack_path}`
end

# Extra module import/export mapping for each registered plugin
# extra_dir = Rails.root.join('app', 'assets', 'javascripts', 'components', 'extra')
extra_dir = Rails.root.join('app', 'packs', 'src', 'components', 'extra')
!File.directory?(extra_dir) && FileUtils.mkdir_p(extra_dir)

module_config_json = JSON.parse(File.read(Rails.root.join('config', 'module_config.json')))
PLUGS.each_with_index do |plugin, _|
module_config_file_json = File.join(Gem.loaded_specs[plugin].full_gem_path, 'config', 'module_config.json')
File.exist?(module_config_file_json) && JSON.parse(File.read(module_config_file_json)).each do |main_comp, extra_comps|
next unless module_config_json.key?(main_comp) # || module_config.has_key?(main_comp.to_sym)

extra_comps.presence&.each do |extra_comp, plug_comps|
if module_config_json[main_comp].key?(extra_comp)
module_config_json[main_comp][extra_comp][plugin] ||= plug_comps
end
end
end
end

module_config_json.each do |jsmodule, hooks|
hooks.each do |hook, plugins|
i = 0
x_imp_exp_file = File.join(extra_dir, jsmodule.to_s.strip + 'X' + hook.to_s.strip + '.js')
x_import ||= ''
x_export ||= "export default {\n"
prototype = plugins['prototype']
if prototype
(plugins.keys - ['prototype']).each do |plugin_name|
plugin_modules = plugins[plugin_name]
plugin_modules.each do |_, plugin_module|
prototype.each do |k, default_value|
if plugin_module[k]
x_import << "import %s%i from 'lib%s/%s';\n" % [k, i, plugin_name.classify, plugin_module[k]]
x_export << " %s%i : %s%i,\n" % [k, i, k, i]
else
x_export << " %s%i : %s,\n" % [k, i, default_value]
end
end
i += 1
end
end
else
plugins.each do |plugin_name, plugin_modules|
plugin_modules.each do |_, plugin_module|
x_import << "import content%i from 'lib%s/%s';\n" % [i, plugin_name.classify, plugin_module['content']]
x_export << " content%i : content%i,\n" % [i, i]
i += 1
end
end
end
x_export << " count : %i,\n}" % [i]
File.write(x_imp_exp_file, x_import + x_export)
end
end
end

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
Expand Down

0 comments on commit 5f66840

Please sign in to comment.