Open GBH opened 5 years ago
Doesn't Rails still support Sprockets, even if using webpacker?
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
I've been playing around with Rails 6 -- it does use webpack by default, yeat images are still handled by sprockets.
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
@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)
@kbroderick those two URLs look identical - maybe a bad copy/paste?
@Tongboy indeed, bad copy paste. The portion of the URL immediately before the filename--between the --== and the /Steamboat--changed: from 25aa53e5f0338980ba775f754d5877a1d9f703cb to df14d446a48267a1bfe8bd9c23b3450e05d177f9
where I can buy couple of beers to someone who will be able to move this awesome gem to rails 6 ? 🙏 ☺️
@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.
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
PR #899 (a duplicate of PR #892) was merged and fixes the file upload issues in Comfy::Cms::Fragment & Comfy::Cms::File.
@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?
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.
@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.
@JohnSmall Yes. I think it's going to have a lot of breaking changes so 3.0 is probably a good idea
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.
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.)
@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
.
@morgant Thanks. I think it's the rack 2.0.8 thing. I'll fix it up.
@GBH Thanks, seems like we're still on rack 2.0.7 in our environment.
@morgant Ok, should not explode with rack below 2.0.8. Let me know and I'll cut the gem.
Looking into how package assets going forward and it's hurting my soul. This is what I think I want:
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./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.
@GBH Your latest commit for rack 2.0.8 fixes the files admin section under 2.0.7 for us. Thanks!
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:
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.