Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 6.0 and CMS 2.1 #865

Open
2 tasks
GBH opened this issue Jan 7, 2019 · 24 comments
Open
2 tasks

Rails 6.0 and CMS 2.1 #865

GBH opened this issue Jan 7, 2019 · 24 comments

Comments

@GBH
Copy link
Member

GBH commented Jan 7, 2019

With upcoming Rails 6.0 sometime in April it seems like a good time to do a version bump. Here are the things that need to happen:

  • Removing Redactor for ActiveText with Trix Wysiwyg. Redactor is not free and I can't bundle latest version anyways. Using wysiwyg that is bundled with Rails is a no-brainer. Need to rework how rich text is stored against fragments as now it needs to live in a separate polymorphic table. (Maybe we can postpone that as we got Redactor 3 license: Redactor 3 #818)
  • Webpacker becomes default replacement for Sprockets so it's time to set up assets in a way that it doesn't conflict with parent app's way of serving assets. I'm thinking of mimicking what ActiveStorage does for its assets. So we'll have default webpack environment and will ship already compiled pack. This makes overriding JS/CSS a bit more complicated.

CMS 2.1 will only support Rails 6.0+ as there are dependencies not found in Rails 5.2

Regarding the timeline. I don't currently maintain any sites that use this CMS, so it's not a priority for me. Any help would be appreciated to keep this project going.

@GBH GBH added the help wanted label Jan 7, 2019
@glebm
Copy link
Contributor

glebm commented Mar 2, 2019

Doesn't Rails still support Sprockets, even if using webpacker?

@GBH
Copy link
Member Author

GBH commented Mar 3, 2019

I haven't really done any legwork yet. From what I understand, engine would manage assets with webpacker like any other app but package compiled pack into /public so it can be referenced when used from the parent app.

This looks like something that makes sense: https://github.com/rails/webpacker/blob/master/docs/engines.md

@skatkov
Copy link

skatkov commented Jul 8, 2019

I've been playing around with Rails 6 -- it does use webpack by default, yeat images are still handled by sprockets.

@JeremiahChurch
Copy link

JeremiahChurch commented Aug 12, 2019

rails 6 rc2 still plays nice and leaves sprockets alone - even when running webpacker with a SPA framework

rails new cmstest --skip-turbolinks --webpacker --webpack=react --database=postgresql

plays plenty nice with the currently published gem of CMS. I can also confirm this works deployed to a production environment - no oddball webpacker configuration or other adjustments. It just works(tm) - bootstrap 4 in CMS admin and the rest of the app is serviced by react, all as expected.

edit: I dug in deeper and found something that doesn't work: file upload - continually creates/destroys/creates/destroys the ActiveStorage::Attachment until the stack gets too deep. I'll dig in to it and see if I can see what's going on

edit2 - found the fix for file uploads #892

@kbroderick
Copy link

kbroderick commented Sep 5, 2019

@tongboy thanks for that fix.

We just upgraded our production site, which relies in part on CMS, to Rails 6. One thing that seems to have happened during the upgrade is a change in Active Storage image URLs, e.g. what was referenced at /rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMUNiQmc9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--25aa53e5f0338980ba775f754d5877a1d9f703cb/SketchSteamboat1998.jpg became /rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMUNiQmc9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--df14d446a48267a1bfe8bd9c23b3450e05d177f9/SketchSteamboat1998.jpg

I'm not sure that this is specifically an Active Storage upgrade issue, a gem upgrade issue, or an unexpected side effect of something we tweaked in the app config for a gem upgrade, but the outcome was a bunch of broken image links because Redactor inserts the public URL rather than linking to the AS object. I understand why it works that way, but I wanted to add this as a caution for testing (we missed it, as we don't mirror all of our image assets into our dev environments regularly and only some of our site pages have CMS wysiwyg content with images in the body).

Images we had added to CMS templates with cms:file didn't break, presumably because they're referenced via their AS objects and not directly via URL.

(edited to fix bad copy-and-paste of URLs)

@JeremiahChurch
Copy link

@kbroderick those two URLs look identical - maybe a bad copy/paste?

@kbroderick
Copy link

kbroderick commented Sep 7, 2019

@tongboy indeed, bad copy paste. The portion of the URL immediately before the filename--between the --== and the /Steamboat--changed:
from
25aa53e5f0338980ba775f754d5877a1d9f703cb to
df14d446a48267a1bfe8bd9c23b3450e05d177f9

@jhovad
Copy link

jhovad commented Sep 13, 2019

where I can buy couple of beers to someone who will be able to move this awesome gem to rails 6 ? 🙏 ☺️

@morgant
Copy link
Contributor

