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
15 changes: 3 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,10 @@ jobs:
# Lint

- name: Run RuboCop
shell: bash
continue-on-error: true
run: |
bundle exec rubocop --format github | sed 's/::error/::warning/g'
run: bundle exec rubocop

- name: Run ESLint in pageflow package
shell: bash
continue-on-error: true
run: |
yarn --cwd package lint . --format @jamesacarr/github-actions
run: yarn --cwd package lint .

- name: Run ESLint in pageflow-scrolled
shell: bash
continue-on-error: true
run: |
yarn --cwd entry_types/scrolled/package lint . --format @jamesacarr/github-actions
run: yarn --cwd entry_types/scrolled/package lint .
12 changes: 6 additions & 6 deletions admins/pageflow/accounts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module Pageflow
account.memberships.size if authorized?(:read, account)
end
account_memberships = current_user.memberships.on_accounts
account_roles = account_memberships.each_with_object({}) do |membership, roles|
roles[membership.entity_id] = membership.role
account_roles = account_memberships.to_h do |membership|
[membership.entity_id, membership.role]
end
if authorized?(:see_own_role_on, :accounts)
column :own_role do |account|
Expand All @@ -43,16 +43,16 @@ module Pageflow
searchable_select_options(text_attribute: :name,
scope: lambda do
Account
.accessible_by(current_ability, :read)
.order(:name)
.accessible_by(current_ability, :read)
.order(:name)
end)

searchable_select_options(name: :member_addable,
text_attribute: :name,
scope: lambda do
AccountPolicy::Scope.new(current_user, Account)
.member_addable
.order(:name)
.member_addable
.order(:name)
end)

form partial: 'form'
Expand Down
14 changes: 7 additions & 7 deletions admins/pageflow/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ module Pageflow
text_attribute: :name,
scope: lambda do
AccountPolicy::Scope
.new(current_user, Account)
.entry_movable
.order(:name)
.new(current_user, Account)
.entry_movable
.order(:name)
end)

searchable_select_options(name: :eligible_sites,
text_attribute: :name_with_account_prefix,
scope: lambda do |params|
account = Account.find(params[:account_id])
SitePolicy::Scope
.new(current_user, Site)
.sites_allowed_for(account)
.new(current_user, Site)
.sites_allowed_for(account)
end,
filter: lambda do |term, scope|
scope.ransack(account_name_cont: term).result
Expand Down Expand Up @@ -318,7 +318,7 @@ def site_policy_scope
end

# rubocop:todo Metrics/PerceivedComplexity
def permitted_attributes # rubocop:todo Metrics/AbcSize
def permitted_attributes # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity
result = [:title, :type_name, {permalink_attributes: [:slug, :directory_id]}]
target = if !params[:id] && current_user.admin?
Account.first
Expand All @@ -331,7 +331,7 @@ def permitted_attributes # rubocop:todo Metrics/AbcSize
result += permitted_account_attributes

result << :folder_id if create_or_new_action? ||
(params[:id] && authorized?(:configure_folder_for, resource))
(params[:id] && authorized?(:configure_folder_for, resource))

accounts = if params[:id]
resource.account
Expand Down
22 changes: 11 additions & 11 deletions admins/pageflow/membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ module Pageflow
user = User.find(params[:parent_id])

PotentialMemberships
.creatable_by(current_user)
.accounts_for_user(user)
.order(:name)
.creatable_by(current_user)
.accounts_for_user(user)
.order(:name)
end)

