Skip to content

Commit

Permalink
Rails 7.1 (#72)
Browse files Browse the repository at this point in the history
* rails 7.1
* fix module loading issues
* adapt iqvoc changes
* drop custom inflections and stick to rails zeitwerk defaults
  • Loading branch information
mjansing authored Feb 17, 2025
1 parent 8cadc17 commit f325ea3
Show file tree
Hide file tree
Showing 61 changed files with 1,053 additions and 228 deletions.
558 changes: 558 additions & 0 deletions Gemfile.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
![CI](https://github.com/innoq/iqvoc_skosxl/workflows/CI/badge.svg)

# Iqvoc::SKOSXL
# Iqvoc::Skosxl

This is the iQvoc SKOS-XL extension. Use this in your Gemfile to add SKOS-XL features to iQvoc.

Iqvoc::SKOSXL may run in two different modes: Standalone as Application and embedded into another Application as Engine.
Iqvoc::Skosxl may run in two different modes: Standalone as Application and embedded into another Application as Engine.

## Standalone Application

Operate Iqvoc::SKOSXL like a common iQvoc-based Application.
Operate Iqvoc::Skosxl like a common iQvoc-based Application.

1. Run database migrations:
`rake iqvoc:db:migrate_all`
Expand All @@ -19,7 +19,7 @@ Operate Iqvoc::SKOSXL like a common iQvoc-based Application.

## Engine

Operate Iqvoc::SKOSXL and Iqvoc as Engines running in a custom App.
Operate Iqvoc::Skosxl and Iqvoc as Engines running in a custom App.

1. Add iqvoc_skosxl to your Gemfile (beneath iqvoc)
2. Run Iqvoc migrations:
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require File.expand_path('../config/application', __FILE__)
require 'rake'

Iqvoc::SKOSXL::Application.load_tasks
Iqvoc::Skosxl::Application.load_tasks

require 'bundler'
Bundler::GemHelper.install_tasks
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/labels/versions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Labels::VersionsController < ApplicationController
def merge
current_label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).published.last
new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last!
current_label = Iqvoc::Xllabel.base_class.by_origin(params[:origin]).published.last
new_version = Iqvoc::Xllabel.base_class.by_origin(params[:origin]).unpublished.last!

authorize! :merge, new_version

Expand Down Expand Up @@ -39,9 +39,9 @@ def merge
end

def branch
current_label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).published.last!
current_label = Iqvoc::Xllabel.base_class.by_origin(params[:origin]).published.last!

if draft_label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
if draft_label = Iqvoc::Xllabel.base_class.by_origin(params[:origin]).unpublished.last
flash[:info] = t('txt.controllers.versioning.branch_error')
redirect_to label_path(published: 0, id: draft_label)
else
Expand All @@ -66,7 +66,7 @@ def branch
end

def consistency_check
label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last!
label = Iqvoc::Xllabel.base_class.by_origin(params[:origin]).unpublished.last!

authorize! :check_consistency, label

Expand All @@ -80,7 +80,7 @@ def consistency_check
end

def to_review
label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last!
label = Iqvoc::Xllabel.base_class.by_origin(params[:origin]).unpublished.last!

authorize! :send_to_review, label

Expand Down
40 changes: 20 additions & 20 deletions app/controllers/labels_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ class LabelsController < ApplicationController
before_action proc { |ctrl| (ctrl.action_has_layout = false) if ctrl.request.xhr? }

def index
authorize! :read, Iqvoc::XLLabel.base_class
authorize! :read, Iqvoc::Xllabel.base_class

search_string = search_string(params[:query], params[:mode])
scope = Iqvoc::XLLabel.base_class
scope = Iqvoc::Xllabel.base_class
.editor_selectable
.by_query_value(search_string)

if params[:language] # NB: this is not the same as :lang, which is supplied via route
scope = scope.by_language(params[:language])
end
@labels = scope.order(Arel.sql("LENGTH(#{Iqvoc::XLLabel.base_class.table_name}.value)")).all
@labels = scope.order(Arel.sql("LENGTH(#{Iqvoc::Xllabel.base_class.table_name}.value)")).all

respond_to do |format|
format.html do
Expand All @@ -36,12 +36,12 @@ def index
end

def show
scope = Iqvoc::XLLabel.base_class.by_origin(params[:id]).with_associations
scope = Iqvoc::Xllabel.base_class.by_origin(params[:id]).with_associations

@published = params[:published] == '1' || !params[:published]
if @published
scope = scope.published
@new_label_version = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
@new_label_version = Iqvoc::Xllabel.base_class.by_origin(params[:id]).unpublished.last
else
scope = scope.unpublished
end
Expand All @@ -59,16 +59,16 @@ def show
end

