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
Allow overriding the JS_URL and JS_ROOT settings - important when staticfiles are hosted on CDN #15
Conversation
i don't think this changes anything, if TINYMCE_JS_URL or TINYMCE_JS_ROOT is defined in settings it will be used. |
i've setup django-tinymce with files served from aws s3 and it's working. |
i've figured out that tinymce popups don't work because of CORS and other domain issues but didn't figure out how this solves it. |
tinymce doesn't work properly when used from CDN so i'm closing this issue more info: |
@aljosa You are completely right about TinyMCE not working from a CDN or static file cache. That is exactly why I made this patch. If Django's Also, as often TinyMCE is used only from Django's admin interface (rather than by all visitors of a site) it makes sense to be able to keep the TinyMCE files out of the Amazon WebFront's etc. to be able to cache efficiently. Please reopen and reconsider. Let me know whether you have further questions. |
@dokterbob I think @aljosa point is that your patch doesn't change the current behavior. It's already possible to override the JS_URL / JS_ROOT by setting TINYMCE_JS_URL / TINYMCE_JS_ROOT. Currently this is done: JS_URL = getattr(settings, 'TINYMCE_JS_URL', os.path.join(settings.STATIC_URL, 'tiny_mce/tiny_mce.js')) This means that, unless TINYMCE_JS_URL is set, JS_URL will be STATIC_URL + 'tiny_mce/tiny_mce.js' Your patch doesn't seem to change that at all. |
@dokterbob i'm using django-tinymce on heroku.com where staticfiles are on AWS S3 so tinymce doesn't work but i can set TINYMCE_JS_URL to something like "/tinymce/tiny_mce.js" and pass it through web server and it works as expected. so this should work w/ current django-tinymce and i am using it in such a way so could you please check again why it's not working for you? |
@aljosa I've been trying to replicate, but a little confused, my settings are:
But obviously, my staticfiles are tied up with serving S3/ Boto, so I get a 404 for tiny_mce.js...
Just to confirm I have checked what Much appreciated if you can elucidate your previous comment. Perhaps I also need to set-up something in urls.py?? |
@Advm you need to have static files (or just tinymce files) available and add url pattern to serve files: add something like this to urls.py:
where "/static/files/path/" should actually exist and be result of django collectstatic command.
will enable tinymce even if other files are on S3. try this and let me know if you need more instructions |
Thanks so much for the quick response, thought static.serve wouldn't work in prod for some reason, ...totally works :) Appreciate it. |
@Advm static.serve doesn't work as good as nginx but if you're using gunicorn + gevent backend you'll get good performance. |
Hi. Does someone get success with Django + Heroku + TinyMCE + S3 static file (including tinymce static on S3)? If it works Django + Heroku + TinyMCE + S3 static file (EXCLUDING tinymce files on static S3 - but tinyMCE files on heroku ) - please write how I have problem with popup windows - link on popup is correct but it is blank my config:admin.py: class Admin(admin.ModelAdmin):
setting: STATICFILES_FINDERS = ( TINYMCE_JS_URL = '/static/tiny_mce/tiny_mce.js' JS_URL = TINYMCE_JS_URL if 'staticfiles' in INSTALLED_APPS or 'django.contrib.staticfiles' in INSTALLED_APPS: JS_BASE_URL = JS_URL[:JS_URL.rfind('/')] url.py: Any combination without success Only when in admin.py: js = [ |
@lesha4ever try using https://github.com/aljosa/django-tinymce/tree/tinymce4 |
Hmm... I thought i am using it. I installed and configured it according to http://django-tinymce.readthedocs.org/en/latest/installation.html But after it (4 installation steps) i can't see it even on edit admin page. Only after adding to admin.py i see it (without popup) class Admin(admin.ModelAdmin): I need TinyMCE only on admin page. May be after install's steps i do some wrong config? |
@lesha4ever tinymce4 is development branch w/ tinymce v4.x and isn't released as django-tinymce.
It should work for your use case, just follow README: |
Many thanks. It "mainly" works. for heroku added requirement: -e git://github.com/aljosa/django-tinymce.git@tinymce4#egg=tinymce4 and to admin.py
urls.py: |
I think i understand where is problem. JS_URL = staticfiles_storage.url('tinymce/tinymce.min.js') and site with tinyMCE + S3 static successful loads core js and css data from CDN. But internally in css link to fonts is relative. For example: 'tinymce';src:url('fonts/tinymce.eot');src:url('fonts/tinymce.eot?#iefix') format('embedded-opentype'),url('fonts/tinymce.woff') format('woff'),url('fonts/tinymce.ttf') format('truetype'),url('fonts/tinymce.svg#tinymce') format('svg') As we see link is relative, and i think it relative to core site link, not to CDN. |
When Django's staticfiles are hosted externally, for example through a CDN, the same-origin policy prevents TinyMCE from functioning properly. Therefore, I made a small patch to allow overriding of
JS_URL
andJS_ROOT
from Django'ssettings
.When this setting is not specified, the original defaults are used. When they are specified, the defaults are ignored.