Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ ruby '3.3.4'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 7.2.1'

gem 'csv'

# Use postgresql as the database for Active Record
gem 'pg', '~> 1.1'

Expand All @@ -20,18 +18,6 @@ gem 'searchkick'
# Use the Puma web server [https://github.com/puma/puma]
gem 'puma', '~> 5.0'

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
# gem 'jbuilder'

# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem 'kredis'

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem 'bcrypt', '~> 3.1.7'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

Expand All @@ -48,6 +34,12 @@ gem 'administrate'
gem 'administrate-field-jsonb'
gem 'trix-rails', require: 'trix'

# administrate < 1.0 pulled these in transitively via sassc-rails; administrate 1.0
# bundles its own assets and dropped that dependency, but the app's own asset
# pipeline (app/assets/config/manifest.js) still relies on Sprockets/Sass directly.
gem 'sassc-rails'
gem 'sprockets-rails'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem 'debug', platforms: %i[mri mingw x64_mingw]
Expand All @@ -67,20 +59,17 @@ group :test do
# chromedriver binary itself (Selenium Manager) - no separate webdriver gem needed.
gem 'capybara'
gem 'selenium-webdriver'
# CDP support, needed for Selenium's driver.register(username:, password:) - used to
# authenticate admin system specs without embedding credentials in the visited URL.
gem 'selenium-devtools'
end

gem 'pundit', '~> 2.2'

gem 'kaminari', '~> 1.2'

gem 'jbuilder', '~> 2.11'

gem 'rspec_api_documentation', '~> 6.1'

gem 'acts-as-taggable-on', '~> 11.0.0'

gem 'administrate-field-acts_as_taggable'

gem 'administrate-field-list', '~> 0.0.6'

gem 'httparty', '~> 0.20.0'
Expand All @@ -95,8 +84,6 @@ gem 'active_record_doctor', '~> 1.10'

gem 'sidekiq', '>=7.2.2', '<8'

gem 'uuid', '~> 2.3'

gem 'addressable', '~> 2.8'

