diff --git a/.bundle/config b/.bundle/config deleted file mode 100644 index f098b396..00000000 --- a/.bundle/config +++ /dev/null @@ -1,3 +0,0 @@ ---- -BUNDLE_JOBS: "3" -BUNDLE_GITHUB__HTTPS: "true" diff --git a/.envrc b/.envrc deleted file mode 100644 index 0fecf38d..00000000 --- a/.envrc +++ /dev/null @@ -1 +0,0 @@ -use ruby 3.0.4 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac280d35..41d87107 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.0.3 + ruby-version: 3.3 - name: Setup config run: | diff --git a/.gitignore b/.gitignore index 9a0c6db7..bffe7172 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,11 @@ config/settings.yml /esdata /rvm-installer /.vscode + +/.bundle/config +/.envrc +/vendor/cache +/contrib +/Session.vim +/.bundle +/.solargraph.yml diff --git a/.rubocop.yml b/.rubocop.yml index 6a45a799..79955c58 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,29 @@ +inherit_from: .rubocop_todo.yml + AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 3.1 + Exclude: + # Exclude generated files from Rails + - bin/rails + - bin/rake + - bin/setup + - config/application.rb + - config/boot.rb + - config/environment.rb + - config/environments/development.rb + - config/environments/production.rb + - config/environments/test.rb + - config/initializers/assets.rb + - config/initializers/content_security_policy.rb + - config/initializers/cors.rb + - config/initializers/filter_parameter_logging.rb + - config/initializers/inflections.rb + - config/initializers/permissions_policy.rb + # Exclude others + - Vagrantfile + - tmp/**/* + - contrib/**/* + - db/schema.rb # loading order actually matters Bundler/OrderedGems: @@ -27,9 +51,9 @@ Style/Not: #Style/RedundantSelf: # Enabled: false -# Good cop, but to spammy -#Style/StringLiterals: -#Enabled: false +# I give up, the readability/security benefit is too small. Just use whatever quotes. +Style/StringLiterals: + Enabled: false # use { only for single line blocks, but allow block content on its own line to keep line length short # each { |l| @@ -51,6 +75,9 @@ Layout/ParameterAlignment: Enabled: true EnforcedStyle: with_fixed_indentation +Layout/MultilineMethodCallIndentation: + Enabled: false + # Do not write 1234 as 1_234 Style/NumericLiterals: Enabled: false @@ -59,6 +86,9 @@ Style/NumericLiterals: Metrics/AbcSize: Max: 40 +Metrics/MethodLength: + Max: 40 + # too spammy Style/Documentation: Enabled: false @@ -67,12 +97,31 @@ Layout/HashAlignment: Enabled: false # adapt rubocop to existing code "style" -Layout/EmptyLineAfterGuardClause: - Enabled: false Style/IfUnlessModifier: Enabled: false Style/NumericPredicate: Enabled: false Style/RedundantReturn: Enabled: false - +Style/StringConcatenation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/PercentLiteralDelimiters: + Enabled: false +Style/SymbolArray: + Enabled: false +Style/WordArray: + Enabled: false +Layout/ArrayAlignment: + Enabled: false +Style/RegexpLiteral: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/CommentIndentation: + Enabled: false +Style/NumericLiteralPrefix: + Enabled: false +Layout/LeadingCommentSpace: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..fb365159 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,748 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2024-10-03 13:59:17 UTC using RuboCop version 1.66.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/BlockEndNewline: + Exclude: + - 'test/factories.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Exclude: + - 'app/helpers/frontend/feed_quality.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: around, only_before +Layout/EmptyLinesAroundAccessModifier: + Exclude: + - 'db/migrate/20230131143554_create_active_storage_variant_records.active_storage.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'test/models/concerns/storage_test.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/FirstArrayElementIndentation: + Exclude: + - 'app/helpers/frontend/feeds_navigation_bar_structure_helper.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + Exclude: + - 'app/helpers/frontend/feeds_navigation_bar_structure_helper.rb' + - 'app/models/frontend/event.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/HeredocIndentation: + Exclude: + - 'lib/feeds/rdf_generator.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Exclude: + - 'app/admin/news.rb' + - 'db/migrate/20230131143554_create_active_storage_variant_records.active_storage.rb' + +# Offense count: 12 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, AllowedPatterns. +Layout/IndentationWidth: + Exclude: + - 'app/admin/news.rb' + - 'app/graphql/types/lecture_type.rb' + - 'app/models/frontend/event.rb' + - 'db/migrate/20230131143554_create_active_storage_variant_records.active_storage.rb' + - 'test/controllers/graphql_controller_test.rb' + - 'test/models/admin_user_test.rb' + - 'test/models/api_key_test.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineArrayBraceLayout: + Exclude: + - 'app/admin/conference.rb' + - 'app/helpers/frontend/feeds_navigation_bar_structure_helper.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Layout/MultilineBlockLayout: + Exclude: + - 'app/helpers/frontend/event_recording_filter_high_quality.rb' + - 'test/factories.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterColon: + Exclude: + - 'app/graphql/types/lecture_type.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterComma: + Exclude: + - 'app/controllers/frontend/feeds_controller.rb' + - 'app/helpers/frontend/event_recording_filter_high_quality.rb' + - 'app/helpers/frontend/event_recording_filter_low_quality.rb' + - 'app/helpers/frontend/event_recording_filter_master.rb' + - 'app/models/concerns/fahrplan_parser.rb' + - 'lib/mime_type.rb' + - 'test/models/frontend/event_test.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterNot: + Exclude: + - 'lib/mime_type.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'app/models/web_feed.rb' + +# Offense count: 21 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. +# SupportedStylesForExponentOperator: space, no_space +# SupportedStylesForRationalLiterals: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'app/controllers/frontend/home_controller.rb' + - 'app/helpers/frontend/feeds_navigation_bar_structure_helper.rb' + - 'app/models/frontend/event.rb' + - 'config/initializers/cors_public.rb' + - 'db/migrate/20140103000127_fill_recordings_folder_from_mime_types.rb' + - 'lib/feeds/podcast_generator.rb' + - 'lib/update_related_events.rb' + - 'test/controllers/api/conferences_controller_test.rb' + - 'test/controllers/api/recordings_controller_test.rb' + - 'test/integration/conferences_api_test.rb' + - 'test/integration/events_api_test.rb' + - 'test/workers/feed/folder_worker_test.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Exclude: + - 'app/models/frontend/event.rb' + - 'test/lib/frontend/folder_tree_test.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'app/admin/conference.rb' + - 'app/helpers/frontend/feeds_navigation_bar_structure_helper.rb' + - 'app/models/event.rb' + - 'config/initializers/devise.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'app/models/event.rb' + - 'app/models/frontend/event.rb' + +# Offense count: 20 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'app/admin/conference.rb' + - 'app/controllers/concerns/api_error_responses.rb' + - 'app/helpers/frontend/feeds_navigation_bar_structure_helper.rb' + - 'test/integration/graphql/conferences_test.rb' + - 'test/integration/graphql/lecture_test.rb' + - 'test/models/event_test.rb' + - 'test/models/recording_view_test.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceInsidePercentLiteralDelimiters: + Exclude: + - 'db/migrate/20230131143554_create_active_storage_variant_records.active_storage.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'db/migrate/20230131143553_add_service_name_to_active_storage_blobs.active_storage.rb' + +# Offense count: 1 +Lint/BinaryOperatorWithIdenticalOperands: + Exclude: + - 'app/helpers/frontend/event_recording_filter_master.rb' + +# Offense count: 9 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'test/controllers/api/events_controller_test.rb' + - 'test/models/concerns/storage_test.rb' + +# Offense count: 4 +Lint/DuplicateMethods: + Exclude: + - 'app/models/event.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Lint/ImplicitStringConcatenation: + Exclude: + - 'app/graphql/types/lecture_type.rb' + +# Offense count: 3 +Lint/IneffectiveAccessModifier: + Exclude: + - 'app/models/web_feed.rb' + - 'lib/feeds/news_feed_generator.rb' + +# Offense count: 1 +Lint/NonLocalExitFromIterator: + Exclude: + - 'lib/frontend/folder_tree.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Lint/ParenthesesAsGroupedExpression: + Exclude: + - 'test/models/conference_test.rb' + - 'test/models/event_test.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods. +# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? +Lint/RedundantSafeNavigation: + Exclude: + - 'app/workers/conference_relive_download_worker.rb' + +# Offense count: 3 +Lint/ShadowingOuterLocalVariable: + Exclude: + - 'app/workers/conference_relive_download_worker.rb' + - 'lib/feeds/news_feed_generator.rb' + +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/graphql/types/query_type.rb' + - 'app/helpers/frontend/event_recording_filter_master.rb' + - 'config/initializers/exception_notifier.rb' + - 'lib/tasks/db_dump_fixtures.rake' + - 'lib/tasks/db_load_fixtures_with_jsonb.rake' + +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'app/graphql/types/json_type.rb' + - 'app/graphql/types/url_type.rb' + - 'app/workers/feed/archive_legacy_worker.rb' + - 'app/workers/feed/archive_worker.rb' + - 'app/workers/feed/audio_worker.rb' + - 'app/workers/feed/legacy_worker.rb' + - 'app/workers/feed/podcast_worker.rb' + - 'app/workers/feed/recent_worker.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods. +Lint/UselessAccessModifier: + Exclude: + - 'app/models/concerns/storage.rb' + - 'app/models/web_feed.rb' + - 'lib/feeds/news_feed_generator.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. +Lint/UselessAssignment: + Exclude: + - 'test/controllers/frontend/events_controller_test.rb' + - 'test/lib/feeds/podcast_generator_test.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. +Lint/UselessMethodDefinition: + Exclude: + - 'app/graphql/resolvers/conference.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'app/graphql/types/lecture_type.rb' + +# Offense count: 2 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. +Metrics/AbcSize: + Exclude: + - 'lib/feeds/podcast_generator.rb' + +# Offense count: 25 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +# AllowedMethods: refine +Metrics/BlockLength: + Max: 177 + +# Offense count: 8 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 237 + +# Offense count: 5 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/CyclomaticComplexity: + Max: 12 + +# Offense count: 1 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Exclude: + - 'app/models/concerns/elasticsearch_event.rb' + +# Offense count: 1 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ModuleLength: + Max: 107 + +# Offense count: 4 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 12 + +# Offense count: 4 +Naming/AccessorMethodName: + Exclude: + - 'app/controllers/concerns/api_error_responses.rb' + - 'app/workers/feed/base.rb' + +# Offense count: 1 +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +Naming/HeredocDelimiterNaming: + Exclude: + - 'lib/feeds/rdf_generator.rb' + +# Offense count: 12 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'app/controllers/frontend/events_controller.rb' + - 'app/controllers/graphql_controller.rb' + - 'app/helpers/frontend/tagging_helper.rb' + - 'app/models/concerns/fahrplan_parser.rb' + - 'app/models/frontend/event.rb' + - 'app/workers/feed/base.rb' + - 'bla.rb' + +# Offense count: 6 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# ForbiddenPrefixes: is_, has_, have_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'app/models/concerns/storage.rb' + - 'app/models/frontend/conference.rb' + - 'app/models/frontend/event.rb' + - 'lib/mime_type.rb' + +# Offense count: 2 +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. +# SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 +Naming/VariableNumber: + Exclude: + - 'app/models/recording.rb' + - 'lib/languages.rb' + +# Offense count: 1 +Security/Open: + Exclude: + - 'app/models/recording.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +Style/BisectedAttrAccessor: + Exclude: + - 'lib/feeds/podcast_generator.rb' + - 'lib/feeds/rdf_generator.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/BlockComments: + Exclude: + - 'db/migrate/20140101231325_move_event_info_data_to_event.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowOnConstant, AllowOnSelfClass. +Style/CaseEquality: + Exclude: + - 'app/controllers/frontend/popular_controller.rb' + +# Offense count: 39 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Enabled: false + +# Offense count: 1 +Style/ClassVars: + Exclude: + - 'bla.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/CombinableLoops: + Exclude: + - 'lib/tasks/db_load_fixtures_with_jsonb.rake' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/CommentedKeyword: + Exclude: + - 'app/admin/dashboard.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'app/controllers/api/events_controller.rb' + - 'app/controllers/concerns/api_error_responses.rb' + - 'app/controllers/frontend/popular_controller.rb' + - 'app/controllers/public/conferences_controller.rb' + - 'app/controllers/public/events_controller.rb' + - 'app/models/recording.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/DefWithParentheses: + Exclude: + - 'app/models/recording.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/EachWithObject: + Exclude: + - 'lib/tasks/db_dump_fixtures.rake' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/EmptyLambdaParameter: + Exclude: + - 'app/models/news.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/EmptyLiteral: + Exclude: + - 'app/models/concerns/fahrplan_parser.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'app/controllers/api/conferences_controller.rb' + - 'app/controllers/api/events_controller.rb' + - 'app/controllers/api/recordings_controller.rb' + - 'app/controllers/public_controller.rb' + - 'test/models/concerns/storage_test.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/ExplicitBlockArgument: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 285 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. +Style/GuardClause: + Exclude: + - 'app/controllers/concerns/api_error_responses.rb' + - 'app/controllers/frontend/events_controller.rb' + - 'app/graphql/types/url_type.rb' + - 'app/models/event.rb' + - 'app/models/recording.rb' + - 'db/migrate/20230131143553_add_service_name_to_active_storage_blobs.active_storage.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'lib/update_related_events.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowIfModifier. +Style/IfInsideElse: + Exclude: + - 'app/controllers/api/recordings_controller.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'app/helpers/frontend/event_recording_filter_master.rb' + - 'app/workers/conference_relive_download_worker.rb' + - 'lib/frontend/folder_tree.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowedMethods, AllowedPatterns. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'test/models/event_test.rb' + +# Offense count: 1 +Style/MissingRespondToMissing: + Exclude: + - 'lib/settings.rb' + +# Offense count: 2 +Style/MixinUsage: + Exclude: + - 'bin/update' + - 'bin/update-data' + +# Offense count: 2 +Style/MultilineBlockChain: + Exclude: + - 'app/models/recording.rb' + +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'app/helpers/frontend/feed_quality.rb' + - 'app/helpers/frontend/feeds_navigation_bar_structure_helper.rb' + - 'app/models/conference.rb' + - 'test/controllers/api/events_controller_test.rb' + - 'test/models/conference_test.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IncludeSemanticChanges. +Style/NonNilCheck: + Exclude: + - 'app/helpers/frontend/event_recording_filter.rb' + +# Offense count: 2 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'app/models/conference.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/OrAssignment: + Exclude: + - 'app/controllers/frontend/conferences_controller.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: SafeForConstants. +Style/RedundantFetchBlock: + Exclude: + - 'config/puma.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantFreeze: + Exclude: + - 'lib/mime_type.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/RedundantInterpolation: + Exclude: + - 'app/models/recording.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantParentheses: + Exclude: + - 'app/helpers/frontend/application_helper.rb' + - 'app/models/event.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpEscape: + Exclude: + - 'app/models/event.rb' + +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantSelf: + Exclude: + - 'app/models/concerns/fahrplan_updater.rb' + - 'app/models/recording.rb' + - 'app/models/web_feed.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'app/controllers/graphql_controller.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'app/graphql/types/query_type.rb' + - 'app/models/event.rb' + - 'app/models/frontend/event.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'db/migrate/20200119000347_change_release_date_type.rb' + +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: only_raise, only_fail, semantic +Style/SignalException: + Exclude: + - 'app/controllers/api/conferences_controller.rb' + - 'app/controllers/api/events_controller.rb' + - 'app/controllers/api/recordings_controller.rb' + - 'app/controllers/frontend/conferences_controller.rb' + - 'app/controllers/frontend/feeds_controller.rb' + - 'app/controllers/public/conferences_controller.rb' + - 'app/controllers/public/events_controller.rb' + - 'app/controllers/public_controller.rb' + - 'lib/frontend/folder_tree.rb' + - 'lib/settings.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SlicingWithRange: + Exclude: + - 'app/controllers/public_controller.rb' + - 'app/models/event.rb' + - 'app/models/frontend/conference.rb' + +# Offense count: 19 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. +# AllowedMethods: define_method +Style/SymbolProc: + Exclude: + - 'app/controllers/frontend/events_controller.rb' + - 'app/controllers/frontend/home_controller.rb' + - 'app/controllers/frontend/popular_controller.rb' + - 'app/controllers/frontend/recent_controller.rb' + - 'app/controllers/frontend/search_controller.rb' + - 'app/controllers/frontend/sitemap_controller.rb' + - 'app/controllers/frontend/tags_controller.rb' + - 'app/controllers/frontend/unpopular_controller.rb' + - 'app/controllers/public/conferences_controller.rb' + - 'app/controllers/public/events_controller.rb' + - 'app/models/frontend/event.rb' + - 'test/lib/frontend/folder_tree_test.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'app/admin/conference.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'app/models/concerns/elasticsearch_event.rb' + - 'app/models/frontend/event.rb' + - 'app/models/recording.rb' + - 'config/initializers/action_mailer.rb' + - 'db/migrate/20140103000127_fill_recordings_folder_from_mime_types.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ZeroLengthPredicate: + Exclude: + - 'app/models/event.rb' + - 'test/models/conference_test.rb' diff --git a/Dockerfile b/Dockerfile index a8c40373..4c71999f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use the the official Ruby image as a base -FROM ruby:3.0-alpine +FROM ruby:3.3-alpine # Install runtime dependencies # Node.js is used for JavaScript compression via the uglifier gem @@ -32,7 +32,8 @@ RUN set -eux; \ build-base \ ; \ \ - gem install -v 2.3.9 bundler; \ + bundle config set --local with development \ + gem install -v 2.5.20 bundler; \ bundle install --jobs=$(nproc); \ rm -r ~/.bundle; \ \ diff --git a/Gemfile b/Gemfile index 3342a6a3..08b92476 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'openssl' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 7.0' +gem 'rails', '~> 7.2.0' gem 'dotenv-rails' gem 'activeadmin' @@ -17,18 +17,13 @@ gem 'foreman' gem 'listen' # rails cache -gem 'redis-rails' +gem 'redis' gem 'exception_notification' # Bundle puma application server gem 'puma' gem 'puma_worker_killer' -gem 'utf8-cleaner' - -# Simplified production logging -gem 'lograge' - group :development do gem 'bullet' gem 'capistrano', '~> 3.17.1', group: :capistrano, require: false @@ -39,6 +34,8 @@ group :development do gem 'mqtt', :git => 'https://github.com/njh/ruby-mqtt.git' gem 'ed25519', require: false gem 'bcrypt_pbkdf', require: false + gem 'solargraph', require: false + gem 'rbs', require: false end gem 'haml' diff --git a/Gemfile.lock b/Gemfile.lock index 6c1ab1d7..1821b01b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,124 +1,135 @@ GIT remote: https://github.com/njh/ruby-mqtt.git - revision: 1df81315f38289c384f86da764b2b6d8cc211c5e + revision: b2e48d05f48919949c1c23f6fd5b9f05b6265a82 specs: - mqtt (0.5.0) + mqtt (0.6.0) GEM remote: https://rubygems.org/ specs: - openssl (3.1.0) - aasm (5.4.0) + aasm (5.5.0) concurrent-ruby (~> 1.0) - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.2.1) + actionpack (= 7.2.1) + activesupport (= 7.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + zeitwerk (~> 2.6) + actionmailbox (7.2.1) + actionpack (= 7.2.1) + activejob (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) + mail (>= 2.8.0) + actionmailer (7.2.1) + actionpack (= 7.2.1) + actionview (= 7.2.1) + activejob (= 7.2.1) + activesupport (= 7.2.1) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (7.2.1) + actionview (= 7.2.1) + activesupport (= 7.2.1) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4, < 3.2) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (7.2.1) + actionpack (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.2.1) + activesupport (= 7.2.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activeadmin (2.13.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activeadmin (3.2.5) arbre (~> 1.2, >= 1.2.1) - formtastic (>= 3.1, < 5.0) - formtastic_i18n (~> 0.4) + csv + formtastic (>= 3.1) + formtastic_i18n (>= 0.4) inherited_resources (~> 1.7) - jquery-rails (~> 4.2) - kaminari (~> 1.0, >= 1.2.1) - railties (>= 6.1, < 7.1) - ransack (>= 2.1.1, < 4) - activejob (7.0.8) - activesupport (= 7.0.8) + jquery-rails (>= 4.2) + kaminari (>= 1.2.1) + railties (>= 6.1) + ransack (>= 4.0) + activejob (7.2.1) + activesupport (= 7.2.1) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.2.1) + activesupport (= 7.2.1) + activerecord (7.2.1) + activemodel (= 7.2.1) + activesupport (= 7.2.1) + timeout (>= 0.4.0) + activestorage (7.2.1) + actionpack (= 7.2.1) + activejob (= 7.2.1) + activerecord (= 7.2.1) + activesupport (= 7.2.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8) - concurrent-ruby (~> 1.0, >= 1.0.2) + activesupport (7.2.1) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - tzinfo (~> 2.0) - airbrussh (1.4.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + airbrussh (1.5.3) sshkit (>= 1.6.1, != 1.7.0) - api-pagination (5.0.0) - apollo-federation (3.3.1) - google-protobuf (~> 3.21.7) + api-pagination (6.0.0) + apollo-federation (3.8.5) + google-protobuf (~> 3.22) graphql (>= 1.10.14) - arbre (1.5.0) - activesupport (>= 3.0.0, < 7.1) - ruby2_keywords (>= 0.0.2, < 1.0) - autoprefixer-rails (10.4.7.0) + arbre (1.7.0) + activesupport (>= 3.0.0) + ruby2_keywords (>= 0.0.2) + ast (2.4.2) + autoprefixer-rails (10.4.19.0) execjs (~> 2) - bcrypt (3.1.18) - bcrypt_pbkdf (1.1.0) + backport (1.2.0) + base64 (0.2.0) + bcrypt (3.1.20) + bcrypt_pbkdf (1.1.1) + bcrypt_pbkdf (1.1.1-x86_64-darwin) + benchmark (0.3.0) + bigdecimal (3.1.8) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) - builder (3.2.4) - bullet (7.0.7) + builder (3.3.0) + bullet (7.2.0) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) - capistrano (3.17.1) + capistrano (3.17.3) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) sshkit (>= 1.9.0) - capistrano-bundler (2.1.0) + capistrano-bundler (2.1.1) capistrano (~> 3.1) - capistrano-rails (1.6.2) + capistrano-rails (1.6.3) capistrano (~> 3.1) capistrano-bundler (>= 1.1, < 3) capistrano-rvm (0.1.2) capistrano (~> 3.0) sshkit (~> 1.2) - capistrano-sidekiq (2.3.0) + capistrano-sidekiq (2.3.1) capistrano (>= 3.9.0) capistrano-bundler sidekiq (>= 6.0) @@ -130,21 +141,24 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.2.2) - connection_pool (2.3.0) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) crass (1.0.6) + csv (3.3.0) date (3.3.4) - devise (4.8.1) + devise (4.9.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - dotenv (2.8.1) - openssl (3.1.0) - dotenv-rails (2.8.1) - dotenv (= 2.8.1) - railties (>= 3.2) + diff-lcs (1.5.1) + dotenv (3.1.4) + dotenv-rails (3.1.4) + dotenv (= 3.1.4) + railties (>= 6.1) + drb (2.2.1) + e2mmap (0.1.0) ed25519 (1.3.0) elasticsearch (6.8.3) elasticsearch-api (= 6.8.3) @@ -159,17 +173,17 @@ GEM elasticsearch-transport (6.8.3) faraday (~> 1) multi_json - erubi (1.12.0) + erubi (1.13.0) exception_notification (4.5.0) actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) - execjs (2.8.1) - factory_bot (6.2.1) + execjs (2.9.1) + factory_bot (6.5.0) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) - faraday (1.10.3) + faraday (1.10.4) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -187,54 +201,63 @@ GEM faraday-httpclient (1.0.1) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (1.0.1) + faraday-net_http (1.0.2) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - ffi (1.15.5) - foreman (0.87.2) - formtastic (4.0.0) - actionpack (>= 5.2.0) + ffi (1.17.0) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + foreman (0.88.1) + formtastic (5.0.0) + actionpack (>= 6.0.0) formtastic_i18n (0.7.0) - get_process_mem (0.2.7) + get_process_mem (1.0.0) + bigdecimal (>= 2.0) ffi (~> 1.0) globalid (1.2.1) activesupport (>= 6.1) - goldiloader (4.2.0) - activerecord (>= 5.2, < 7.2) - activesupport (>= 5.2, < 7.2) - google-protobuf (3.21.12) - google-protobuf (3.21.12-x86_64-darwin) - google-protobuf (3.21.12-x86_64-linux) - graphiql-rails (1.8.0) + goldiloader (5.3.1) + activerecord (>= 6.1, < 8) + activesupport (>= 6.1, < 8) + google-protobuf (3.25.5) + google-protobuf (3.25.5-x86_64-darwin) + google-protobuf (3.25.5-x86_64-linux) + graphiql-rails (1.10.1) railties - sprockets-rails - graphql (1.13.18) + graphql (1.13.23) + base64 graphql-query-resolver (0.2.0) graphql (~> 1.0, >= 1.0.0) - haml (6.1.1) + haml (6.3.0) temple (>= 0.8.2) thor tilt - has_scope (0.8.0) + has_scope (0.8.2) actionpack (>= 5.2) activesupport (>= 5.2) hashie (5.0.0) - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) - inherited_resources (1.13.1) - actionpack (>= 5.2, < 7.1) - has_scope (~> 0.6) - railties (>= 5.2, < 7.1) - responders (>= 2, < 4) - jbuilder (2.11.5) + inherited_resources (1.14.0) + actionpack (>= 6.0) + has_scope (>= 0.6) + railties (>= 6.0) + responders (>= 2) + io-console (0.7.2) + irb (1.14.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jaro_winkler (1.6.0) + jbuilder (2.13.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - jquery-rails (4.5.1) + 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) kaminari-actionview (= 1.2.2) @@ -247,14 +270,15 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - listen (3.8.0) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + language_server-protocol (3.17.0.3) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - lograge (0.12.0) - actionpack (>= 4) - activesupport (>= 4) - railties (>= 4) - request_store (~> 1.0) + logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -263,14 +287,14 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) - method_source (1.0.0) + marcel (1.0.4) + method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.5) - minitest (5.20.0) + mini_portile2 (2.8.7) + minitest (5.25.1) multi_json (1.15.0) - multipart-post (2.3.0) - net-imap (0.4.8) + multipart-post (2.4.1) + net-imap (0.4.16) date net-protocol net-pop (0.1.2) @@ -279,54 +303,68 @@ GEM timeout net-scp (4.0.0) net-ssh (>= 2.6.5, < 8.0.0) - net-smtp (0.4.0) + net-sftp (4.0.0) + net-ssh (>= 5.0.0, < 8.0.0) + net-smtp (0.5.0) net-protocol - net-ssh (7.0.1) - nio4r (2.7.0) - nokogiri (1.15.5) + net-ssh (7.3.0) + nio4r (2.7.3) + nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.15.5-x86_64-darwin) + nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.15.5-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) + openssl (3.2.0) orm_adapter (0.5.0) - pg (1.4.5) + ostruct (0.6.0) + parallel (1.26.3) + parser (3.3.5.0) + ast (~> 2.4.1) + racc + pg (1.5.8) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - pry-rails (0.3.9) - pry (>= 0.10.4) - psych (5.0.2) + pry-rails (0.3.11) + pry (>= 0.13.0) + psych (5.1.2) stringio - puma (6.0.2) + puma (6.4.3) nio4r (~> 2.0) - puma_worker_killer (0.3.1) - get_process_mem (~> 0.2) + puma_worker_killer (1.0.0) + bigdecimal (>= 2.0) + get_process_mem (>= 0.2) puma (>= 2.7) - racc (1.7.3) - rack (2.2.8) - rack-cors (1.1.1) + racc (1.8.1) + rack (3.1.7) + rack-cors (2.0.2) rack (>= 2.0.0) + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.2.1) + actioncable (= 7.2.1) + actionmailbox (= 7.2.1) + actionmailer (= 7.2.1) + actionpack (= 7.2.1) + actiontext (= 7.2.1) + actionview (= 7.2.1) + activejob (= 7.2.1) + activemodel (= 7.2.1) + activerecord (= 7.2.1) + activestorage (= 7.2.1) + activesupport (= 7.2.1) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.2.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -338,53 +376,57 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) - method_source + railties (7.2.1) + actionpack (= 7.2.1) + activesupport (= 7.2.1) + irb (~> 1.13) + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) - rake (13.1.0) - ransack (3.2.1) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + ransack (4.2.1) activerecord (>= 6.1.5) activesupport (>= 6.1.5) i18n rb-fsevent (0.11.2) - rb-inotify (0.10.1) + rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (6.5.0) + rbs (2.8.4) + rdoc (6.7.0) psych (>= 4.0.0) redcarpet (3.6.0) - redis (4.8.0) - redis-actionpack (5.3.0) - actionpack (>= 5, < 8) - redis-rack (>= 2.1.0, < 3) - redis-store (>= 1.1.0, < 2) - redis-activesupport (5.3.0) - activesupport (>= 3, < 8) - redis-store (>= 1.3, < 2) - redis-client (0.12.1) + redis (5.3.0) + redis-client (>= 0.22.0) + redis-client (0.22.2) connection_pool - redis-rack (2.1.4) - rack (>= 2.0.8, < 3) - redis-store (>= 1.2, < 2) - redis-rails (5.0.2) - redis-actionpack (>= 5.0, < 6) - redis-activesupport (>= 5.0, < 6) - redis-store (>= 1.2, < 2) - redis-store (1.9.1) - redis (>= 4, < 5) - request_store (1.5.1) - rack (>= 1.4) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) - rexml (3.2.5) - rss (0.2.9) + regexp_parser (2.9.2) + reline (0.5.10) + io-console (~> 0.5) + responders (3.1.1) + actionpack (>= 5.2) + railties (>= 5.2) + reverse_markdown (2.1.1) + nokogiri + rexml (3.3.8) + rss (0.3.1) rexml + rubocop (1.66.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) ruby-graphviz (1.2.5) rexml + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -396,51 +438,74 @@ GEM sprockets (> 3.0) sprockets-rails tilt - sdoc (2.6.0) + sdoc (2.6.1) rdoc (>= 5.0) search_object (1.2.5) - search_object_graphql (1.0.4) + search_object_graphql (1.0.5) graphql (> 1.8) - search_object (~> 1.2.2) - sidekiq (7.0.3) + search_object (~> 1.2.5) + securerandom (0.3.1) + sidekiq (7.3.2) concurrent-ruby (< 2) connection_pool (>= 2.3.0) + logger rack (>= 2.2.4) - redis-client (>= 0.11.0) - sprockets (4.2.0) + redis-client (>= 0.22.2) + solargraph (0.50.0) + backport (~> 1.2) + benchmark + bundler (~> 2.0) + diff-lcs (~> 1.4) + e2mmap + jaro_winkler (~> 1.5) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + parser (~> 3.0) + rbs (~> 2.0) + reverse_markdown (~> 2.0) + rubocop (~> 1.38) + thor (~> 1.0) + tilt (~> 2.0) + yard (~> 0.9, >= 0.9.24) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - sshkit (1.21.3) + sshkit (1.23.1) + base64 net-scp (>= 1.1.2) + net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) - stringio (3.0.4) - temple (0.10.0) - thor (1.3.0) - tilt (2.0.11) + ostruct + stringio (3.1.1) + temple (0.10.3) + thor (1.3.2) + tilt (2.4.0) timeout (0.4.1) - tinymce-rails (6.3.1) + tinymce-rails (7.3.0) railties (>= 3.1.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uglifier (4.2.0) + uglifier (4.2.1) execjs (>= 0.3.0, < 3) + unicode-display_width (2.6.0) uniform_notifier (1.16.0) - utf8-cleaner (1.0.0) - activesupport + useragent (0.16.10) warden (1.2.9) rack (>= 2.0.9) + webrick (1.8.2) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) yajl-ruby (1.4.3) - zeitwerk (2.6.12) + yard (0.9.37) + zeitwerk (2.6.18) PLATFORMS ruby @@ -464,7 +529,6 @@ DEPENDENCIES coffee-rails devise dotenv-rails - openssl ed25519 elasticsearch-model (~> 6.1.1) elasticsearch-rails (~> 6.1.0) @@ -480,18 +544,19 @@ DEPENDENCIES jquery-rails kaminari listen - lograge mqtt! + openssl pg pry-byebug pry-rails puma puma_worker_killer rack-cors - rails (~> 7.0) + rails (~> 7.2.0) rails-controller-testing + rbs redcarpet - redis-rails + redis rss ruby-graphviz sass-rails @@ -499,11 +564,11 @@ DEPENDENCIES search_object search_object_graphql sidekiq + solargraph tinymce-rails turbolinks uglifier (>= 1.3.0) - utf8-cleaner yajl-ruby BUNDLED WITH - 2.3.9 + 2.5.20 diff --git a/README.md b/README.md index 80073ba1..d1d6dd5c 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ Image and video files in `docker/content` are tried first, if missing live data ### Ruby Version -ruby 3.0.3 +ruby 3.3 ### Dependencies @@ -223,8 +223,8 @@ gpg --verify rvm-installer.asc rvm-installer bash rvm-installer stable source ~/.rvm/scripts/rvm -# install ruby 3.0.3 -rvm install ruby-3.0.3 +# install ruby +rvm install ruby-3.3.5 # install bundler gem install bundler diff --git a/app/admin/admin_user.rb b/app/admin/admin_user.rb index d6259a5a..6cd46b22 100644 --- a/app/admin/admin_user.rb +++ b/app/admin/admin_user.rb @@ -26,5 +26,4 @@ def permitted_params params.permit admin_user: [:email, :password, :password_confirmation] end end - end diff --git a/app/admin/conference.rb b/app/admin/conference.rb index ccd80312..21f6550f 100644 --- a/app/admin/conference.rb +++ b/app/admin/conference.rb @@ -1,5 +1,4 @@ ActiveAdmin.register Conference do - filter :acronym filter :title filter :slug @@ -75,7 +74,6 @@ f.inputs "Meta" do f.input :subtitles, :as => :boolean, label: 'Conference has subtitles', hint: 'displays subtitle appeal below player' f.input :custom_css - end f.actions end @@ -91,7 +89,7 @@ action_item(:add_event, only: [:show, :edit]) do link_to 'View', conference_path(acronym: conference.acronym), method: :get end - + action_item(:download_schedule, only: :show) do link_to 'Download Schedule', download_schedule_admin_conference_path(conference), method: :post end @@ -118,7 +116,4 @@ def permitted_params ] end end - - - end diff --git a/app/controllers/api/recordings_controller.rb b/app/controllers/api/recordings_controller.rb index 2d18be53..63a8dc67 100644 --- a/app/controllers/api/recordings_controller.rb +++ b/app/controllers/api/recordings_controller.rb @@ -1,5 +1,5 @@ class Api::RecordingsController < ApiController - protect_from_forgery except: %i(create download) + protect_from_forgery except: %i(create) before_action :set_recording, only: [:show, :edit, :update, :destroy] # GET /api/recordings/ @@ -33,7 +33,7 @@ def create else if @recording.dupe.present? @recording = @recording.dupe[0] - + if @recording.update(recording_params) format.json { render :show, status: :ok } else diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8e33b479..cfa87c1c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,5 +27,4 @@ def authenticate_api_key! end render json: { errors: 'No or invalid API key. Please add "Authorization: Token token=xxx" header or api_key=xxx param in URL or JSON request body.' }, :status => :forbidden if keys.nil? end - end diff --git a/app/controllers/concerns/api_error_responses.rb b/app/controllers/concerns/api_error_responses.rb index 9b9876c9..47631181 100644 --- a/app/controllers/concerns/api_error_responses.rb +++ b/app/controllers/concerns/api_error_responses.rb @@ -7,7 +7,6 @@ module ApiErrorResponses rescue_from ActionController::RoutingError, with: :record_not_found before_action { |controller| set_header(controller) } - end private @@ -37,4 +36,3 @@ def set_header(controller) end end end - diff --git a/app/controllers/concerns/throttle_connections.rb b/app/controllers/concerns/throttle_connections.rb index 4fbce37f..2e8220f5 100644 --- a/app/controllers/concerns/throttle_connections.rb +++ b/app/controllers/concerns/throttle_connections.rb @@ -5,6 +5,7 @@ module ThrottleConnections def throttle?(recording_view) return false if Rails.env.test? + Rails.cache.exist?(cache_key(recording_view)) end diff --git a/app/controllers/frontend/conferences_controller.rb b/app/controllers/frontend/conferences_controller.rb index 4e421086..898962a4 100644 --- a/app/controllers/frontend/conferences_controller.rb +++ b/app/controllers/frontend/conferences_controller.rb @@ -21,6 +21,7 @@ def browse @folders = conferences_folder_tree_at(params[:slug] || '') return redirect_to root_url if @folders.blank? + respond_to do |format| format.html { render :browse } end @@ -51,6 +52,7 @@ def conferences_folder_tree_at(path) tree.build(conferences_with_events.pluck(:id, :slug)) folders = tree.folders_at(path) fail ActiveRecord::RecordNotFound unless folders + tree.sort_folders(folders) end @@ -60,12 +62,14 @@ def conferences_with_events def sort_param return SORT_PARAM[@sorting] if @sorting + 'view_count desc' end def check_sort_param return unless params[:sort] return unless SORT_PARAM.keys.include?(params[:sort]) + @sorting = params[:sort] end end diff --git a/app/controllers/frontend/events_controller.rb b/app/controllers/frontend/events_controller.rb index b4579a02..c865f71e 100644 --- a/app/controllers/frontend/events_controller.rb +++ b/app/controllers/frontend/events_controller.rb @@ -28,8 +28,8 @@ def postroll # videoplayer suitable for embedding in an iframe def oembed - @width = params[:width] || view_context.aspect_ratio_width - @height = params[:height] || view_context.aspect_ratio_height + @width = params[:width] || @event.conference.aspect_ratio_width + @height = params[:height] || @event.conference.aspect_ratio_height response.headers.delete 'X-Frame-Options' render layout: 'frontend/oembed' end @@ -38,12 +38,13 @@ def oembed def related_events(n) return Event.find(@event.related_event_ids(n)) if @event.metadata['related'].present? + @event.next_from_conference(n) end def load_event @event = Frontend::Event.find_by!( - "slug = ? OR guid = ? OR slug ILIKE ?", + "slug = ? OR guid = ? OR slug ILIKE ?", params[:slug], params[:slug], params[:slug] + '%' ) diff --git a/app/controllers/frontend/news_controller.rb b/app/controllers/frontend/news_controller.rb index 2d295af4..901b53d3 100644 --- a/app/controllers/frontend/news_controller.rb +++ b/app/controllers/frontend/news_controller.rb @@ -1,5 +1,7 @@ module Frontend class NewsController < FrontendController + include ActionView::Helpers::AssetUrlHelper + def index news = News.latest_first atom_feed = Feeds::NewsFeedGenerator.generate(news, @@ -8,7 +10,7 @@ def index title: I18n.t('custom.news_title'), feed_url: news_url, icon: File.join(Settings.frontend_url, 'favicon.ico'), - logo: view_context.image_url('frontend/voctocat.svg') + logo: image_url('frontend/voctocat.svg') }) respond_to do |format| format.xml { render xml: atom_feed } diff --git a/app/controllers/frontend/popular_controller.rb b/app/controllers/frontend/popular_controller.rb index 2613ff83..286a92f8 100644 --- a/app/controllers/frontend/popular_controller.rb +++ b/app/controllers/frontend/popular_controller.rb @@ -21,6 +21,5 @@ def index respond_to { |format| format.html } end - end end diff --git a/app/controllers/frontend/recent_controller.rb b/app/controllers/frontend/recent_controller.rb index c363aa17..638b3713 100644 --- a/app/controllers/frontend/recent_controller.rb +++ b/app/controllers/frontend/recent_controller.rb @@ -5,6 +5,5 @@ def index respond_to { |format| format.html } end - end end diff --git a/app/controllers/frontend/tags_controller.rb b/app/controllers/frontend/tags_controller.rb index abd37510..a348522f 100644 --- a/app/controllers/frontend/tags_controller.rb +++ b/app/controllers/frontend/tags_controller.rb @@ -3,6 +3,7 @@ class TagsController < FrontendController def show @tag = params[:tag] raise ActiveRecord::RecordNotFound unless @tag + # TODO native postgresql query? @events = Frontend::Event.all.select { |event| event.tags.include? @tag } respond_to { |format| format.html } diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb index 4e57cd31..58677e77 100644 --- a/app/controllers/graphql_controller.rb +++ b/app/controllers/graphql_controller.rb @@ -1,6 +1,6 @@ class GraphqlController < ApplicationController - skip_before_action :verify_authenticity_token - + skip_before_action :verify_authenticity_token + def execute variables = ensure_hash(params[:variables]) query = params[:query] diff --git a/app/controllers/public/conferences_controller.rb b/app/controllers/public/conferences_controller.rb index 02006d50..3d6166be 100644 --- a/app/controllers/public/conferences_controller.rb +++ b/app/controllers/public/conferences_controller.rb @@ -24,6 +24,7 @@ def show @conference = Conference.find_by(acronym: params[:id]) end fail ActiveRecord::RecordNotFound unless @conference + respond_to { |format| format.json } end end diff --git a/app/controllers/public/events_controller.rb b/app/controllers/public/events_controller.rb index c900c271..7b049e84 100644 --- a/app/controllers/public/events_controller.rb +++ b/app/controllers/public/events_controller.rb @@ -47,6 +47,7 @@ def show end fail ActiveRecord::RecordNotFound unless @event + respond_to { |format| format.json } end diff --git a/app/controllers/public_controller.rb b/app/controllers/public_controller.rb index a1c5e34b..f7319df1 100644 --- a/app/controllers/public_controller.rb +++ b/app/controllers/public_controller.rb @@ -22,6 +22,7 @@ def oembed def parse_url_param return unless params[:url] + uri = URI.parse(params[:url]) return unless allowed_url?(uri) @@ -30,8 +31,8 @@ def parse_url_param fail ActiveRecord::RecordNotFound unless recording @conference = @event.conference - @width = recording.min_width(params[:maxwidth] || view_context.aspect_ratio_width) - @height = recording.min_height(params[:maxheight] || view_context.aspect_ratio_height) + @width = recording.min_width(params[:maxwidth] || @event.conference.aspect_ratio_width) + @height = recording.min_height(params[:maxheight] || @event.conference.aspect_ratio_height) true rescue URI::InvalidURIError false @@ -41,6 +42,7 @@ def allowed_url?(uri) return true unless Rails.env.production? return if uri.host != Settings.frontend_host return unless uri.path.starts_with?('/v/') + true end diff --git a/app/graphql/resolvers/conference.rb b/app/graphql/resolvers/conference.rb index 091f3edf..431a0260 100644 --- a/app/graphql/resolvers/conference.rb +++ b/app/graphql/resolvers/conference.rb @@ -60,12 +60,8 @@ def apply_order_by_with_created_at_desc(scope) scope.order('created_at DESC') end - def resolve(obj, args, ctx) - # NOTE: Don't run QueryResolver during tests - return super unless ctx.present? - - GraphQL::QueryResolver.run(Conference, ctx, Types::ConferenceType) do - super - end + # TODO this should be converted into a plain ruby class? https://graphql-ruby.org/fields/resolvers.html + def resolve(args) + super end -end \ No newline at end of file +end diff --git a/app/graphql/resolvers/search_lectures.rb b/app/graphql/resolvers/search_lectures.rb index 966d8ccb..c712bca0 100644 --- a/app/graphql/resolvers/search_lectures.rb +++ b/app/graphql/resolvers/search_lectures.rb @@ -3,7 +3,7 @@ class Resolvers::SearchLectures < GraphQL::Schema::Resolver argument :query, String, required: true argument :page, Integer, required: false - + def resolve(query:, page: 1) results = Frontend::Event.query(query).page(page) @events = results.records.includes(recordings: :conference) diff --git a/app/graphql/types/conference_type.rb b/app/graphql/types/conference_type.rb index 9354ecda..0118b885 100644 --- a/app/graphql/types/conference_type.rb +++ b/app/graphql/types/conference_type.rb @@ -1,9 +1,9 @@ module Types class ConferenceType < Types::BaseObject description "This entity groups multiple lectures together, e.g. a Conference or Lecture Series" - field :id, ID, null: false + field :id, ID, null: false field :title, String, "The title of this conference", null: false - field :slug, String, "The URL slug of this conference", null: false + field :slug, String, "The URL slug of this conference", null: false field :lectures, LectureType.connection_type, null: true field :url, UrlType, "A URL pointing to the conference page in vocotweb frontend", null: false @@ -11,7 +11,7 @@ class ConferenceType < Types::BaseObject field :logo_url, UrlType, "A URL pointing to the conference's logo", null: true field :aspect_ratio, String, "The aspect ratio of the conference's recordings", null: false # TODO: Enum #field :recordings_url, UrlType, "A URL pointing to the root of all recording files of this conference", null: false - field :schedule_url, UrlType, "A URL pointing to the conference's frab xml schedule", null: true + field :schedule_url, UrlType, "A URL pointing to the conference's frab xml schedule", null: true field :updated_at, DateTimeType, "Identifies the date and time when the object was last updated", null: false field :event_last_released_at, DateTimeType, "Identifies the date and time when a event was last released", null: true @@ -27,5 +27,4 @@ def url Rails.application.routes.url_helpers.conference_url(acronym: object.acronym) end end - end diff --git a/app/graphql/types/date_time_type.rb b/app/graphql/types/date_time_type.rb index 5c39d295..f8eac2df 100644 --- a/app/graphql/types/date_time_type.rb +++ b/app/graphql/types/date_time_type.rb @@ -1,6 +1,5 @@ module Types class DateTimeType < GraphQL::Types::ISO8601DateTime graphql_name 'DateTime' - end end diff --git a/app/graphql/types/json_type.rb b/app/graphql/types/json_type.rb index dd6d025b..0f6fca54 100644 --- a/app/graphql/types/json_type.rb +++ b/app/graphql/types/json_type.rb @@ -2,19 +2,20 @@ module Types class JsonType < GraphQL::Types::String description "A untyped JSON document" graphql_name 'JSON' - + def self.coerce_input(input_value, context) # TODO check if input_value is already pared or not data = JSON.parse(input_value) if data.nil? raise GraphQL::CoercionError, "#{input_value.inspect} is not a valid JSON" end + # It's valid, return the URI object data end - + def self.coerce_result(ruby_value, context) ruby_value end end -end \ No newline at end of file +end diff --git a/app/graphql/types/lecture_type.rb b/app/graphql/types/lecture_type.rb index e5674c3b..85d941bd 100644 --- a/app/graphql/types/lecture_type.rb +++ b/app/graphql/types/lecture_type.rb @@ -2,16 +2,15 @@ # alternate Name: Lecture, Talk? module Types - class LectureType < Types::BaseObject description 'This entity is an Event with multiple Files e.g. Video and Audio recordings, subtitles (SRT) as well as PDFs e.g. the lecture slides' - field :guid, ID, null: false + field :guid, ID, null: false field :local_id, Integer, null: false # field :conference, Types::ConferenceType, "The conference this event belongs to", null: false - field :title, String, "The title of this event", null: false - field :subtitle, String, "The event's subtitle that may be displayed below the title", null: true + field :title, String, "The title of this event", null: false + field :subtitle, String, "The event's subtitle that may be displayed below the title", null: true field :description, String, "The event's description", null: true field :slug, UrlType, "The URL slug of this event", null: false @@ -33,7 +32,6 @@ class LectureType < Types::BaseObject field :link, UrlType, "URL pointing to the conference event website", null: true field :doi_url, UrlType, "Digital Object Identifier (DOI) e.g. https://doi.org/10.5446/19566", null: true - field :video_preferred, ResourceType, null: false field :videos, [ResourceType], null: false field :audios, [ResourceType], null: true @@ -42,12 +40,12 @@ class LectureType < Types::BaseObject field :files, ResourceType.connection_type, null: false # field :thumbnail, Types::ImageType, null: true - class LectureImageType < Types::BaseObject + class LectureImageType < Types::BaseObject field :poster_url, UrlType, 'URL pointing to a preview/poster image of the event', null: true field :thumb_url, UrlType, 'URL pointing to a smaller version of the poster image', null: true end field :images, LectureImageType, null: true - def images + def images object end @@ -56,12 +54,12 @@ class LectureTimelensType < Types::BaseObject field :thumbnails_url, UrlType, 'URL pointing to scrubbing thumbnails for timelens/timeline', null: true end field :timelens, LectureTimelensType, null: true - def timelens + def timelens object end field :player_config, JsonType, null: true - def player_config + def player_config { sources: object.clappr_sources, subtitles: object.clappr_subtitles } end diff --git a/app/graphql/types/url_type.rb b/app/graphql/types/url_type.rb index 82bd5a03..ab447601 100644 --- a/app/graphql/types/url_type.rb +++ b/app/graphql/types/url_type.rb @@ -2,7 +2,7 @@ module Types class UrlType < GraphQL::Types::String description "A valid URL, transported as a string" graphql_name 'URL' - + def self.coerce_input(input_value, context) # Parse the incoming object into a `URI` url = URI.parse(input_value) @@ -13,10 +13,10 @@ def self.coerce_input(input_value, context) raise GraphQL::CoercionError, "#{input_value.inspect} is not a valid URL" end end - + def self.coerce_result(ruby_value, context) # It's transported as a string, so stringify it ruby_value.to_s end end -end \ No newline at end of file +end diff --git a/app/helpers/frontend/application_helper.rb b/app/helpers/frontend/application_helper.rb index 8fcdebb6..d712c22c 100644 --- a/app/helpers/frontend/application_helper.rb +++ b/app/helpers/frontend/application_helper.rb @@ -34,6 +34,7 @@ def breadcrumbs_trail end parts = path.split('/') return if parts.blank? + if @playlist parts += ['playlist'] elsif @event @@ -74,33 +75,6 @@ def video_for_flash(recordings) end end - def aspect_ratio_width(high = true) - case @conference.aspect_ratio - when /16:9/ - high ? '640' : '188' - when /4:3/ - high ? '400' : '120' - end - end - - def aspect_ratio_height(high = true) - case @conference.aspect_ratio - when /16:9/ - high ? '360' : '144' - when /4:3/ - high ? '300' : '90' - end - end - - def aspect_ratio_height_vw - case @conference.aspect_ratio - when /16:9/ - '56.25vw' - when /4:3/ - '75vw' - end - end - def persons_icon(persons) if persons.length <= 1 'icon-user-light'.freeze diff --git a/app/helpers/frontend/event_recording_filter_high_quality.rb b/app/helpers/frontend/event_recording_filter_high_quality.rb index c656aba2..6f3f4464 100644 --- a/app/helpers/frontend/event_recording_filter_high_quality.rb +++ b/app/helpers/frontend/event_recording_filter_high_quality.rb @@ -6,4 +6,4 @@ def filter_by_quality(recordings) } end end -end \ No newline at end of file +end diff --git a/app/helpers/frontend/event_recording_filter_low_quality.rb b/app/helpers/frontend/event_recording_filter_low_quality.rb index 449eff5b..1f0a43a7 100644 --- a/app/helpers/frontend/event_recording_filter_low_quality.rb +++ b/app/helpers/frontend/event_recording_filter_low_quality.rb @@ -6,4 +6,4 @@ def filter_by_quality(recordings) .sort { |recording_a,recording_b| recording_b.number_of_pixels - recording_a.number_of_pixels } end end -end \ No newline at end of file +end diff --git a/app/helpers/frontend/feeds_navigation_bar_structure_helper.rb b/app/helpers/frontend/feeds_navigation_bar_structure_helper.rb index 368fc7da..cd84329b 100644 --- a/app/helpers/frontend/feeds_navigation_bar_structure_helper.rb +++ b/app/helpers/frontend/feeds_navigation_bar_structure_helper.rb @@ -13,7 +13,7 @@ def feed_structure { :left => { :content => 'Podcast audio feed of the last year', :href => '/podcast-audio-only.xml' } }, { :left => { :content => 'Podcast archive feed, everything older than two years', :href => '/podcast-archive-hq.xml' }, :right => - { :content => SD_LABEL, :href => '/podcast-archive-lq.xml', :title => 'Podcast archive feed, everything older than two years (SD)'} } ] + { :content => SD_LABEL, :href => '/podcast-archive-lq.xml', :title => 'Podcast archive feed, everything older than two years (SD)'} } ] if @conference && @conference.downloaded_events_count > 0 menu += add_feeds_for_conference_recordings(@conference) @@ -51,7 +51,6 @@ def add_feeds_for_conference_recordings(conference) } }) end - end unless sub_menu.empty? @@ -60,6 +59,5 @@ def add_feeds_for_conference_recordings(conference) sub_menu end - end end diff --git a/app/helpers/frontend/tagging_helper.rb b/app/helpers/frontend/tagging_helper.rb index 81aa6bb2..7f699b95 100644 --- a/app/helpers/frontend/tagging_helper.rb +++ b/app/helpers/frontend/tagging_helper.rb @@ -1,7 +1,6 @@ module Frontend # Set the tags attribute on items to use this helper module TaggingHelper - # link to tag page def link_for_global(tag, css: '') %[] @@ -11,9 +10,9 @@ def link_for(conference, tag, css: '') %[] end - # def tag_cloud return [] if @tags.empty? + tags_hash.map { |tag, count| link_for tag, css: css_class_by_size(count) } @@ -39,6 +38,7 @@ def tags_hash tags = {} @tags.each do |tag, events| next unless tag + tags[tag] = events.count end tags diff --git a/app/helpers/public_json_helper.rb b/app/helpers/public_json_helper.rb index 1602a0b3..dc609114 100644 --- a/app/helpers/public_json_helper.rb +++ b/app/helpers/public_json_helper.rb @@ -1,6 +1,7 @@ module PublicJsonHelper def frontend_event_url(slug: '') return event_url(slug: slug) unless Rails.env.production? + event_url(slug: slug, host: Settings.frontend_host, protocol: Settings.frontend_proto, port: nil) end diff --git a/app/helpers/view_helper.rb b/app/helpers/view_helper.rb index c89fdbdb..341c1ef7 100644 --- a/app/helpers/view_helper.rb +++ b/app/helpers/view_helper.rb @@ -5,6 +5,7 @@ def show_recording_url(recording) def show_folder(label: 'Path', path: '/') return nil if label.empty? + "#{label} (#{path})" end diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb index 07d4ecbe..89c4183f 100644 --- a/app/models/admin_user.rb +++ b/app/models/admin_user.rb @@ -2,6 +2,10 @@ class AdminUser < ApplicationRecord # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable - devise :database_authenticatable, + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable + + def self.ransackable_attributes(*) + %w[email] + end end diff --git a/app/models/api_key.rb b/app/models/api_key.rb index 59ab6257..98b28f04 100644 --- a/app/models/api_key.rb +++ b/app/models/api_key.rb @@ -1,9 +1,16 @@ class ApiKey < ApplicationRecord - before_create :generate_guid def generate_guid self.key = SecureRandom.uuid end + # keep this in sync with filters in app/admin + def self.ransackable_attributes(*) + %w[key description] + end + + def self.ransackable_associations(*) + [] + end end diff --git a/app/models/concerns/elasticsearch_event.rb b/app/models/concerns/elasticsearch_event.rb index d630f537..ca79d416 100644 --- a/app/models/concerns/elasticsearch_event.rb +++ b/app/models/concerns/elasticsearch_event.rb @@ -15,7 +15,7 @@ def as_indexed_json(_options = {}) only: %i[title subtitle description persons length release_date date updated_at slug original_language translations], methods: :remote_id, id: :guid, - include: { + include: { conference: { only: %i[title acronym] }, subtitles: { only: %i[language], methods: :fulltext } } @@ -104,7 +104,7 @@ def query_persons(term) }, boost: 1.2, functions: [ - { gauss: { date: { scale: '730d', decay: 0.9 } } } + { gauss: { date: { scale: '730d', decay: 0.9 } } } ] } } diff --git a/app/models/concerns/fahrplan_parser.rb b/app/models/concerns/fahrplan_parser.rb index 96d4bae9..619b7f32 100644 --- a/app/models/concerns/fahrplan_parser.rb +++ b/app/models/concerns/fahrplan_parser.rb @@ -45,6 +45,5 @@ def get_persons(ev) } persons end - end end diff --git a/app/models/concerns/fahrplan_updater.rb b/app/models/concerns/fahrplan_updater.rb index 29029be7..603012e4 100644 --- a/app/models/concerns/fahrplan_updater.rb +++ b/app/models/concerns/fahrplan_updater.rb @@ -4,9 +4,11 @@ module FahrplanUpdater def fill_event_info return unless conference.downloaded? + fahrplan = FahrplanParser.new(conference.schedule_xml) info = fahrplan.event_info_by_guid[guid] return if info.empty? + update_event_info(info) end @@ -27,6 +29,7 @@ def update_event_info(info) def get_event_url(id) return unless conference.schedule_url.present? + conference.schedule_url.sub('schedule.xml', "events/#{id}.html").freeze end end diff --git a/app/models/concerns/storage.rb b/app/models/concerns/storage.rb index 5f01a236..ef4e6308 100644 --- a/app/models/concerns/storage.rb +++ b/app/models/concerns/storage.rb @@ -23,6 +23,7 @@ class << self def for_url(symbol) "get_#{symbol}_url".freeze end + def for_url_path(symbol) "get_#{symbol}_url_path".freeze end @@ -33,6 +34,7 @@ class PathValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if value.nil? or value.blank? return if File.join('/test'.freeze, value) == File.absolute_path(value, '/test'.freeze) + record.errors.add(attribute, 'not a valid path') end end diff --git a/app/models/conference.rb b/app/models/conference.rb index e3ff8747..7c39b015 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -46,12 +46,18 @@ class Conference < ApplicationRecord end end + # keep this in sync with filters in app/admin/conference.rb + def self.ransackable_attributes(*) + %w[acronym title slug recordings_path images_path updated_at] + end + def set_defaults self.aspect_ratio ||= '16:9' end def download! return unless schedule_url + ScheduleDownloadWorker.perform_async(id) end @@ -103,20 +109,50 @@ def recordings_url File.join(Settings.cdn_url, recordings_path).freeze end + def aspect_ratio_width(high = true) + case aspect_ratio + when /16:9/ + high ? '640' : '188' + when /4:3/ + high ? '400' : '120' + end + end + + def aspect_ratio_height(high = true) + case aspect_ratio + when /16:9/ + high ? '360' : '144' + when /4:3/ + high ? '300' : '90' + end + end + + def aspect_ratio_height_vw + case aspect_ratio + when /16:9/ + '56.25vw' + when /4:3/ + '75vw' + end + end + private def logo_exists? return if logo.blank? + true end def slug_reachable return unless Conference.pluck(:slug).any? { |s| s.starts_with?(slug + '/') } + errors.add :slug, "can't add conference below another conference" end def schedule_url_valid return unless schedule_url + URI.parse(schedule_url) rescue URI::Exception errors.add :schedule_url, 'not a valid url' diff --git a/app/models/event.rb b/app/models/event.rb index 50b2a2be..c298fcbc 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -19,8 +19,8 @@ class Event < ApplicationRecord before_validation :strip_prefix, :only => [:doi] - serialize :persons, Array - serialize :tags, Array + serialize :persons, type: Array, coder: YAML + serialize :tags, type: Array, coder: YAML # get all Events of a Conference with at least one Recording scope :recorded_at, ->(conference) { @@ -57,6 +57,15 @@ class Event < ApplicationRecord # active admin and serialized fields workaround: attr_accessor :persons_raw, :tags_raw + # keep this in sync with filters in app/admin + def self.ransackable_attributes(*) + %w[guid title link conference_id promoted slug tags date release_date updated_at] + end + + def self.ransackable_associations(*) + %w[conference recordings video_recordings] + end + def generate_guid self.guid ||= SecureRandom.uuid end @@ -76,6 +85,7 @@ def self.update_promoted_from_view_count def self.update_view_counts event_ids = recently_viewed_event_ids return unless event_ids.present? + view_count_updated_at = EventViewCount.updated_at connection.execute %{ UPDATE events @@ -204,7 +214,6 @@ def translations video_master.languages - [ original_language ] end - def update_feeds return unless release_date diff --git a/app/models/frontend/conference.rb b/app/models/frontend/conference.rb index 5eef082c..7e1a2077 100644 --- a/app/models/frontend/conference.rb +++ b/app/models/frontend/conference.rb @@ -47,6 +47,7 @@ def mime_types def mime_type_names return enum_for(:mime_type_names) unless block_given? + mime_types.map { |mime_type| yield mime_type.freeze, MimeType.mime_type_slug(mime_type) } @@ -54,8 +55,10 @@ def mime_type_names def playlist(event = nil) return events.includes(:conference) unless event + n = events.index(event) return events.includes(:conference) unless n.positive? + events[n..-1] end diff --git a/app/models/frontend/event.rb b/app/models/frontend/event.rb index 3beb6e46..90a00dd3 100644 --- a/app/models/frontend/event.rb +++ b/app/models/frontend/event.rb @@ -44,18 +44,18 @@ def poster_url File.join(Settings.static_url, conference.images_path, poster_filename).freeze elsif relive_present? relive['thumbnail'].freeze - end end + end def thumb_url if thumb_filename_exists? File.join(Settings.static_url, conference.images_path, thumb_filename).freeze elsif relive_present? relive['thumbnail'].freeze - else + else conference.logo_url.freeze - end end + end def timeline_url File.join(Settings.static_url, conference.images_path, timeline_filename).freeze if timelens_present? diff --git a/app/models/frontend/recording.rb b/app/models/frontend/recording.rb index b8721032..92193c29 100644 --- a/app/models/frontend/recording.rb +++ b/app/models/frontend/recording.rb @@ -5,6 +5,7 @@ class Recording < ::Recording def resolution return '' unless height + if height < 720 'sd' elsif height < 1080 diff --git a/app/models/recording.rb b/app/models/recording.rb index 518f9896..d998474a 100644 --- a/app/models/recording.rb +++ b/app/models/recording.rb @@ -6,7 +6,7 @@ class Recording < ApplicationRecord has_one :conference, through: :event has_many :recording_views, dependent: :delete_all - validates :event, :filename, :mime_type, :language, presence: true + validates :event, :filename, :mime_type, :language, presence: true validates :length, presence: true, if: :requires_length validates :width, :height, presence: true, if: :video? validates :folder, length: { minimum: 0, allow_nil: false, message: "can't be nil" } @@ -39,6 +39,15 @@ class Recording < ApplicationRecord has_attached_file :recording, via: :filename, folder: :folder, belongs_into: :recordings, on: :conference + # keep this in sync with filters in app/admin + def self.ransackable_attributes(*) + %w[state mime_type language filename folder html5 high_quality conference_id event_id updated_at] + end + + def self.ransackable_associations(*) + %w[conference event] + end + def video? mime_type.in? MimeType::VIDEO end @@ -67,6 +76,7 @@ def display_name end return id if str.empty? + str end @@ -138,16 +148,16 @@ def languages end def url - if self.mime_type == 'text/vtt' - File.join(Settings.static_url, event.conference.images_path, filename).freeze + if self.mime_type == 'text/vtt' + File.join(Settings.static_url, event.conference.images_path, filename).freeze else File.join(event.conference.recordings_url, folder || '', filename).freeze end end def cors_url - if self.mime_type == 'text/vtt' - File.join(Settings.static_url, event.conference.images_path, filename).freeze + if self.mime_type == 'text/vtt' + File.join(Settings.static_url, event.conference.images_path, filename).freeze else File.join(Settings.cors_url, event.conference.recordings_path, folder || '', filename).freeze end @@ -156,7 +166,7 @@ def cors_url # for elastic search def fulltext puts ' downloading ' + cors_url - begin + begin URI.open(url).read if subtitle? rescue OpenURI::HTTPError puts ' failed with HTTP Error' @@ -168,11 +178,13 @@ def fulltext def language_valid return unless language + errors.add(:language, 'not a valid language') unless languages.all? { |l| Languages.all.include?(l) } end def filename_without_path return unless filename + errors.add :filename, 'not allowed to contain a path' if File.basename(filename) != filename end @@ -190,7 +202,7 @@ def unique_recording self.dupe = event.recordings.select { |recording| recording.filename == filename && recording.folder == folder }.delete_if { |dupe| dupe == self } - end + end if self.dupe.present? errors.add :event, 'recording already exist on event' diff --git a/app/models/web_feed.rb b/app/models/web_feed.rb index bf185ad6..ac90cc65 100644 --- a/app/models/web_feed.rb +++ b/app/models/web_feed.rb @@ -13,6 +13,7 @@ def self.update_with_lock(time, selector={}) feed = WebFeed.find_or_create_by(selector) feed.with_lock do return if feed.newer?(time) + feed.last_build = time || Time.now yield feed feed.save @@ -25,6 +26,7 @@ def self.folder_key(conference, quality, mime_type) def newer?(date) return unless last_build && date + last_build >= date end diff --git a/app/workers/conference_relive_download_worker.rb b/app/workers/conference_relive_download_worker.rb index a4435d56..27e23bf5 100644 --- a/app/workers/conference_relive_download_worker.rb +++ b/app/workers/conference_relive_download_worker.rb @@ -14,6 +14,7 @@ def perform relive_toc.each do |r| next unless r.key?('media_conference_id') + conference = Conference.find_by(acronym: r['project']) next unless conference @@ -48,6 +49,7 @@ def recently_updated?(date) def protocol_relative_url(url) return url if url.start_with?('http') || url.start_with?('file') + 'https:' + url end end diff --git a/app/workers/conference_streaming_download_worker.rb b/app/workers/conference_streaming_download_worker.rb index 18eaa9fb..3b6791ec 100644 --- a/app/workers/conference_streaming_download_worker.rb +++ b/app/workers/conference_streaming_download_worker.rb @@ -15,6 +15,7 @@ def perform streaming.each do |conference_data| conference = Conference.find_by(acronym: conference_data['slug']) next unless conference + logger.info "updating streaming config for #{conference.acronym}" conference.update(streaming: conference_data) end diff --git a/app/workers/event_update_worker.rb b/app/workers/event_update_worker.rb index 88456570..100b6ae3 100644 --- a/app/workers/event_update_worker.rb +++ b/app/workers/event_update_worker.rb @@ -14,8 +14,10 @@ def perform(ids) fahrplan = fahrplan_for_conference(conference) next unless fahrplan + info = event_info(fahrplan, event.guid) next unless info.present? + event.update_event_info(info) end end diff --git a/app/workers/feed/archive_worker.rb b/app/workers/feed/archive_worker.rb index 77dc9b90..2f4d6c75 100644 --- a/app/workers/feed/archive_worker.rb +++ b/app/workers/feed/archive_worker.rb @@ -18,7 +18,6 @@ def perform(*args) def build(events, quality) generator = Feeds::PodcastGenerator.new( - view_context, title: "archive feed (#{Frontend::FeedQuality.display_name(quality)})", channel_summary: ' This feed contains events older than two years', logo_image: logo_image_url diff --git a/app/workers/feed/base.rb b/app/workers/feed/base.rb index 1c7339d2..65fd4ced 100644 --- a/app/workers/feed/base.rb +++ b/app/workers/feed/base.rb @@ -1,4 +1,11 @@ class Feed::Base + include ActionView::Helpers + + def initialize + Rails.application.routes.default_url_options[:host] = Settings.frontend_host + Rails.application.routes.default_url_options[:protocol] = Settings.frontend_proto + end + def self.key(n) @name = n end @@ -35,23 +42,12 @@ def last_year WebFeed.last_year end - def view_context - # conference_url, event_url, image_url - view = ActionView::Base.new(ActionController::Base.view_paths, {}, nil) - view.class.include Rails.application.routes.url_helpers - view.class.include ApplicationHelper - Rails.application.routes.default_url_options[:host] = Settings.frontend_host - Rails.application.routes.default_url_options[:protocol] = Settings.frontend_proto - view - end - def logo_image_url - view_context.image_url('frontend/feed-banner.png') + image_url('frontend/feed-banner.png') end def generator Feeds::PodcastGenerator.new( - view_context, title: self.class.get_title, channel_summary: self.class.get_summary, logo_image: logo_image_url diff --git a/app/workers/feed/folder_worker.rb b/app/workers/feed/folder_worker.rb index 4f3f0422..7da13735 100644 --- a/app/workers/feed/folder_worker.rb +++ b/app/workers/feed/folder_worker.rb @@ -1,5 +1,6 @@ class Feed::FolderWorker < Feed::Base include Sidekiq::Worker + include Rails.application.routes.url_helpers key :podcast_folder @@ -31,11 +32,10 @@ def perform(*args) def build(conference, mime_type, mime_type_name, quality) quality_display_name = Frontend::FeedQuality.display_name(quality) generator = Feeds::PodcastGenerator.new( - view_context, title: "#{conference.title} (#{[quality_display_name, mime_type_name].reject(&:empty?).join(' ')})", channel_summary: " This feed contains all events from #{conference.acronym} as #{mime_type_name}", channel_description: " This feed contains all events from #{conference.acronym} as #{mime_type_name}", - base_url: view_context.conference_url(acronym: conference.acronym), + base_url: conference_url(acronym: conference.acronym), logo_image: conference.logo_url ) generator.generate(conference.events.released.includes(:conference)) do |event| diff --git a/app/workers/feed/podcast_worker.rb b/app/workers/feed/podcast_worker.rb index 36340146..c9d1d2b0 100644 --- a/app/workers/feed/podcast_worker.rb +++ b/app/workers/feed/podcast_worker.rb @@ -18,7 +18,6 @@ def perform(*args) def build(events, quality) generator = Feeds::PodcastGenerator.new( - view_context, title: "recent events feed (#{Frontend::FeedQuality.display_name(quality)})", channel_summary: ' This feed contains events from the last two years', logo_image: logo_image_url diff --git a/app/workers/feed/recent_worker.rb b/app/workers/feed/recent_worker.rb index 43f28b0b..bd7f807e 100644 --- a/app/workers/feed/recent_worker.rb +++ b/app/workers/feed/recent_worker.rb @@ -10,7 +10,6 @@ def perform(*args) start_time = events.maximum(:updated_at) generator = Feeds::RdfGenerator.new( - view_context: view_context, config: { title: self.class.get_title, channel_summary: self.class.get_summary, diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 00000000..40330c0f --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup index ec47b79b..1c309716 100755 --- a/bin/setup +++ b/bin/setup @@ -1,11 +1,11 @@ #!/usr/bin/env ruby require "fileutils" -# path to your application root. APP_ROOT = File.expand_path("..", __dir__) +APP_NAME = "media-backend" def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do @@ -30,4 +30,8 @@ FileUtils.chdir APP_ROOT do puts "\n== Restarting application server ==" system! "bin/rails restart" + + # puts "\n== Configuring puma-dev ==" + # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" + # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" end diff --git a/config/application.rb b/config/application.rb index 28802c96..fcc3d8b3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,38 +6,31 @@ # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -Dotenv::Railtie.load +Dotenv::Rails.load module MediaBackend class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 + config.load_defaults 7.2 + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w(assets tasks)) # Configuration for the application, engines, and railties goes here. # # These settings can be overridden in specific environments using the files # in config/environments, which are processed later. - config.eager_load_paths << Rails.root.join('lib') - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - # config.time_zone = 'Central Time (US & Canada)' config.time_zone = 'Berlin' - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de + config.eager_load_paths << Rails.root.join('lib') # use custom error pages config.exceptions_app = self.routes config.app_generators.scaffold_controller = :scaffold_controller - # Settings in config/environments/* take precedence over those specified here. - # Application configuration can go into files in config/initializers - # -- all .rb files in that directory are automatically loaded after loading - # the framework and any gems in your application. config.custom_css = nil end diff --git a/config/boot.rb b/config/boot.rb index d69bd27d..28201161 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/config/deploy.rb b/config/deploy.rb index e4032607..c81c6142 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -11,7 +11,7 @@ # https://github.com/capistrano/rvm/ # set :rvm_type, :user # Defaults to: :auto -set :rvm_ruby_version, '3.0.3' +set :rvm_ruby_version, '3.3' set :use_sudo, false set :stage, :production @@ -71,7 +71,6 @@ before :start, :make_dirs end - namespace :deploy do desc 'Initial Deploy' task :initial do diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 46697736..579a3b27 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -21,8 +21,6 @@ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value # role :db, %w{deploy@example.com} - - # Configuration # ============= # You can set any configuration variable like in config/deploy.rb @@ -31,8 +29,6 @@ # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. - - # Custom SSH Options # ================== # You may pass any option but keep in mind that net/ssh understands a diff --git a/config/environments/development.rb b/config/environments/development.rb index 32aafe8e..a141bd66 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,7 +6,7 @@ # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -14,7 +14,7 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing + # Enable server timing. config.server_timing = true # Enable/disable caching. By default caching is disabled. @@ -24,9 +24,7 @@ config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.to_i}" - } + config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -39,8 +37,12 @@ # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: "localhost", port: 3000 } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -56,6 +58,9 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + # Suppress logger output for asset requests. config.assets.quiet = true @@ -63,11 +68,17 @@ # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true + config.action_view.annotate_rendered_view_with_filenames = true # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true + + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + config.generators.apply_rubocop_autocorrect_after_generate! + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. @@ -84,6 +95,7 @@ end if ENV['DEV_DOMAIN'] + config.hosts << 'voctoweb-docker' config.hosts << ENV['DEV_DOMAIN'] end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 3633ddbb..ae12f866 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -13,15 +13,14 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. @@ -33,7 +32,7 @@ # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass - # Do not fallback to assets pipeline if a precompiled asset is missed. + # Do not fall back to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. @@ -51,31 +50,41 @@ # config.action_cable.url = "wss://example.com/cable" # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true + + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - #config.log_level = :info - config.log_level = if ENV['RAILS_LOG_LEVEL'].present? - ENV['RAILS_LOG_LEVEL'].to_sym - else - :info - end + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + # Use a different cache store in production. # config.cache_store = :mem_cache_store # https://guides.rubyonrails.org/caching_with_rails.html#activesupport-cache-rediscachestore - config.cache_store = :redis_store, 'redis://localhost:6379/0/cache', { expires_in: 7.days } + config.cache_store = :redis_cache_store, { url: 'redis://localhost:6379/0' } config.active_record.cache_versioning = false # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque + # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "media_backend_production" + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. @@ -89,30 +98,14 @@ # Don't log any deprecations. config.active_support.report_deprecations = false - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # Log disallowed deprecations. - config.active_support.disallowed_deprecation = :log - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Use a different logger for distributed setups. - # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") - - if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - else - config.lograge.enabled = true - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 21759bc9..757f534c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,27 +8,26 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Turn false under Spring and add config.action_view.cache_template_loading = true. - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.to_i}" - } + config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. - config.consider_all_requests_local = true + config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :memory_store - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -36,6 +35,8 @@ # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -43,6 +44,10 @@ # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Unlike controllers, the mailer instance doesn't have any context about the + # incoming request so you'll need to provide the :host parameter yourself. + config.action_mailer.default_url_options = { host: "www.example.com" } + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr @@ -57,4 +62,7 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb index f6c0cda4..79ca83ef 100644 --- a/config/initializers/active_admin.rb +++ b/config/initializers/active_admin.rb @@ -1,5 +1,4 @@ ActiveAdmin.setup do |config| - # == Site Title # # Set the title that is displayed on the main layout @@ -57,7 +56,6 @@ # within the controller. config.authentication_method = :authenticate_admin_user! - # == Current User # # Active Admin will associate actions with the current @@ -67,7 +65,6 @@ # to return the currently logged in user. config.current_user_method = :current_admin_user - # == Logging Out # # Active Admin displays a logout link on each screen. These @@ -86,7 +83,6 @@ # Default: # config.logout_link_method = :get - # == Root # # Set the action to call for the root path. You can set different @@ -95,14 +91,12 @@ # Default: config.root_to = 'conferences#index' - # == Batch Actions # # Enable and disable Batch Actions # config.batch_actions = true - # == Controller Filters # # You can add before, after and around filters to all of your @@ -111,12 +105,10 @@ # config.before_filter :do_something_awesome config.before_action :deny_request, if: :ssl_configured? - # == Setting a Favicon # # config.favicon = '/assets/favicon.ico' - # == Register Stylesheets & Javascripts # # We recommend using the built in Active Admin layout and loading @@ -129,7 +121,6 @@ # You can provide an options hash for more control, which is passed along to stylesheet_link_tag(): # config.register_stylesheet 'my_print_stylesheet.css', :media => :print - # == CSV options # # Set the CSV builder separator @@ -138,7 +129,6 @@ # Force the use of quotes # config.csv_options = { :force_quotes => true } - # == Menu System # # You can add a navigation menu to be used in your application, or configure a provided menu @@ -160,7 +150,6 @@ # end # end - # == Download Links # # You can disable download links on resource listing pages, @@ -178,7 +167,6 @@ # # end - # == Pagination # # Pagination is enabled by default for all resources. @@ -186,7 +174,6 @@ # config.default_per_page = 20 - # == Filters # # By default the index screen includes a “Filters” sidebar on the right @@ -196,5 +183,4 @@ # config.filters = true config.comments_menu = false - end diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 8f7c2ff5..b3076b38 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -6,19 +6,19 @@ # Rails.application.configure do # config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end # -# # Generate session nonces for permitted importmap and inline scripts +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src) +# config.content_security_policy_nonce_directives = %w(script-src style-src) # # # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index a9a173b9..3435964b 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure parameters to be filtered from the log file. Use this to limit dissemination of -# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported -# notations and behaviors. +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += [ :password, :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] diff --git a/config/initializers/graphql.rb b/config/initializers/graphql.rb index 75a279c4..8487c72e 100644 --- a/config/initializers/graphql.rb +++ b/config/initializers/graphql.rb @@ -6,4 +6,4 @@ class DefinedObjectProxy Rails.application.routes.default_url_options[:protocol] = Settings.frontend_proto end end -end \ No newline at end of file +end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ac033bf9..3860f659 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' +# inflect.acronym "RESTful" # end diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb deleted file mode 100644 index c383d072..00000000 --- a/config/initializers/new_framework_defaults_5_2.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.2 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Make Active Record use stable #cache_key alongside new #cache_version method. -# This is needed for recyclable cache keys. -# Rails.application.config.active_record.cache_versioning = true - -# Use AES-256-GCM authenticated encryption for encrypted cookies. -# Also, embed cookie expiry in signed or encrypted cookies for increased security. -# -# This option is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 5.2. -# -# Existing cookies will be converted on read then written with the new scheme. -# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true - -# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages -# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true. -# Rails.application.config.active_support.use_authenticated_message_encryption = true - -# Add default protection from forgery to ActionController::Base instead of in -# ApplicationController. -# Rails.application.config.action_controller.default_protect_from_forgery = true - -# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and -# 'f' after migrating old data. -# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true - -# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. -# Rails.application.config.active_support.use_sha1_digests = true - -# Make `form_with` generate id attributes for any generated HTML tags. -# Rails.application.config.action_view.form_with_generates_ids = true diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb deleted file mode 100644 index 9526b835..00000000 --- a/config/initializers/new_framework_defaults_6_1.rb +++ /dev/null @@ -1,67 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Support for inversing belongs_to -> has_many Active Record associations. -# Rails.application.config.active_record.has_many_inversing = true - -# Track Active Storage variants in the database. -# Rails.application.config.active_storage.track_variants = true - -# Apply random variation to the delay when retrying failed jobs. -# Rails.application.config.active_job.retry_jitter = 0.15 - -# Stop executing `after_enqueue`/`after_perform` callbacks if -# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. -# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true - -# Specify cookies SameSite protection level: either :none, :lax, or :strict. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax - -# Generate CSRF tokens that are encoded in URL-safe Base64. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_controller.urlsafe_csrf_tokens = true - -# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an -# UTC offset or a UTC time. -# ActiveSupport.utc_to_local_returns_utc_offset_times = true - -# Change the default HTTP status code to `308` when redirecting non-GET/HEAD -# requests to HTTPS in `ActionDispatch::SSL` middleware. -# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 - -# Use new connection handling API. For most applications this won't have any -# effect. For applications using multiple databases, this new API provides -# support for granular connection swapping. -# Rails.application.config.active_record.legacy_connection_handling = false - -# Make `form_with` generate non-remote forms by default. -# Rails.application.config.action_view.form_with_generates_remote_forms = false - -# Set the default queue name for the analysis job to the queue adapter default. -# Rails.application.config.active_storage.queues.analysis = nil - -# Set the default queue name for the purge job to the queue adapter default. -# Rails.application.config.active_storage.queues.purge = nil - -# Set the default queue name for the incineration job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.incineration = nil - -# Set the default queue name for the routing job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.routing = nil - -# Set the default queue name for the mail deliver job to the queue adapter default. -# Rails.application.config.action_mailer.deliver_later_queue_name = nil - -# Generate a `Link` header that gives a hint to modern browsers about -# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. -# Rails.application.config.action_view.preload_links_header = true diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb deleted file mode 100644 index 4d580245..00000000 --- a/config/initializers/new_framework_defaults_7_0.rb +++ /dev/null @@ -1,135 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.0 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.0`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -# `button_to` view helper will render `