Skip to content

Commit

Permalink
Rails 8 compatibility, Ruby 3.4.1 compatibility
Browse files Browse the repository at this point in the history
- Rails 8 now supported
- Rails 6 no longer supported
  • Loading branch information
avonderluft committed Dec 26, 2024
1 parent 80db548 commit a915b28
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ jobs:
strategy:
matrix:
ruby-version:
- "3.1"
- "3.2"
- "3.3"
- "3.4"
rails-version:
- "7.1"
- "7.2"
- "8.0"
continue-on-error: [true]
name: ${{ format('Tests (Ruby {0}, Rails {1})', matrix.ruby-version, matrix.rails-version) }}
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require:
# - rubocop-minitest

AllCops:
TargetRubyVersion: 3.0
TargetRubyVersion: 3.2
NewCops: enable
Exclude:
- bin/*
Expand Down Expand Up @@ -59,6 +59,9 @@ Style/Documentation:
Style/DocumentDynamicEvalDefinition:
Enabled: false

Style/HashSyntax:
Enabled: false

Style/IfUnlessModifier:
Enabled: false

Expand Down
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ For all changes prior to the inception of this project, see the [Release History

## [Unreleased]

Changes since the last non-beta release.
- [Remove sassc sprockets](https://github.com/shakacode/comfortable-media-surfer/pull/4)

_Please add entries here for your pull requests that have not yet been released._

## [3.0.1] - 2024-12-01
## [3.1.0] - 2024-12-26

### Added

- Added this CHANGELOG
- Added badges to README for CI build, Test Coverage, Gem version, Gem downloads, and last release
- Deprecated Rails 6.x support, since it is not being maintained as of October 2024
- Added compatibility and support for Rails 8
- Added documentation to README for converting from the older CMSs
- Updated README links to the Surfer wiki

## [3.0.0] - 2024-11-30

Expand Down
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gemspec

gem 'rails', '~> 7.2'
gem 'rails', '~> 8.0'

group :development, :test do
gem 'autoprefixer-rails', '~> 10.4.16.0'
gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw]
gem 'gem-release'
gem 'image_processing', '>= 1.12.0'
gem 'sqlite3', '~> 1.6.7'
gem 'sqlite3', '>= 2.1'
# gem 'mysql2', '~> 0.5'
# gem 'pg', '~> 1.5.4'
end
Expand All @@ -31,6 +31,7 @@ group :test do
gem 'minitest', '>= 5.23.0'
gem 'minitest-reporters', '>= 1.6.1'
gem 'mocha', '>= 2.3.0', require: false
gem 'ostruct'
gem 'rails-controller-testing', '~> 1.0.5'
gem 'rubocop', '~> 1.63.0', require: false
gem 'rubocop-minitest'
Expand Down
68 changes: 50 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Rails CI](https://github.com/shakacode/comfortable-media-surfer/actions/workflows/rubyonrails.yml/badge.svg)](https://github.com/shakacode/comfortable-media-surfer/actions/workflows/rubyonrails.yml)
[![Coverage Status](https://coveralls.io/repos/github/shakacode/comfortable-media-surfer/badge.svg?branch=master)](https://coveralls.io/github/shakacode/comfortable-media-surfer?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/shakacode/comfortable-media-surfer/badge.svg?branch=HEAD)](https://coveralls.io/github/shakacode/comfortable-media-surfer?branch=HEAD)
[![Gem Version](https://img.shields.io/gem/v/comfortable_media_surfer.svg?style=flat)](http://rubygems.org/gems/comfortable_media_surfer)
[![Gem Downloads](https://img.shields.io/gem/dt/comfortable_media_surfer.svg?style=flat)](http://rubygems.org/gems/comfortable_media_surfer)
[![GitHub Release Date - Published_At](https://img.shields.io/github/release-date/shakacode/comfortable-media-surfer?label=last%20release&color=seagreen)](https://github.com/shakacode/comfortable-media-surfer/releases)
Expand All @@ -11,19 +11,19 @@ ComfortableMediaSurfer is a powerful Ruby 7.0+ CMS (Content Management System) E
## Features

- Simple drop-in integration with Rails 7.0+ apps with minimal configuration
- The CMS keeps clear from the rest of your application
- Powerful page templating capability using [Content Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags)
- [Multiple Sites](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Sites) from a single installation
- Multi-Language Support (i18n) (ca, cs, da, de, en, es, fi, fr, gr, hr, it, ja, nb, nl, pl, pt-BR, ru, sv, tr, uk, zh-CN, zh-TW) and page localization.
- [CMS Seeds](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-CMS-Seeds) for initial content population
- [Revision History](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Revisions) to revert changes
- [Extendable Admin Area](https://github.com/comfy/comfortable-mexican-sofa/wiki/HowTo:-Reusing-Admin-Area) built with [Bootstrap 4](http://getbootstrap.com) (responsive design). Using [CodeMirror](http://codemirror.net) for HTML and Markdown highlighing and [Redactor](http://imperavi.com/redactor) as the WYSIWYG editor.
* The CMS keeps clear from the rest of your application
* Powerful page templating capability using [Content Tags](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-Content-Tags)
* [Multiple Sites](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-Sites) from a single installation
* Multi-Language Support (i18n) (ca, cs, da, de, en, es, fi, fr, gr, hr, it, ja, nb, nl, pl, pt-BR, ru, sv, tr, uk, zh-CN, zh-TW) and page localization.
* [CMS Seeds](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-CMS-Seeds) for initial content population
* [Revision History](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-Revisions) to revert changes
* [Extendable Admin Area](https://github.com/shakacode/comfortable-media-surfer/wiki/HowTo:-Reusing-Admin-Area) built with [Bootstrap 4](http://getbootstrap.com) (responsive design). Using [CodeMirror](http://codemirror.net) for HTML and Markdown highlighing and [Redactor](http://imperavi.com/redactor) as the WYSIWYG editor.

## Dependencies

- File attachments are handled by [ActiveStorage](https://github.com/rails/rails/tree/master/activestorage). Make sure that you can run appropriate migrations by running: `rails active_storage:install`
- Image resizing is done with with [ImageMagick](http://www.imagemagick.org/script/download.php), so make sure it's installed.
- Pagination is handled by [kaminari](https://github.com/amatsuda/kaminari) or [will_paginate](https://github.com/mislav/will_paginate). Please add one of those to your Gemfile.
- Pagination is handled by [kaminari](https://github.com/amatsuda/kaminari).

## Compatibility

Expand All @@ -34,14 +34,16 @@ On Ruby 3.x, Rails 7.x +
Add gem definition to your Gemfile:

```ruby
gem "comfortable_media_surfer", "~> 3.0.0"
gem "comfortable_media_surfer", "~> 3.1.0"
```

Then from the Rails project's root run:

```
bundle install
rails generate comfy:cms
rake db:migrate
```

Now take a look inside your `config/routes.rb` file. You'll see where routes attach for the admin area and content serving. Make sure that content serving route appears as a very last item or it will make all other routes to be inaccessible.

Expand All @@ -50,6 +52,40 @@ comfy_route :cms_admin, path: "/admin"
comfy_route :cms, path: "/"
```

## Converting from ComfortableMexicanSofa or Occams

### From Sofa to Surfer

The database structure is the same. Your Sofa project will also need to be upgraded to >= Rails 7.x
Then you should simply be able to update your Gemfile thus, and run bundle

```ruby
gem 'comfortable_media_surfer', '~> 3.1.0'
```

### From Occams to Surfer

Again the project must be >= Rails 7.x. Since the schema is different, executing this SQL should get you set for Surfer

```sql
ALTER TABLE occams_cms_categories RENAME TO comfy_cms_categories;
ALTER TABLE occams_cms_categorizations RENAME TO comfy_cms_categorizations;
ALTER TABLE occams_cms_files RENAME TO comfy_cms_files;
ALTER TABLE occams_cms_fragments RENAME TO comfy_cms_fragments;
ALTER TABLE occams_cms_layouts RENAME TO comfy_cms_layouts;
ALTER TABLE occams_cms_pages RENAME TO comfy_cms_pages;
ALTER TABLE occams_cms_revisions RENAME TO comfy_cms_revisions;
ALTER TABLE occams_cms_sites RENAME TO comfy_cms_sites;
ALTER TABLE occams_cms_snippets RENAME TO comfy_cms_snippets;
ALTER TABLE occams_cms_translations RENAME TO comfy_cms_translations;
UPDATE comfy_cms_fragments SET record_type = 'Comfy::Cms::Page' WHERE record_type = 'Occams::Cms::Page';
UPDATE comfy_cms_fragments SET record_type = 'Comfy::Cms::Layout' WHERE record_type = 'Occams::Cms::Layout';
UPDATE comfy_cms_fragments SET record_type = 'Comfy::Cms::Snippet' WHERE record_type = 'Occams::Cms::Snippet';
UPDATE comfy_cms_revisions SET record_type = 'Comfy::Cms::Page' WHERE record_type = 'Occams::Cms::Page';
UPDATE comfy_cms_revisions SET record_type = 'Comfy::Cms::Layout' WHERE record_type = 'Occams::Cms::Layout';
UPDATE comfy_cms_revisions SET record_type = 'Comfy::Cms::Snippet' WHERE record_type = 'Occams::Cms::Snippet';
```

## Quick Start Guide

After finishing installation you should be able to navigate to http://localhost:3000/admin
Expand All @@ -73,11 +109,8 @@ Once you have a layout, you may start creating pages and populating content. It'

## Documentation

For more information on how to use this CMS please refer to the [Wiki](https://github.com/comfy/comfortable-mexican-sofa/wiki). Section that might be of interest is the entry
on [Content Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags).

[Comfy Demo App](https://github.com/comfy/comfy-demo) also can be used as an
example of a default Rails app with CMS installed.
For more information on how to use this CMS please refer to the [Wiki](https://github.com/shakacode/comfortable-media-surfer/wiki). Section that might be of interest is the entry
on [Content Tags](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-Content-Tags).

## Add-ons

Expand All @@ -86,10 +119,9 @@ If you want to add a Blog functionality to your app take a look at

![Admin Area Preview](doc/preview.jpg)

#### Old Versions
#### Old Versions of ComfortableMexicanSofa

[CHANGELOG](//github.com/comfy/comfortable-mexican-sofa/releases) is documented
in Github releases.
[CHANGELOG](//github.com/comfy/comfortable-mexican-sofa/releases) is documented in ComfortableMexicanSofa Github releases.

#### Contributing

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/comfy/admin/cms_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module Comfy
module Admin
module CmsHelper
# Wrapper around Comfy::FormBuilder
def comfy_form_with(**options, &block)
def comfy_form_with(**options, &)
form_options = options.merge(builder: ComfortableMediaSurfer::FormBuilder)
form_options[:bootstrap] = { layout: :horizontal }
form_options[:local] = true
bootstrap_form_with(**form_options, &block)
bootstrap_form_with(**form_options, &)
end

def comfy_admin_partial(path, params = {})
Expand Down
2 changes: 1 addition & 1 deletion comfortable_media_surfer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
f.match(%r{^(test|doc)/})
end

spec.required_ruby_version = '>= 3.0.0'
spec.required_ruby_version = '>= 3.2.0'
spec.metadata['rubygems_mfa_required'] = 'true'

spec.add_dependency 'active_link_to', '~> 1.0', '>= 1.0.5'
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Application < Rails::Application
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0')
config.active_record.default_column_serializer = YAML
config.active_record.before_committed_on_all_records = false
config.active_record.commit_transaction_on_non_local_return = false
# config.active_record.commit_transaction_on_non_local_return = false # deprecated in Rails 8
config.active_record.run_after_transaction_callbacks_in_order_defined = false
config.active_support.message_serializer = :json
config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = true
Expand Down
18 changes: 11 additions & 7 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@
# 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.
# Run rails dev:cache to toggle caching.
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
# Run rails dev:cache to toggle Action Controller caching.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
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

config.cache_store = :null_store
end

Expand All @@ -41,8 +38,12 @@
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

# Make template changes take effect immediately.
config.action_mailer.perform_caching = false

# Set localhost to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

Expand Down Expand Up @@ -77,4 +78,7 @@
# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true
end

# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
# config.generators.apply_rubocop_autocorrect_after_generate!
end
43 changes: 43 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
#
# Puma starts a configurable number of processes (workers) and each process
# serves each request in a thread from an internal thread pool.
#
# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
# should only set this value when you want to run 2 or more workers. The
# default is already 1.
#
# The ideal number of threads per worker depends both on how much time the
# application spends waiting for IO operations and on how much you wish to
# prioritize throughput over latency.
#
# As a rule of thumb, increasing the number of threads will increase how much
# traffic a given process can handle (throughput), but due to CRuby's
# Global VM Lock (GVL) it has diminishing returns and will degrade the
# response time (latency) of the application.
#
# The default is set to 3 threads as it's deemed a decent compromise between
# throughput and latency for the average Rails application.
#
# Any libraries that use a connection pool or another resource pool should
# be configured to provide at least as many connections as the number of
# threads. This includes Active Record's `pool` parameter in `database.yml`.
threads_count = ENV.fetch('RAILS_MAX_THREADS', 3)
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch('PORT', 3000)

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart

# Run the Solid Queue supervisor inside of Puma for single-server deployments
plugin :solid_queue if ENV['SOLID_QUEUE_IN_PUMA']

# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV['PIDFILE'] if ENV['PIDFILE']
2 changes: 1 addition & 1 deletion gemfiles/7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ group :development, :test do
gem 'autoprefixer-rails', '~> 10.4.16.0'
gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw]
gem 'image_processing', '>= 1.12.0'
gem 'sqlite3', '~> 1.6.7'
gem 'sqlite3', '>= 2.1'
end

group :test do
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ group :development, :test do
gem 'autoprefixer-rails', '~> 10.4.16.0'
gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw]
gem 'image_processing', '>= 1.12.0'
gem 'sqlite3', '~> 1.6.7'
gem 'sqlite3', '>= 2.1'
end

group :test do
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/7.0.gemfile → gemfiles/8.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gemspec path: '../'

gem 'rails', '~> 7.0.0'
gem 'rails', '~> 8.0.1'

group :development, :test do
gem 'autoprefixer-rails', '~> 10.4.16.0'
gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw]
gem 'image_processing', '>= 1.12.0'
gem 'sqlite3', '~> 1.6.7'
gem 'sqlite3', '>= 2.1'
end

group :test do
Expand Down
2 changes: 1 addition & 1 deletion lib/comfortable_media_surfer/extensions/has_revisions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def prepare_revision
return if new_record?

if (respond_to?(:fragments_attributes_changed) && fragments_attributes_changed) ||
!(changed & revision_fields).empty?
!!changed.intersect?(revision_fields)
self.revision_data = revision_fields.each_with_object({}) do |field, c|
c[field] = send("#{field}_was")
end
Expand Down
Loading

0 comments on commit a915b28

Please sign in to comment.