gem 'importmap-rails', '~> 2.0'
Expand Down
55 changes: 14 additions & 41 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,16 @@ GEM
zeitwerk (>= 2.4, < 3.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
administrate (0.20.1)
actionpack (>= 6.0, < 8.0)
actionview (>= 6.0, < 8.0)
activerecord (>= 6.0, < 8.0)
jquery-rails (~> 4.6.0)
administrate (1.0.0)
actionpack (>= 6.0, < 9.0)
actionview (>= 6.0, < 9.0)
activerecord (>= 6.0, < 9.0)
kaminari (~> 1.2.2)
sassc-rails (~> 2.1)
selectize-rails (~> 0.6)
administrate-field-active_storage (0.4.2)
administrate (>= 0.2.2)
rails (>= 7.0)
administrate-field-acts_as_taggable (0.0.4)
acts-as-taggable-on (>= 6.0)
administrate (< 1.0.0)
administrate-field-jsonb (0.4.6)
administrate (< 1.0.0)
administrate-field-jsonb (0.4.8)
administrate (< 2.0)
rails (>= 4.2)
administrate-field-list (0.0.6)
administrate
Expand Down Expand Up @@ -137,7 +131,6 @@ GEM
cronex (0.15.0)
tzinfo
unicode (>= 0.4.4.5)
csv (3.3.0)
date (3.3.4)
debug (1.9.2)
irb (~> 1.10)
Expand Down Expand Up @@ -205,10 +198,6 @@ GEM
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jmespath (1.6.2)
jquery-rails (4.6.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.7.2)
kaminari (1.2.2)
activesupport (>= 4.1.0)
Expand All @@ -227,8 +216,6 @@ GEM
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
Expand All @@ -246,7 +233,6 @@ GEM
multi_json (1.21.1)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
mustache (1.1.1)
namae (1.2.0)
racc (~> 1.7)
net-http (0.9.1)
Expand Down Expand Up @@ -284,8 +270,6 @@ GEM
public_suffix (6.0.1)
puma (5.6.8)
nio4r (~> 2.0)
pundit (2.4.0)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.8.1)
rack (2.2.9)
Expand Down Expand Up @@ -341,10 +325,6 @@ GEM
roo (2.10.1)
nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.2)
Expand All @@ -362,10 +342,6 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rspec_api_documentation (6.1.0)
activesupport (>= 3.0.0)
mustache (~> 1.0, >= 0.99.4)
rspec (~> 3.0)
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand Down Expand Up @@ -408,7 +384,8 @@ GEM
activemodel (>= 6.1)
hashie
securerandom (0.3.1)
selectize-rails (0.12.6)
selenium-devtools (0.151.0)
selenium-webdriver (~> 4.2)
selenium-webdriver (4.46.0)
base64 (~> 0.2)
logger (~> 1.4)
Expand All @@ -428,18 +405,18 @@ GEM
fugit (~> 1.8, >= 1.11.1)
globalid (>= 1.0.1)
sidekiq (>= 6.5.0)
sprockets (4.2.1)
sprockets (4.2.2)
concurrent-ruby (~> 1.0)
logger
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
stringio (3.1.1)
strscan (3.1.0)
systemu (2.6.5)
thor (1.3.1)
tilt (2.4.0)
tilt (2.8.0)
timeout (0.4.1)
trix-rails (2.4.0)
rails (> 4.1)
Expand All @@ -449,8 +426,6 @@ GEM
unicode-display_width (2.5.0)
uri (1.1.1)
useragent (0.16.10)
uuid (2.3.9)
macaddr (~> 1.0)
webrick (1.8.1)
websocket (1.2.11)
websocket-driver (0.7.6)
Expand Down Expand Up @@ -481,14 +456,12 @@ DEPENDENCIES
addressable (~> 2.8)
administrate
administrate-field-active_storage (~> 0.4.1)
administrate-field-acts_as_taggable
administrate-field-jsonb
administrate-field-list (~> 0.0.6)
aws-sdk-rails (~> 5.0)
aws-sdk-ses (~> 1.0)
bootsnap
capybara
csv
debug
elasticsearch (~> 8)
factory_bot_rails
Expand All @@ -501,25 +474,25 @@ DEPENDENCIES
namae (~> 1.1)
pg (~> 1.1)
puma (~> 5.0)
pundit (~> 2.2)
rack-cors
rails (~> 7.2.1)
roo (~> 2.9)
rspec-rails
rspec_api_documentation (~> 6.1)
rubocop
rubocop-factory_bot
rubocop-rails
rubocop-rspec
rubocop-rspec_rails
sassc-rails
searchkick
selenium-devtools
selenium-webdriver
shoulda-matchers
sidekiq (>= 7.2.2, < 8)
sidekiq-cron (~> 2.4.0)
sprockets-rails
trix-rails
tzinfo-data
uuid (~> 2.3)

RUBY VERSION
ruby 3.3.4p94
Expand Down
4 changes: 1 addition & 3 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
//= link_tree ../../../vendor/javascript .js
//= link administrate-field-jsonb/application.css
//= link administrate-field-jsonb/application.js
//= link administrate-field-taggable/application.js
//= link administrate-field-taggable/application.css
//= link acts_as_taggable_field.js
//= link administrate-field-active_storage/application.css
//= require selectize
//= require trix
// application.js
// application.css
Expand Down
20 changes: 20 additions & 0 deletions app/assets/javascripts/acts_as_taggable_field.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Selectize init for ActsAsTaggableField's text input, ported from the
// unmaintained administrate-field-acts_as_taggable gem's application.js.
$(function() {
$(".field-unit--acts-as-taggable-field .field-unit__field > input").each(function(elem) {
var $this = $(this);
var opts = $this.data('tag-options');

$this.selectize({
delimiter: ", ",
persist: false,
options: opts,
create: function(input) {
return {
value: input,
text: input
};
}
});
})
});
9 changes: 9 additions & 0 deletions app/assets/stylesheets/acts_as_taggable_field.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.taggable_field .tag {
text-align: center;
font-size: 0.85em;
margin: 0 3px 3px 0;
padding: 2px 6px;
background: #f2f2f2;
color: #303030;
border: 0 solid #d0d0d0;
}
2 changes: 0 additions & 2 deletions app/controllers/admin/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# you're free to overwrite the RESTful controller actions.
module Admin
class ApplicationController < Administrate::ApplicationController
# include Administrate::Punditize