morgant commented Sep 18, 2019

@tongboy Thanks for the fix in PR #892. It needs to be applied to Comfy::Cms::Fragment as well as Comfy::Cms::File to resolve Issue #898.

@glebm
Copy link
Contributor

glebm commented Oct 22, 2019

Here is what I ended up doing in Thredded to support both Webpacker and Sprockets:

https://github.com/thredded/thredded#add-thredded-javascripts-webpack
https://github.com/thredded/thredded/blob/master/lib/thredded/webpack_assets.rb

@morgant
Copy link
Contributor

morgant commented Dec 9, 2019

PR #899 (a duplicate of PR #892) was merged and fixes the file upload issues in Comfy::Cms::Fragment & Comfy::Cms::File.

@morgant
Copy link
Contributor

morgant commented Dec 9, 2019

@GBH Thanks for the recent merge and for saying you'd try to get a new release out around the end of the month! I know you mentioned in this issue that you're not currently maintaining any sites that use CMS, do you hope to continue managing the project & merging community fixes long term?

@GBH
Copy link
Member Author

GBH commented Dec 16, 2019

I'm slowly working towards a release. So far I updated form builder for Rails 6 (support for ActiveText rich_text input field). Updated demo app to Rails 6 so I can actually test integration properly.

It's been slow as I'm very busy with my day job (that doesn't involve CMS) and I'm kinda burned out most of the time.

I'm hoping that I'll make some progress over the holidays. At the very least I want to release stable version that sorta works with Rails 6 (basically what we have in master branch right now).

Then I want to cleanup the front-end nonsense, drop rails 5 support and finally integrate newest Redactor.

I definitely going to continue to maintain this project. It's only tough when Rails gets a major release and things change and/or break.

@JohnSmall
Copy link

@GBH "CMS 2.1 will only support Rails 6.0+ "

Shouldn't it be version 3.x then? According to semantic versioning breaking changes should update the major version number.

@GBH
Copy link
Member Author

GBH commented Dec 25, 2019

@JohnSmall Yes. I think it's going to have a lot of breaking changes so 3.0 is probably a good idea

@GBH
Copy link
Member Author

GBH commented Dec 26, 2019

Hey guys, I think I got master branch ready to go. It will be a maintenance release (2.0.19) that works in both 5.2 and 6.0. Works just fine locally but I'd like to confirm that everything checks out on production.

One thing that I immediately noticed that asset compilation won't really work if you have Sprockets 4.0. Not entirely sure what can be done about this as 3 and 4 are radically different for some reason.

In CMS3 I'll drop support for Sprockets 3 so I'll need to figure out only one way to serve assets.

@morgant
Copy link
Contributor

morgant commented Dec 27, 2019

Thanks for taking some time during the holidays to test & make updates, @GBH! I'll try to get these changes tested in our Rails 6 environment ASAP (we're still on Sprockets 3 for the same reasons.)

@morgant
Copy link
Contributor

morgant commented Dec 27, 2019

@GBH Attachment upload works in pages, but attempting to visit the Files admin page results in an NoMethodError in Comfy::Admin::Cms::Files#index with undefined method 'public_id' for string.

@GBH
Copy link
Member Author

GBH commented Dec 27, 2019

@morgant Thanks. I think it's the rack 2.0.8 thing. I'll fix it up.

@morgant
Copy link
Contributor

morgant commented Dec 30, 2019

@GBH Thanks, seems like we're still on rack 2.0.7 in our environment.

@GBH
Copy link
Member Author

GBH commented Dec 30, 2019

@morgant Ok, should not explode with rack below 2.0.8. Let me know and I'll cut the gem.

@GBH
Copy link
Member Author

GBH commented Dec 31, 2019

Looking into how package assets going forward and it's hurting my soul. This is what I think I want:

  • I want to package everything in comfy/admin/cms/application.js (also css and vendored assets) and declare them in engine's config.assets.precompile so host application can precompile without any drama. Assuming it still has sprockets.
  • I still want to manage assets in dev mode so I don't rely on gems and can import whatever i need via yarn. Vendorized assets, like Redactor, can be pulled in via includes.
  • I want to compile my js/css assets and cram them into /app/assets/ without cache-busting fingerprint. They still will be referenced via javascript_include_tag

So it seems that I cannot use Webpacker here. Maybe I need to have a Rollup workflow to accomplish this.

@morgant
Copy link
Contributor

morgant commented Dec 31, 2019

@GBH Your latest commit for rack 2.0.8 fixes the files admin section under 2.0.7 for us. Thanks!

@GBH
Copy link
Member Author

GBH commented Dec 31, 2019

Ok. 2.0.19 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants