spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
814 stars 257 forks source link

Loading plugins not using hashed version - rails 4.1.1, tinymce-rails 4.1.0 #147

Open kayluhb opened 10 years ago

kayluhb commented 10 years ago

Using rails 4.1.1 and tinymce-rails 4.1.0 (as well as the master branch) paths to plugins are not using the hashed version after asset:precompile. The hashed versions of the plugins are created successfully, but tinymce loads in the non-hashed versions still.

This is happening on several projects I'm working on. The odd thing is that when I use the cached version I have locally of the tinymce-4 branch, it works correctly.

remote: git://github.com/spohlenz/tinymce-rails.git
revision: 66c0d1dc5ec9101e2d3f5e1d25c22a713dd95c78
branch: tinymce-4

However, since that branch is no longer available, I can't rollback on my projects using master/4.1.0 without some tomfoolery.

Any ideas what might be happening?

kayluhb commented 10 years ago

More info:

The non-existent path that it's trying to load is

Failed to load: //beta2.zoomin.bbox.ly//zoomin-beta2.s3.amazonaws.com/assets/tinymce/plugins/link/plugin.js

Failed to load resource: the server responded with a status of 404 (Not Found) http://beta2.zoomin.bbox.ly//zoomin-beta2.s3.amazonaws.com/assets/tinymce/plugins/lists/plugin.js

It looks like it's possibly choking on the path to the host, although that is the non-hashed version which does not exist on the host.

I pushed our cached repo to https://github.com/blenderbox/tinymce-rails so I can still use the gem from there. I'll try to get into the internals to figure out what's happening.

spohlenz commented 10 years ago

Please try out tinymce-rails 4.1.2 (just released) which contains a fix for protocol-relative asset hosts. You may also need to run rake tmp:cache:clear which is possibly why the master branch didn't work for you.

Note that tinymce-rails hooks into the assets:precompile rake task to explicitly remove the digests from the filenames, so in your example, http://zoomin-beta2.s3.amazonaws.com/assets/tinymce/plugins/lists/plugin.js does in fact exist.

kayluhb commented 9 years ago

Thanks for the reply, I missed it completely when you wrote it. I'm actually revisiting this now as I've had the same issue with other projects.

On two separate projects, with rails 4.1.4 and 4.2.0, I've tried running tinymce-rails 4.1.4 and 4.1.6 and it's still happening for some reason (even after rake tmp:cache:clear)

When I run RAILS_ENV=production bin/rake assets:precompile locally, I get the hashed versions of the files and I don't have the skins directory included in the precompiled assets.

It seems like it's is something with my setup though since this doesn't seem to be an issue with anyone other than me. Perhaps I missed an upgrade step at some point.

spohlenz commented 9 years ago

Hi @kayluhb. I've been working for some time on a new asset compilation method which is currently in the compile assets branch.

I still need to finish off a few things before release but it may be worth a try in your instance (plus the extra testing/feedback would be useful).

j-dexx commented 9 years ago

Hi @spohlenz , I have a similar issue, an engine which loads in a couple of custom plugins. Rails precompiles these but tinymce is looking for the non-fingerprinted version. Any ideas? I've tried the compile assets branch with no change.

dinjas commented 8 years ago

We've noticed this also. We're using the config.tinymce.install = :compile option. We see digested versions of the TinyMCE plugin files being generated, but TinyMCE requests the non-digested versions. Is there a way to get TinyMCE to use the digested version? We're mainly concerned with having the ability to cache-bust if we need to push out an update to any of the plugins we're using.

dikond commented 8 years ago

It seems like I have the same issue with a skin. In my assets initializer I have the following:

Rails.application.config.assets.paths << Rails.root.join("app", "assets", "tinymce", "skins", "charocal")
Rails.application.config.assets.precompile += %w( skin.min.css content.min.css )

I've placed skin under this folder, and included it in my layout file:

= stylesheet_link_tag    'application', 'skin.min', 'content.min', media: 'all', 'data-turbolinks-track' => 'reload'

But I still get two errors:

GET http://localhost:3000/assets/tinymce/skins/charocal/skin.min.css 
GET http://localhost:3000/assets/tinymce/skins/charocal/content.min.css 404 (Not Found)

However, on my page it seems like skin is working! I'm kinda confused now. I am on rails-5.0.0.beta3 if that matters...

sharq1 commented 5 years ago

Could this get fixed finally? I suggest at least appending current gem version to each plugin path, like /assets/tinymce/plugins/lists/plugin.js?v=5.0.4

spohlenz commented 5 years ago

I've added the version string to the plugin URLs in the 5.0.5 release (by way of the cache_suffix option).