searchable_select_options(name: :potential_entries_for_user,
Expand All @@ -24,8 +24,8 @@ module Pageflow
scope: lambda do |params|
user = User.find(params[:parent_id])
entries = PotentialMemberships
.creatable_by(current_user)
.entries_for_user(user)
.creatable_by(current_user)
.entries_for_user(user)

if can?(:see, :accounts)
entries.include_account_name.order('account_name', :title)
Expand All @@ -42,9 +42,9 @@ module Pageflow
scope: lambda do |params|
account = Account.find(params[:parent_id])
PotentialMemberships
.creatable_by(current_user)
.users_for_account(account)
.order(:last_name, :first_name)
.creatable_by(current_user)
.users_for_account(account)
.order(:last_name, :first_name)
end,
filter: lambda do |term, scope|
UserNameQuery::Scope.new(term, scope).resolve
Expand All @@ -55,9 +55,9 @@ module Pageflow
scope: lambda do |params|
entry = Entry.find(params[:parent_id])
PotentialMemberships
.creatable_by(current_user)
.users_for_entry(entry)
.order(:last_name, :first_name)
.creatable_by(current_user)
.users_for_entry(entry)
.order(:last_name, :first_name)
end,
filter: lambda do |term, scope|
UserNameQuery::Scope.new(term, scope).resolve
Expand Down
10 changes: 5 additions & 5 deletions admins/pageflow/translations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ module Pageflow
display_text: lambda do |entry|
if entry.translation_group
entry.translation_group
.entries
.order('title ASC')
.map(&:title)
.join(' / ')
.presence
.entries
.order('title ASC')
.map(&:title)
.join(' / ')
.presence
else
entry.title
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/pageflow/admin/widgets_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def admin_widgets_fields(form, config)
end

def admin_widget_types_collection_for_role(config, role)
config.widget_types.find_all_by_role(role).each_with_object({}) do |widget_type, result|
result[I18n.t(widget_type.translation_key)] = widget_type.name
config.widget_types.find_all_by_role(role).to_h do |widget_type|
[I18n.t(widget_type.translation_key), widget_type.name]
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/pageflow/common_entry_seed_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def initialize(config)
end

def as_json
config.page_types.each_with_object({}) do |page_type, result|
result[page_type.name.to_sym] = page_type_seed(page_type)
config.page_types.to_h do |page_type|
[page_type.name.to_sym, page_type_seed(page_type)]
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/helpers/pageflow/entry_json_seed_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def entry_widgets_seed(entry)
end

def entry_file_ids_seed(entry)
Pageflow.config.file_types.with_thumbnail_support.each_with_object({}) do |file_type, result|
result[file_type.collection_name] = entry.find_files(file_type.model).map(&:perma_id)
Pageflow.config.file_types.with_thumbnail_support.to_h do |file_type|
[file_type.collection_name, entry.find_files(file_type.model).map(&:perma_id)]
end
end

def entry_audio_files_json_seed(entry)
seed = entry.find_files(AudioFile).each_with_object({}) do |audio_file, result|
result[audio_file.perma_id] = audio_file_sources(audio_file)
seed = entry.find_files(AudioFile).to_h do |audio_file|
[audio_file.perma_id, audio_file_sources(audio_file)]
end

sanitize_json(seed.to_json).html_safe
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/pageflow/public_i18n_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def public_i18n_translations(entry)
{
pageflow: {
public: I18n.t('pageflow.public', locale: I18n.default_locale)
.dup
.dup
.deep_merge(I18n.t('pageflow.public', locale: entry.locale),
&merge_ignoring_nil)
}
Expand Down
4 changes: 1 addition & 3 deletions app/helpers/pageflow/themes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module ThemesHelper # rubocop:todo Style/Documentation
include RenderJsonHelper

def themes_options_json_seed(config = Pageflow.config)
config.themes.each_with_object({}) { |theme, options|
options[theme.name] = theme.options
}.to_json.html_safe
config.themes.to_h { |theme| [theme.name, theme.options] }.to_json.html_safe
end

def theme_json_seeds(config)
Expand Down
44 changes: 24 additions & 20 deletions app/models/pageflow/image_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,30 @@ def attachment_styles(attachment)

Pageflow
.config.thumbnail_styles.transform_values { |options| options.merge(style_defaults) }
.merge(
print: {geometry: '300x300>',
**style_defaults,
convert_options: '-quality 10 -interlace Plane'},
medium: {geometry: '1024x1024>',
**style_defaults,
convert_options: '-quality 70 -interlace Plane'},
large: {geometry: '1920x1920>',
**style_defaults,
convert_options: '-quality 70 -interlace Plane'},
ultra: {geometry: '3840x3840>',
**style_defaults,
convert_options: '-quality 90 -interlace Plane'},
panorama_medium: {geometry: ImageFile.scale_down_to_cover(1024, 1024),
format: panorama_format,
convert_options: '-quality 90 -interlace Plane'},
panorama_large: {geometry: ImageFile.scale_down_to_cover(1920, 1080),
format: panorama_format,
convert_options: '-quality 90 -interlace Plane'}
)
.merge(
print: {geometry: '300x300>',
**style_defaults,
convert_options: '-quality 10 -interlace Plane'},
medium: {geometry: '1024x1024>',
**style_defaults,
convert_options: '-quality 70 -interlace Plane'},
large: {geometry: '1920x1920>',
**style_defaults,
convert_options: '-quality 70 -interlace Plane'},
ultra: {geometry: '3840x3840>',
**style_defaults,
convert_options: '-quality 90 -interlace Plane'},
panorama_medium: {
geometry: ImageFile.scale_down_to_cover(1024, 1024),
format: panorama_format,
convert_options: '-quality 90 -interlace Plane'
},
panorama_large: {
geometry: ImageFile.scale_down_to_cover(1920, 1080),
format: panorama_format,
convert_options: '-quality 90 -interlace Plane'
}
)
.merge(social_image_styles)
end

Expand Down
6 changes: 3 additions & 3 deletions app/models/pageflow/image_file_url_templates.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Pageflow
class ImageFileUrlTemplates # rubocop:todo Style/Documentation
def call
styles.each_with_object({}) do |style, result|
result[style] = replace_extension_with_placeholder(
styles.to_h do |style|
[style, replace_extension_with_placeholder(
UrlTemplate.from_attachment(example_file.attachment, style)
)
)]
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/pageflow/nested_revision_component_copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def where_belongs_to_old_root(model, chain)
"#{[*chain, model].first.old_foreign_key} = #{@old_root_id}"
end

Model = Struct.new(:klass, :foreign_key, :level, keyword_init: true) do
Model = Struct.new(:klass, :foreign_key, :level) do
def self.for(revision_components:)
revision_components.map do |revision_component|
Model.new(klass: revision_component, foreign_key: 'revision_id', level: 1)
Expand Down
2 changes: 1 addition & 1 deletion app/models/pageflow/revision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def configuration
'manual_start' => manual_start,
'overview_button_enabled' => overview_button_enabled
}.delete_if { |_k, v| v.nil? }
.merge(read_attribute(:configuration) || {})
.merge(read_attribute(:configuration) || {})
end

def self.ransackable_attributes(_auth_object = nil)
Expand Down
4 changes: 2 additions & 2 deletions app/models/pageflow/widget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def defaults_by_role
def placeholders_by_role
return {} unless options[:include_placeholders]

config.widget_types.roles.each_with_object({}) do |role, result|
result[role] = Widget.new(role:, type_name: nil, subject: nil)
config.widget_types.roles.to_h do |role|
[role, Widget.new(role:, type_name: nil, subject: nil)]
end
end

Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20140418225525_setup_schema.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rubocop:disable Layout/LineLength, Metrics/ClassLength, Metrics/MethodLength, Metrics/AbcSize, Metrics/BlockLength
# rubocop:disable Layout/LineLength, Metrics/ClassLength, Metrics/BlockLength

class SetupSchema < ActiveRecord::Migration[5.2]
def change
Expand Down Expand Up @@ -296,4 +296,4 @@ def change
end
end

# rubocop:enable Layout/LineLength, Metrics/ClassLength, Metrics/MethodLength, Metrics/AbcSize, Metrics/BlockLength
# rubocop:enable Layout/LineLength, Metrics/ClassLength, Metrics/BlockLength
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def generate(rules)
private

def extract_breakpoint_declarations!(declarations)
BREAKPOINTS.keys.each_with_object({}) { |breakpoint_name, result|
result[breakpoint_name] = declarations.delete(breakpoint_name)
BREAKPOINTS.keys.to_h { |breakpoint_name|
[breakpoint_name, declarations.delete(breakpoint_name)]
}.compact
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def register(name, callable, content_element_type_names: nil)

# @api private
def for(entry, request, options = {})
items_for_entry(entry, options).each_with_object({}) do |item, result|
result[item.name] = item.callable.call(entry:, request:, foo: 1)
items_for_entry(entry, options).to_h do |item|
[item.name, item.callable.call(entry:, request:, foo: 1)]
end
end

Expand Down
5 changes: 3 additions & 2 deletions entry_types/scrolled/lib/pageflow_scrolled/plugin.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PageflowScrolled
# @api private
class Plugin < Pageflow::Plugin
class Plugin < Pageflow::Plugin # rubocop:disable Metrics/ClassLength
def configure(config)
config.features.register('scrolled_entry_type') do |feature_config|
feature_config.entry_types.register(PageflowScrolled.entry_type)
Expand Down Expand Up @@ -71,7 +71,8 @@ def configure(config)
'section_default_padding_top' => 'max(10em, 20svh)',
'section_default_padding_bottom' => 'max(10em, 20svh)',
'content_element_margin_style_default' => '2em',
'content_element_box_shadow_style_default' => '0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.15)',
'content_element_box_shadow_style_default' =>
'0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.15)',
'box_shadow_clip_margin_bottom' => '3rem',
'outline_color' => '#a0a0a080'
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ describe('LinkTooltip', () => {
<MainStorylineActivity activeExcursion={activeExcursion}>
<LinkTooltipProvider>
<LinkPreview href="https://example.com" openInNewTab={false}>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a>Test Link</a>
</LinkPreview>
</LinkTooltipProvider>
Expand Down
Loading
Loading