iqvoc_similar_terms 2.7.0 → 2.11.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +67 -0
  3. data/.gitignore +7 -0
  4. data/Gemfile +14 -15
  5. data/Gemfile.lock +483 -314
  6. data/README.md +5 -6
  7. data/app/assets/javascripts/manifest.js +2 -0
  8. data/app/assets/stylesheets/manifest.scss +3 -0
  9. data/app/controllers/similar_terms_controller.rb +27 -11
  10. data/app/models/services/similar_terms_service.rb +141 -0
  11. data/app/views/similar_terms/_form.html.erb +21 -0
  12. data/app/views/similar_terms/new.html.erb +21 -0
  13. data/app/views/similar_terms/show.html.erb +32 -28
  14. data/bin/bundle +3 -0
  15. data/bin/rails +3 -9
  16. data/bin/rake +3 -6
  17. data/bin/setup +33 -0
  18. data/bin/update +31 -0
  19. data/bin/yarn +17 -0
  20. data/config/application.rb +30 -48
  21. data/config/boot.rb +3 -5
  22. data/config/cable.yml +10 -0
  23. data/config/database.yml.postgresql +26 -0
  24. data/config/environment.rb +4 -4
  25. data/config/initializers/content_security_policy.rb +25 -0
  26. data/config/initializers/filter_parameter_logging.rb +8 -0
  27. data/config/initializers/inflections.rb +16 -0
  28. data/config/initializers/iqvoc.rb +5 -4
  29. data/config/initializers/new_framework_defaults_6_1.rb +67 -0
  30. data/config/initializers/permissions_policy.rb +11 -0
  31. data/config/locales/de.yml +6 -0
  32. data/config/locales/en.yml +6 -0
  33. data/config/routes.rb +2 -2
  34. data/config/storage.yml +34 -0
  35. data/config.ru +4 -2
  36. data/faucet.config.js +46 -0
  37. data/iqvoc_similar_terms.gemspec +1 -1
  38. data/lib/iqvoc/similar_terms/version.rb +1 -1
  39. data/lib/iqvoc/similar_terms.rb +12 -97
  40. data/lib/iqvoc_similar_terms.rb +1 -0
  41. data/package-lock.json +1486 -0
  42. data/package.json +29 -0
  43. data/test/concept_test.nt +5 -0
  44. data/test/concept_test.ttl +8 -1
  45. data/test/controllers/similar_terms_controller_test.rb +167 -0
  46. data/test/models/entity_resolution_test.rb +6 -6
  47. data/test/models/results_test.rb +43 -17
  48. metadata +31 -23
  49. data/.travis.yml +0 -30
  50. data/bin/spring +0 -18
  51. data/config/initializers/iqvoc_similiar_terms.rb +0 -1
  52. data/config/initializers/wrap_parameters.rb +0 -14
  53. data/test/controllers/api_test.rb +0 -58
  54. data/test/controllers/onebox_test.rb +0 -37