before_action :authenticate_admin

before_action do
Expand Down
2 changes: 1 addition & 1 deletion app/dashboards/mention_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MentionDashboard < Administrate::BaseDashboard
id: Field::Number,
created_at: Field::DateTime,
updated_at: Field::DateTime,
tags: Field::ActsAsTaggable
tags: ActsAsTaggableField
}.freeze

# COLLECTION_ATTRIBUTES
Expand Down
56 changes: 56 additions & 0 deletions app/fields/acts_as_taggable_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

require 'administrate/field/text'
require 'administrate/engine'

# In-house replacement for the unmaintained administrate-field-acts_as_taggable gem
# (last released 2021, hard-pins `administrate < 1.0.0`). Behavior is ported as-is
# from that gem's lib/administrate/field/acts_as_taggable.rb.
class ActsAsTaggableField < Administrate::Field::Text
class Engine < ::Rails::Engine
if defined?(Administrate::Engine)
Administrate::Engine.add_javascript 'acts_as_taggable_field'
Administrate::Engine.add_stylesheet 'acts_as_taggable_field'
end
end

def context
options.fetch(:context, @attribute)
end

# acts_as_taggable_on exposes a `<context.singularize>_list` virtual attribute
# (e.g. `tag_list` for the `:tags` context) for reading/writing a comma-delimited
# tag string - this field operates on that attribute rather than the raw `tags`
# association.
def attribute
"#{super.to_s.singularize}_list"
end

def self.permitted_attribute(attr, **_opts)
"#{attr.to_s.singularize}_list"
end

def tags
data
end

def name
context.to_s
end

def delimited
tags.join(', ').to_s
end

def truncate
delimited[0...truncation_length]
end

def tag_options
return [] unless defined?(ActsAsTaggableOn::Tag)

ActsAsTaggableOn::Tag.for_context(context).order(:name).map do |t|
{ text: t.name, value: t.name }
end
end
end
11 changes: 6 additions & 5 deletions app/models/published_letter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class PublishedLetter < ApplicationRecord
has_many :letter_languages, foreign_key: 'letter_id', inverse_of: :letter, dependent: :destroy
has_many :languages, -> { distinct }, through: :letter_languages

belongs_to :letter_file, foreign_key: 'letter_id', inverse_of: :letter, optional: true
belongs_to :file_folder, foreign_key: 'letter_id', inverse_of: :letter, optional: true
belongs_to :letter_owner, foreign_key: 'letter_id', inverse_of: :letter, optional: true
belongs_to :letter_publisher, foreign_key: 'letter_id', inverse_of: :letter, optional: true
belongs_to :letter_file, foreign_key: 'letter_id', inverse_of: :letters, optional: true
belongs_to :file_folder, foreign_key: 'letter_id', inverse_of: :letters, optional: true
belongs_to :letter_owner, foreign_key: 'letter_id', inverse_of: :letters, optional: true
belongs_to :letter_publisher, foreign_key: 'letter_id', inverse_of: :letters, optional: true

def self.default_scope
where(published: true)
Expand All @@ -53,7 +53,8 @@ def search_data
repositories: repositories.select(&:published).map(&:label),
languages: languages.map(&:label),
published:,
volume: volume.to_s
volume: volume.to_s,
publisher: letter_publisher&.label
}
end

Expand Down
Loading
Loading