def new
authorize! :create, Iqvoc::XLLabel.base_class
@label = Iqvoc::XLLabel.base_class.new
authorize! :create, Iqvoc::Xllabel.base_class
@label = Iqvoc::Xllabel.base_class.new
@label.build_initial_change_note(current_user)
@label.build_notes
end

def create
authorize! :create, Iqvoc::XLLabel.base_class
authorize! :create, Iqvoc::Xllabel.base_class

@label = Iqvoc::XLLabel.base_class.new(label_params)
@label = Iqvoc::Xllabel.base_class.new(label_params)

if @label.valid?
if @label.save
Expand All @@ -85,7 +85,7 @@ def create
end

def edit
@label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last!
@label = Iqvoc::Xllabel.base_class.by_origin(params[:id]).unpublished.last!
authorize! :update, @label

if params[:check_associations_in_editing_mode]
Expand All @@ -103,7 +103,7 @@ def edit
end

def update
@label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last!
@label = Iqvoc::Xllabel.base_class.by_origin(params[:id]).unpublished.last!
authorize! :update, @label

# set to_review to false if someone edits a label
Expand All @@ -123,11 +123,11 @@ def update
end

def destroy
@new_label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last!
@new_label = Iqvoc::Xllabel.base_class.by_origin(params[:id]).unpublished.last!
authorize! :destroy, @new_label

if @new_label.destroy
published_label = Iqvoc::XLLabel.base_class.published.by_origin(@new_label.origin).first
published_label = Iqvoc::Xllabel.base_class.published.by_origin(@new_label.origin).first
flash[:success] = I18n.t('txt.controllers.label_versions.delete')
redirect_to published_label.present? ? label_path(id: published_label.origin) : dashboard_path
else
Expand All @@ -137,9 +137,9 @@ def destroy
end

def duplicate
authorize! :create, Iqvoc::XLLabel.base_class
label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).published.first
if Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
authorize! :create, Iqvoc::Xllabel.base_class
label = Iqvoc::Xllabel.base_class.by_origin(params[:origin]).published.first
if Iqvoc::Xllabel.base_class.by_origin(params[:origin]).unpublished.last
flash[:error] = t('txt.controllers.label.duplicate_error')
redirect_to label_path(published: 1, id: label)
end
Expand All @@ -149,8 +149,8 @@ def duplicate
end

def new_from_concept
authorize! :create, Iqvoc::XLLabel.base_class
@label = Iqvoc::XLLabel.base_class.new
authorize! :create, Iqvoc::Xllabel.base_class
@label = Iqvoc::Xllabel.base_class.new

respond_to do |format|
format.html do
Expand All @@ -160,9 +160,9 @@ def new_from_concept
end

def create_from_concept
authorize! :create, Iqvoc::XLLabel.base_class
authorize! :create, Iqvoc::Xllabel.base_class

@label = Iqvoc::XLLabel.base_class.new(label_params)
@label = Iqvoc::Xllabel.base_class.new(label_params)
@label.build_initial_change_note(current_user)

if @label.save
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/rdf_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# TODO: move out of /controllers
module RdfControllerLabelExtension
def show
scope = params[:published] == '0' ? Iqvoc::XLLabel.base_class.unpublished : Iqvoc::XLLabel.base_class.published
scope = params[:published] == '0' ? Iqvoc::Xllabel.base_class.unpublished : Iqvoc::Xllabel.base_class.published
if @label = scope.by_origin(params[:id]).with_associations.last
respond_to do |format|
format.html {
Expand All @@ -20,4 +20,4 @@ def show
end
end

RdfController.prepend(RdfControllerLabelExtension)
RdfController.prepend(RdfControllerLabelExtension)
4 changes: 2 additions & 2 deletions app/controllers/xl_dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class XlDashboardController < DashboardController
def label_index
authorize! :use, :dashboard

labels = Iqvoc::XLLabel.base_class.for_dashboard.load
labels = Iqvoc::Xllabel.base_class.for_dashboard.load

if params[:sort] && params[:sort].include?('state ')
sort = params[:sort].split(',').select { |s| s.include? 'state ' }.last.gsub('state ', '')
Expand All @@ -37,7 +37,7 @@ def label_index

@items = Kaminari.paginate_array(labels).page(params[:page])

render 'dashboard/index', locals: { active_class: Iqvoc::XLLabel.base_class }
render 'dashboard/index', locals: { active_class: Iqvoc::Xllabel.base_class }
end

end
2 changes: 1 addition & 1 deletion app/helpers/iqvoc_skosxl_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module IqvocSkosxlHelper
def render_label(label)
if label.new_record?
'-'
elsif label.is_a?(Label::SKOSXL::Base)
elsif label.is_a?(Label::Skosxl::Base)
link_to(label.to_s, label_path(id: label))
else
label.to_s
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/labels_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def render_label_rdf(document, label)
end
end

Iqvoc::XLLabel.additional_association_class_names.keys.each do |class_name|
Iqvoc::Xllabel.additional_association_class_names.keys.each do |class_name|
label.send(class_name.to_relation_name).each do |additional_object|
additional_object.build_rdf(document, c)
end
Expand All @@ -43,15 +43,15 @@ def label_view_data(label)
render_label_association(res, label, labeling_class)
end

Iqvoc::XLLabel.relation_classes.each do |relation_class|
Iqvoc::Xllabel.relation_classes.each do |relation_class|
render_label_association(res, label, relation_class)
end

Iqvoc::XLLabel.note_classes.each do |note_class|
Iqvoc::Xllabel.note_classes.each do |note_class|
render_label_association(res, label, note_class)
end

Iqvoc::XLLabel.additional_association_classes.keys.each do |assoc_class|
Iqvoc::Xllabel.additional_association_classes.keys.each do |assoc_class|
render_label_association(res, label, assoc_class)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/collection/skosxl/extension.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Collection
module SKOSXL
module Skosxl
module Extension
extend ActiveSupport::Concern

Expand Down
6 changes: 3 additions & 3 deletions app/models/concept/skosxl/extension.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Concept
module SKOSXL
module Skosxl
module Extension
extend ActiveSupport::Concern

Expand All @@ -22,7 +22,7 @@ module Extension
split(InlineDataHelper::SPLITTER).map(&:squish)

# Iterate over all labels to be added and create them
Iqvoc::XLLabel.base_class.by_origin(new_origins).each do |l|
Iqvoc::Xllabel.base_class.by_origin(new_origins).each do |l|
concept.send(labeling_relation_name).create!(target: l)
end
end
Expand All @@ -46,7 +46,7 @@ def valid_label_language
(@labelings_by_id || {}).each { |labeling_class_name, origin_mappings|
origin_mappings.each { |language, new_origins|
new_origins = new_origins.split(InlineDataHelper::SPLITTER)
Iqvoc::XLLabel.base_class.by_origin(new_origins).published.each do |label|
Iqvoc::Xllabel.base_class.by_origin(new_origins).published.each do |label|
if label.language != language.to_s
errors.add(:base,
I18n.t('txt.controllers.versioned_concept.label_error') % label)
Expand Down
4 changes: 2 additions & 2 deletions app/models/label/relation/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def self.by_range_origin(origin)
end

def self.range_editor_selectable
# includes(:range) & Iqvoc::XLLabel.base_class.editor_selectable
# includes(:range) & Iqvoc::Xllabel.base_class.editor_selectable
# Doesn't work correctly (kills label_relations.type condition :-( )
includes(:range).
where('labels.published_at IS NOT NULL OR (labels.published_at IS NULL AND labels.published_version_id IS NULL) ')
end

def self.range_in_edit_mode
joins(:range).references(:labels).merge(Iqvoc::XLLabel.base_class.unpublished)
joins(:range).references(:labels).merge(Iqvoc::Xllabel.base_class.unpublished)
end

def self.view_section(obj)
Expand Down
6 changes: 3 additions & 3 deletions app/models/label/relation/skosxl/base.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class Label::Relation::SKOSXL::Base < Label::Relation::Base
class Label::Relation::Skosxl::Base < Label::Relation::Base
self.rdf_namespace = 'skosxl'

def self.build_from_rdf(subject, predicate, object)
create(domain: subject, range: object)
end

def build_rdf(document, subject)
pred = self.class == Label::Relation::SKOSXL::Base ? :labelRelation : self.rdf_predicate
raise "Match::SKOS::Base#build_rdf: Class #{self.class.name} needs to define self.rdf_namespace and self.rdf_predicate." unless pred
pred = self.class == Label::Relation::Skosxl::Base ? :labelRelation : self.rdf_predicate
raise "Match::Skos::Base#build_rdf: Class #{self.class.name} needs to define self.rdf_namespace and self.rdf_predicate." unless pred

subject.send(self.rdf_namespace.camelcase).send(pred, IqRdf.build_uri(range.origin))
end
Expand Down
Loading

0 comments on commit f325ea3

Please sign in to comment.