data/README.md CHANGED
@@ -1,17 +1,16 @@
1
- [![Build Status](https://travis-ci.org/innoq/iqvoc_similar_terms.svg?branch=master)](https://travis-ci.org/innoq/iqvoc_similar_terms)
1
+ # Similar terms for iQvoc
2
2
 
3
- Similar terms for iQvoc
3
+ ![CI](https://github.com/innoq/iqvoc_similar_terms/workflows/CI/badge.svg)
4
+
5
+ ## Getting Started
4
6
 
5
- Getting Started
6
- ===============
7
7
 
8
8
  1. Initialize database:
9
9
 
10
10
  $ bundle exec rake db:create
11
11
  $ bundle exec rake db:migrate iqvoc:db:seed_all
12
12
 
13
- Extensions
14
- ==========
13
+ ## Extensions
15
14
 
16
15
  In addition to regular SKOS, Similar Terms supports
17
16
  [SKOS-XL](https://github.com/innoq/iqvoc_skosxl) and
@@ -0,0 +1,2 @@
1
+ import '../../../node_modules/iqvoc/app/assets/javascripts/framework';
2
+ import '../../../node_modules/iqvoc/app/assets/javascripts/iqvoc/manifest';
@@ -0,0 +1,3 @@
1
+ @import 'iqvoc/app/assets/stylesheets/iqvoc/settings/manifest';
2
+ @import 'iqvoc/app/assets/stylesheets/framework';
3
+ @import 'iqvoc/app/assets/stylesheets/iqvoc/_manifest';
@@ -9,7 +9,7 @@ class SimilarTermsController < ApplicationController
9
9
  Returns labels which are semantically (not orthographically) similar,
10
10
  as determined by concept relations.
11
11
  DOC
12
- formats [:html, :ttl, :rdf]
12
+ formats [:html, :ttl, :rdf, :xml, :json]
13
13
  param :terms, String, :required => true, :desc => <<-DOC
14
14
  One or more terms (comma-separated, CSV-style) to be processed.
15
15
  DOC
@@ -21,25 +21,41 @@ class SimilarTermsController < ApplicationController
21
21
  skos:altLabel "Baumart"@de.
22
22
  DOC
23
23
 
24
- def show
24
+ def create
25
25
  authorize! :read, Iqvoc::Concept.base_class
26
26
 
27
- unless params[:terms]
28
- head 400 unless request.format.html? # non-GUI
29
- return
30
- end
31
-
32
- @terms = InlineDataHelper.parse_inline_values(params[:terms])
27
+ @terms = InlineDataHelper.parse_inline_values(similar_terms_params)
33
28
  lang = params[:lang]
29
+ options = {
30
+ synonyms_only: ['1', 'true'].include?(params[:synonyms_only])
31
+ }
34
32
 
35
33
  respond_to do |format|
36
34
  format.html do
37
- @results = Iqvoc::SimilarTerms.ranked(lang, *@terms)
35
+ @results = Services::SimilarTermsService.ranked(lang, options, *@terms)
36
+ render :show
38
37
  end
39
- format.any(:rdf, :ttl, :xml) do
40
- @results = Iqvoc::SimilarTerms.alphabetical(lang, *@terms)
38
+ format.any(:rdf, :ttl, :nt, :xml) do
39
+ @results = Services::SimilarTermsService.alphabetical(lang, options, *@terms)
40
+ render :show
41
41
  end
42
+ format.json {
43
+ results = Services::SimilarTermsService.alphabetical(lang, options, *@terms)
44
+ render json: {
45
+ "url": request.original_url,
46
+ "total_results": results.length,
47
+ "results": results.map {|c| c.value }
48
+ }.to_json
49
+ }
42
50
  end
43
51
  end
44
52
 
53
+ def new
54
+ end
55
+
56
+ private
57
+
58
+ def similar_terms_params
59
+ params.require(:terms)
60
+ end
45
61
  end
@@ -0,0 +1,141 @@
1
+ module Services
2
+ module SimilarTermsService # TODO: make language constraints optional
3
+
4
+ @@weightings = Iqvoc::SimilarTerms.weightings
5
+
6
+ # returns an array of label/concepts pairs, sorted descendingly by weighting -- XXX: unused/deprecated
7
+ # TODO: rename
8
+ def self.ranked(lang, options, *terms)
9
+ weighted(lang, options, *terms).sort_by { |label, _data| label }
10
+ .sort_by { |_label, data| data[0] }
11
+ .reverse
12
+ .map { |label, data| [label] + data[1..-1] } # drop weighting
13
+ end
14
+
15
+ # returns a list of labels, sorted alphabetically
16
+ def self.alphabetical(lang, options, *terms)
17
+ concepts = base_query(lang, *terms)
18
+
19
+ results = concepts.map { |c| c.labelings.map { |ln| ln.target } }
20
+
21
+ unless options[:synonyms_only]
22
+ results << find_related_and_narrower_concepts(concepts, lang, *terms).map { |c| c.pref_labels }
23
+ end
24
+
25
+ results.flatten.sort_by { |l| l.value }
26
+ end
27
+
28
+ def self.base_query(lang, *terms)
29
+ # FIXME: move to initializer to run on start/boot. Could be a problem with intializer load
30
+ # order of host app because further_labeling classes are initialised after this check
31
+ Iqvoc::Concept.labeling_class_names.each do |klass_name, langs|
32
+ unless @@weightings.keys.include? klass_name
33
+ raise "#{klass_name} has no registered weighting. Please configure one using Iqvoc::SimilarTerms.register_weighting('MyLabelingClass', 1.0)"
34
+ end
35
+ end
36
+
37
+ # use only labelings with weighting > 0
38
+ used_weightings = @@weightings.select { |klass_name, weight| weight > 0 }.keys
39
+ terms_to_concepts(lang, *terms)
40
+ .includes(:labelings => [:owner, :target])
41
+ .where('labels.language' => lang)
42
+ .where('labelings.type IN (?)', used_weightings)
43
+ end
44
+
45
+ # returns a hash of label/weighting+concepts pairs -- XXX: unused/deprecated
46
+ def self.weighted(lang, options, *terms) # TODO: rename
47
+ concepts = base_query(lang, *terms)
48
+
49
+ return terms.inject({}) do |memo, term|
50
+ concepts.each do |concept|
51
+ concept.labelings.each do |ln|
52
+ concept = ln.owner
53
+ label = ln.target
54
+ weight = @@weightings[ln.class.name]
55
+
56
+ memo[label] ||= []
57
+ # weighting
58
+ memo[label][0] ||= 0
59
+ memo[label][0] += weight
60
+ # associated concepts
61
+ memo[label] << concept unless memo[label].include? concept
62
+ end
63
+ end
64
+
65
+ unless options[:synonyms_only]
66
+ find_related_and_narrower_concepts(concepts, lang, *terms).each do |c|
67
+ memo[c.pref_label] ||= []
68
+ # weighting
69
+ memo[c.pref_label][0] ||= 0
70
+ memo[c.pref_label][0] += 1
71
+ # associated concepts
72
+ memo[c.pref_label] << c unless memo[c.pref_label].include? c
73
+ end
74
+ end
75
+
76
+ memo
77
+ end
78
+ end
79
+
80
+ def self.terms_to_concepts(lang, *terms)
81
+ concept_ids = terms_to_labels(lang, *terms)
82
+ .includes(:labelings)
83
+ .map { |label| label.labelings.map(&:owner_id) }.flatten.uniq
84
+
85
+ return Iqvoc::Concept.base_class.published.where(id: concept_ids)
86
+ end
87
+
88
+ def self.find_related_and_narrower_concepts(concepts, lang, *terms)
89
+ results = []
90
+ concepts.each do |c|
91
+ results << c.narrower_relations.published.map(&:target_id)
92
+ results << c.concept_relation_skos_relateds.published.map(&:target_id)
93
+ end
94
+
95
+ # evaluate only if iqvoc_compound_forms engine is loaded
96
+ if Iqvoc.const_defined?(:CompoundForms) && results.empty?
97
+ terms.each do |term|
98
+ label = if Iqvoc.const_defined?(:Inflectionals)
99
+ hash = Inflectional::Base.normalize(term)
100
+ label_id = Inflectional::Base.select([:label_id])
101
+ .where(:normal_hash => hash)
102
+ .map(&:label_id)
103
+ .first
104
+
105
+ Iqvoc::XLLabel.base_class.where(:language => lang, :id => label_id).first
106
+ else
107
+ Iqvoc::XLLabel.base_class.where('LOWER(value) = ?', term.downcase).first
108
+ end
109
+
110
+ results << label.compound_in.map { |ci| ci.concepts.map { |c| c.id } } if label.present?
111
+ end
112
+ end
113
+ Iqvoc::Concept.base_class.where(id: results.flatten.uniq)
114
+ end
115
+
116
+ # NB: case-insensitive only when inflectionals are available
117
+ def self.terms_to_labels(lang, *terms)
118
+ # efficiency enhancement to turn `IN` into `=` queries where possible
119
+ reduce = lambda { |arr| arr.length < 2 ? arr[0] : arr }
120
+
121
+ if Iqvoc.const_defined?(:Inflectionals)
122
+ # use normalized form for case-insensitivity (and performance)
123
+ hashes = terms.map { |term| Inflectional::Base.normalize(term) }
124
+ label_ids = Inflectional::Base.select([:label_id])
125
+ .where(normal_hash: reduce.call(hashes))
126
+ .map(&:label_id)
127
+
128
+ return Iqvoc::XLLabel.base_class.where(language: lang, id: reduce.call(label_ids))
129
+ elsif Iqvoc.const_defined?(:XLLabel)
130
+ return Iqvoc::XLLabel.base_class
131
+ .where(language: lang)
132
+ .where('LOWER(value) IN (?)', terms.map(&:downcase))
133
+ else
134
+ return Iqvoc::Label.base_class
135
+ .where(language: lang)
136
+ .where('LOWER(value) IN (?)', terms.map(&:downcase))
137
+ end
138
+ end
139
+
140
+ end
141
+ end
@@ -0,0 +1,21 @@
1
+ <%= bootstrap_form_tag(url: similar_url, method: :get) do |f| %>
2
+ <div class="p-3 row no-gutters align-items-center bg-white">
3
+ <div class="col-auto">
4
+ <i class="fa fa-search fa-lg"></i>
5
+ </div>
6
+ <div class="col">
7
+ <%= f.text_field :terms, hide_label: true, autofocus: (@terms ? false : true), wrapper_class: 'mb-0',
8
+ class: 'form-control-lg form-control-borderless border-0', autocomplete: 'off',
9
+ value: (@terms ? InlineDataHelper.generate_inline_values(@terms) : params[:terms])
10
+ %>
11
+ </div>
12
+ <div class="col-auto">
13
+ <%= f.submit t('txt.views.search_results.submit'), class: 'btn btn-block btn-lg btn-primary p-2' %>
14
+ </div>
15
+ </div>
16
+ <div class="py-3 row">
17
+ <div class="col-auto">
18
+ <%= f.check_box :synonyms_only, label: t('txt.views.similar_terms.synonyms_only'), checked: ['1', 'true'].include?(params[:synonyms_only]) %>
19
+ </div>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <div class="text-center my-5">
2
+ <h1 class="mb-5">
3
+ <%= t("txt.views.similar_terms.title") %>
4
+ </h1>
5
+
6
+ <div class="row justify-content-center">
7
+ <div class="col-12 col-md-10 col-lg-8">
8
+ <%= render 'form' %>
9
+ </div>
10
+ </div>
11
+ </div>
12
+
13
+ <div class="my-5">
14
+ <h2 class="text-center my-4">
15
+ <%= t("txt.views.similar_terms.about.title") %>
16
+ </h2>
17
+
18
+ <div class="row col-md-8 offset-md-2">
19
+ <%= simple_format t("txt.views.similar_terms.about.description") %>
20
+ </div>
21
+ </div>
@@ -1,32 +1,36 @@
1
- <%= page_header :title => t("txt.views.similar_terms.title") %>
1
+ <% if @results.any? %>
2
+ <h2 class="text-center my-5">
3
+ <%= raw t('txt.views.similar_terms.results', terms: @terms.join(', '), count: @results.size) %>
4
+ </h2>
2
5
 
3
- <% if @terms %>
4
- <%= sidebar do %>
5
- <%= sidebar_header t('txt.common.representations') %>
6
- <%= sidebar_item :icon => 'share', :text => 'HTML', :path => similar_path(:terms => params[:terms], :format => :html) %>
7
- <%= sidebar_item :icon => 'share', :text => 'RDF/XML', :path => similar_path(:terms => params[:terms], :format => :rdf) %>
8
- <%= sidebar_item :icon => 'share', :text => 'RDF/Turtle', :path => similar_path(:terms => params[:terms], :format => :ttl) %>
9
- <% end %>
10
- <% end %>
11
-
12
- <%= bootstrap_form_tag(:url => similar_path, :method => :get, :layout => :inline) do |f| %>
13
- <%= f.text_field :terms, :hide_label => true, :value => (@terms ?
14
- InlineDataHelper.generate_inline_values(@terms) :
15
- params[:terms]) %>
16
- <%= f.submit t('txt.views.search_results.submit'), :class => 'btn btn-primary' %>
17
- <% end %>
18
-
19
- <ol>
20
- <% (@results || []).each do |data|
21
- label = data[0]
22
- concepts = data[1..-1]
23
- %>
24
- <li>
25
- <%= label.value %>
26
- (<%= concepts.map do |concept|
6
+ <ol>
7
+ <% (@results || []).each do |data|
8
+ label = data[0]
9
+ concepts = data[1..-1]
10
+ %>
11
+ <li>
12
+ <%= label.value %>
13
+ (<%= concepts.map do |concept|
27
14
  origin = concept.origin
28
15
  link_to origin, rdf_url(origin, :format => nil, :lang => nil)
29
16
  end.join(", ").html_safe %>)
30
- </li>
31
- <% end %>
32
- </ol>
17
+ </li>
18
+ <% end %>
19
+ </ol>
20
+ <% else %>
21
+ <h2 class="text-center my-5">
22
+ <%= t('txt.views.similar_terms.no_results') %>
23
+ </h2>
24
+ <% end %>
25
+
26
+ <div class="text-center my-5">
27
+ <h1 class="mb-5">
28
+ <%= t("txt.views.similar_terms.title") %>
29
+ </h1>
30
+
31
+ <div class="row justify-content-center">
32
+ <div class="col-12 col-md-10 col-lg-8">
33
+ <%= render 'form' %>
34
+ </div>
35
+ </div>
36
+ </div>
data/bin/bundle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/bin/rails CHANGED
@@ -1,10 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- begin
3
- load File.expand_path("../spring", __FILE__)
4
- rescue LoadError
5
- end
6
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
7
-
8
- APP_PATH = File.expand_path('../../config/application', __FILE__)
9
- require File.expand_path('../../config/boot', __FILE__)
10
- require 'rails/commands'
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
data/bin/rake CHANGED
@@ -1,7 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- begin
3
- load File.expand_path("../spring", __FILE__)
4
- rescue LoadError
5
- end
6
- require 'bundler/setup'
7
- load Gem.bin_path('rake', 'rake')
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
data/bin/setup ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path("..", __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts "== Installing dependencies =="
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?("config/database.yml")
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! "bin/rails db:prepare"
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! "bin/rails log:clear tmp:clear"
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! "bin/rails restart"
33
+ end
data/bin/update ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a way to update your development environment automatically.
14
+ # Add necessary update steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ puts "\n== Updating database =="
24
+ system! 'bin/rails db:migrate'
25
+
26
+ puts "\n== Removing old logs and tempfiles =="
27
+ system! 'bin/rails log:clear tmp:clear'
28
+
29
+ puts "\n== Restarting application server =="
30
+ system! 'bin/rails restart'
31
+ end
data/bin/yarn ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
+ yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
5
+ select { |dir| File.expand_path(dir) != __dir__ }.
6
+ product(["yarn", "yarn.cmd", "yarn.ps1"]).
7
+ map { |dir, file| File.expand_path(file, dir) }.
8
+ find { |file| File.executable?(file) }
9
+
10
+ if yarn
11
+ exec yarn, *ARGV
12
+ else
13
+ $stderr.puts "Yarn executable was not detected in the system."
14
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
15
+ exit 1
16
+ end
17
+ end
@@ -1,56 +1,38 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- if defined?(Bundler)
6
- # If you precompile assets before deploying to production, use this line
7
- Bundler.require *Rails.groups(:assets => %w(development test))
8
- # If you want your assets lazily compiled in production, use this line
9
- # Bundler.require(:default, :assets, Rails.env)
10
- end
1
+ require_relative "boot"
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_model/railtie"
5
+ require "active_job/railtie"
6
+ require "active_record/railtie"
7
+ require "active_storage/engine"
8
+ require "action_controller/railtie"
9
+ require "action_mailer/railtie"
10
+ require "action_mailbox/engine"
11
+ require "action_text/engine"
12
+ require "action_view/railtie"
13
+ require "action_cable/engine"
14
+ # require "sprockets/railtie"
15
+ require "rails/test_unit/railtie"
16
+
17
+ # Require the gems listed in Gemfile, including any gems
18
+ # you've limited to :test, :development, or :production.
19
+ Bundler.require(*Rails.groups)
11
20
 
12
21
  module Iqvoc::SimilarTerms
13
22
  class Application < Rails::Application
23
+ # Initialize configuration defaults for originally generated Rails version.
24
+ config.load_defaults 7.0
25
+
26
+ # Configuration for the application, engines, and railties goes here.
27
+ #
28
+ # These settings can be overridden in specific environments using the files
29
+ # in config/environments, which are processed later.
30
+ #
31
+ # config.time_zone = "Central Time (US & Canada)"
32
+ # config.eager_load_paths << Rails.root.join("extras")
33
+ #
14
34
 
15
35
  # This tells iqvoc_similar_terms.rb whether it it runs as app or as engine
16
36
  require 'iqvoc_similar_terms'
17
-
18
- # Settings in config/environments/* take precedence over those specified here.
19
- # Application configuration should go into files in config/initializers
20
- # -- all .rb files in that directory are automatically loaded.
21
-
22
- # Custom directories with classes and modules you want to be autoloadable.
23
- # config.autoload_paths += %W(#{config.root}/extras)
24
-
25
- # Only load the plugins named here, in the order given (default is alphabetical).
26
- # :all can be used as a placeholder for all plugins not explicitly named.
27
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
28
-
29
- # Activate observers that should always be running.
30
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
31
-
32
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
33
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
34
- # config.time_zone = 'Central Time (US & Canada)'
35
-
36
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
37
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
38
- config.i18n.default_locale = :de
39
- # config.i18n.available_locales = [:de, :en]
40
-
41
- # Configure the default encoding used in templates for Ruby 1.9.
42
- config.encoding = "utf-8"
43
-
44
- # Configure sensitive parameters which will be filtered from the log file.
45
- config.filter_parameters += [:password, :password_confirmation]
46
-
47
- # Enable escaping HTML in JSON.
48
- config.active_support.escape_html_entities_in_json = true
49
-
50
- # Enable the asset pipeline
51
- config.assets.enabled = true
52
-
53
- # Version of your assets, change this if you want to expire all your assets
54
- config.assets.version = "1.0.0"
55
37
  end
56
38
  end
data/config/boot.rb CHANGED
@@ -1,6 +1,4 @@
1
- require 'rubygems'
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
2
 
3
- # Set up gems listed in the Gemfile.
4
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
-
6
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
data/config/cable.yml ADDED
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: test
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: iqvoc/similar_terms_production
@@ -0,0 +1,26 @@
1
+ development:
2
+ adapter: postgresql
3
+ host: localhost
4
+ encoding: unicode
5
+ database: <%= ENV["POSTGRES_DB"] || 'iqvoc_similar_terms_development' %>
6
+ pool: 5
7
+ username: <%= ENV["POSTGRES_USER"] || 'postgres' %>
8
+ password: <%= ENV["POSTGRES_PASSWORD"] || 'postgres' %>
9
+
10
+ test:
11
+ adapter: postgresql
12
+ host: localhost
13
+ encoding: unicode
14
+ database: <%= ENV["POSTGRES_DB"] || 'iqvoc_similar_terms_test' %>
15
+ pool: 5
16
+ username: <%= ENV["POSTGRES_USER"] || 'postgres' %>
17
+ password: <%= ENV["POSTGRES_PASSWORD"] || 'postgres' %>
18
+
19
+ production:
20
+ adapter: postgresql
21
+ host: localhost
22
+ encoding: unicode
23
+ database: <%= ENV["POSTGRES_DB"] || 'iqvoc_similar_terms_production' %>
24
+ pool: 5
25
+ username: <%= ENV["POSTGRES_USER"] || 'postgres' %>
26
+ password: <%= ENV["POSTGRES_PASSWORD"] || 'postgres' %>
@@ -1,5 +1,5 @@
1
- # Load the Rails application
2
- require File.expand_path('../application', __FILE__)
1
+ # Load the Rails application.
2
+ require_relative "application"
3
3
 
4
- # Initialize the Rails application
5
- Iqvoc::SimilarTerms::Application.initialize!
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,25 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide content security policy.
4
+ # See the Securing Rails Applications Guide for more information:
5
+ # https://guides.rubyonrails.org/security.html#content-security-policy-header
6
+
7
+ # Rails.application.configure do
8
+ # config.content_security_policy do |policy|
9
+ # policy.default_src :self, :https
10
+ # policy.font_src :self, :https, :data
11
+ # policy.img_src :self, :https, :data
12
+ # policy.object_src :none
13
+ # policy.script_src :self, :https
14
+ # policy.style_src :self, :https
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+ #
19
+ # # Generate session nonces for permitted importmap and inline scripts
20
+ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21
+ # config.content_security_policy_nonce_directives = %w(script-src)
22
+ #
23
+ # # Report violations without enforcing the policy.
24
+ # # config.content_security_policy_report_only = true
25
+ # end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4
+ # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5
+ # notations and behaviors.
6
+ Rails.application.config.filter_parameters += [
7
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8
+ ]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, "\\1en"
8
+ # inflect.singular /^(ox)en/i, "\\1"
9
+ # inflect.irregular "person", "people"
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym "RESTful"
16
+ # end