lib/iqvoc/configuration/core.rb in iqvoc-4.3.3 vs lib/iqvoc/configuration/core.rb in iqvoc-4.4.0
- old
+ new
@@ -6,19 +6,23 @@
extend ActiveSupport::Concern
included do
mattr_accessor :searchable_class_names,
:unlimited_search_results,
+ :default_rdf_namespace_helper_modules,
:default_rdf_namespace_helper_methods,
:rdf_namespaces,
:change_note_class_name,
:first_level_class_configuration_modules,
:navigation_items,
:ability_class_name,
:localized_routes,
:core_assets,
- :search_sections
+ :search_sections,
+ :export_path,
+ :upload_path,
+ :truncation_blacklist
self.localized_routes = [] # routing extensibility hook
self.core_assets = %w(
manifest.css
@@ -37,132 +41,122 @@
*.woff
*.eof
)
self.navigation_items = [{
- :text => "Dashboard",
- :href => proc { dashboard_path },
- :controller => "dashboard",
+ text: 'Dashboard',
+ href: proc { dashboard_path },
+ controller: 'dashboard',
:authorized? => proc { can? :use, :dashboard }
}, {
- :text => "Scheme",
- :href => proc { scheme_path },
- :controller => "concepts/scheme",
+ text: 'Scheme',
+ href: proc { scheme_path },
+ controller: 'concepts/scheme',
:authorized? => proc { can? :read, Iqvoc::Concept.root_class.instance }
}, {
- :text => proc { ::Concept::Base.model_name.human(:count => 2) },
- :href => proc { hierarchical_concepts_path },
- :controller => "concepts/hierarchical",
+ text: proc { ::Concept::Base.model_name.human(count: 2) },
+ href: proc { hierarchical_concepts_path },
+ controller: 'concepts/hierarchical',
:active? => proc {
%w(concepts/hierarchical concepts/alphabetical concepts/untranslated).
include?(params[:controller])
}
}, {
- :text => proc { t("txt.views.navigation.collections") },
- :href => proc { collections_path },
- :controller => "collections"
+ text: proc { t('txt.views.navigation.collections') },
+ href: proc { collections_path },
+ controller: 'collections'
}, {
- :text => proc { t("txt.views.navigation.search") },
- :href => proc { search_path },
- :controller => "search_results"
+ text: proc { t('txt.views.navigation.search') },
+ href: proc { search_path },
+ controller: 'search_results'
}, {
- :text => proc { t("txt.views.navigation.administration") },
+ text: proc { t('txt.views.navigation.administration') },
:authorized? => proc { can? :use, :administration },
- :items => [{
- :text => proc { t("txt.views.navigation.users") },
- :href => proc { users_path },
- :controller => "users",
+ items: [{
+ text: proc { t('txt.views.navigation.users') },
+ href: proc { users_path },
+ controller: 'users',
:authorized? => proc { can? :manage, User }
}, {
- :text => proc { t("txt.views.navigation.instance_configuration") },
- :href => proc { instance_configuration_path },
- :controller => "instance_configuration",
+ text: proc { t('txt.views.navigation.instance_configuration') },
+ href: proc { instance_configuration_path },
+ controller: 'instance_configuration',
:authorized? => proc { can? :manage, Iqvoc.config }
}]
}, {
- :text => proc { t("txt.views.navigation.help") },
- :items => [{
- :text => proc { t("txt.views.navigation.help") },
- :href => proc { help_path },
- :controller => "pages",
- :action => "help",
+ text: proc { t('txt.views.navigation.help') },
+ items: [{
+ text: proc { t('txt.views.navigation.help') },
+ href: proc { help_path },
+ controller: 'pages',
+ action: 'help',
:authorized? => proc { can? :read, :help }
}, {
- :text => proc { t("txt.views.navigation.about") },
- :href => "http://iqvoc.net/"
+ text: proc { t('txt.views.navigation.about') },
+ href: 'http://iqvoc.net/'
}]
}]
self.searchable_class_names = {
- "Labeling::SKOS::Base" => "labels",
- "Labeling::SKOS::PrefLabel" => "pref_labels",
- "Note::Base" => "notes"
+ 'Labeling::SKOS::Base' => 'labels',
+ 'Labeling::SKOS::PrefLabel' => 'pref_labels',
+ 'Note::Base' => 'notes'
}
self.unlimited_search_results = false
+ self.default_rdf_namespace_helper_modules = []
self.default_rdf_namespace_helper_methods = [:iqvoc_default_rdf_namespaces]
self.rdf_namespaces = {
- :rdf => "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
- :rdfs => "http://www.w3.org/2000/01/rdf-schema#",
- :owl => "http://www.w3.org/2002/07/owl#",
- :skos => "http://www.w3.org/2004/02/skos/core#",
- :dct => "http://purl.org/dc/terms/",
- :foaf => "http://xmlns.com/foaf/spec/",
- :void => "http://rdfs.org/ns/void#",
- :iqvoc => "http://try.iqvoc.net/schema#"
+ rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+ rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
+ owl: 'http://www.w3.org/2002/07/owl#',
+ skos: 'http://www.w3.org/2004/02/skos/core#',
+ dct: 'http://purl.org/dc/terms/',
+ foaf: 'http://xmlns.com/foaf/spec/',
+ void: 'http://rdfs.org/ns/void#',
+ iqvoc: 'http://try.iqvoc.net/schema#'
}
# The class to use for automatic generation of change notes on every save
- self.change_note_class_name = "Note::SKOS::ChangeNote"
+ self.change_note_class_name = 'Note::SKOS::ChangeNote'
self.first_level_class_configuration_modules = [] # Will be set in the modules
- self.ability_class_name = "Iqvoc::Ability"
+ self.ability_class_name = 'Iqvoc::Ability'
self.search_sections = [
- "klass",
- "mode",
- "terms",
- "type",
- "collection",
- "languages",
- "datasets"
+ 'klass',
+ 'mode',
+ 'terms',
+ 'type',
+ 'collection',
+ 'languages',
+ 'datasets'
]
+ # ignored database tables during thesaurus truncation
+ self.truncation_blacklist = [
+ 'schema_migrations',
+ 'users',
+ 'exports',
+ 'imports'
+ ]
+
# initialize
self.config.register_settings({
- "title" => "iQvoc",
- "languages.pref_labeling" => ["en", "de"],
- "languages.further_labelings.Labeling::SKOS::AltLabel" => ["en", "de"],
- "languages.notes" => ["en", "de"],
- "performance.unbounded_hierarchy" => false,
- "sources.iqvoc" => [""]
+ 'title' => 'iQvoc',
+ 'languages.pref_labeling' => ['en', 'de'],
+ 'languages.further_labelings.Labeling::SKOS::AltLabel' => ['en', 'de'],
+ 'languages.notes' => ['en', 'de'],
+ 'performance.unbounded_hierarchy' => false,
+ 'sources.iqvoc' => ['']
})
end
module ClassMethods
- def generate_secret_token
- require 'securerandom'
-
- template = Rails.root.join("config", "initializers", "secret_token.rb.template")
- raise "File not found: #{template}" unless File.exist?(template)
-
- file_name = "config/initializers/secret_token.rb"
-
- token = SecureRandom.hex(64)
- txt = File.read(template)
- txt.gsub!("S-E-C-R-E-T", token)
-
- File.open(file_name, "w") do |f|
- f.write txt
- end
-
- puts "Secret token configuration has been created in #{file_name}."
- end
-
# ************** instance configuration **************
def config(&block)
cfg = InstanceConfiguration.instance
if block
@@ -187,15 +181,15 @@
def ability_class
ability_class_name.constantize
end
def title
- config["title"]
+ config['title']
end
def note_languages
- config["languages.notes"]
+ config['languages.notes']
end
# returns a list of all languages selectable for labels and/or notes
def all_languages
(Iqvoc::Concept.pref_labeling_languages +
@@ -203,21 +197,27 @@
note_languages).compact.map(&:to_s).uniq
end
# @deprecated
def title=(value)
- ActiveSupport::Deprecation.warn "title has been moved into instance configuration", caller
- self.config.register_setting("title", value)
+ ActiveSupport::Deprecation.warn 'title has been moved into instance configuration', caller
+ self.config.register_setting('title', value)
end
def root
if Iqvoc.const_defined?(:Engine)
Iqvoc::Engine.root
else
Rails.root
end
end
- end
+ def routing_constraint
+ lambda do |params, req|
+ langs = Iqvoc::Concept.pref_labeling_languages.join('|').presence || 'en'
+ return params[:lang].to_s =~ /^#{langs}$/
+ end
+ end
+ end
end
end
end