Closed webdesserts closed 12 years ago
I finally found what I was looking for on the wiki:
layout :layout_with_mercury
def layout_with_mercury
# if we're not already within mercury, and the user is able, load the mercury template.
# otherwise use the default application template.
!params[:mercury_frame] && is_editing? ? 'mercury' : 'application'
end
minus the is_editing?
tidbit.
I think information on how to use the layout should definitely be on the Readme. This was the first place I even found mention of how to use the layout and it was kinda buried. When I first tried this I just used the layout on it's own and Mercury kept on loading within itself. I didn't know about the mercury_frame
parameter at the time. I definitely prefer this method over the /editor path. Feels like it should be default.
-Michael
Glad you found what you were looking for. The previous version of the editor (Midas) actually did this by default. We found that most of the time it actually added complexity and was more confusing to the users. They preferred the ability to have separate urls for looking at content vs editing the content. Granted that was primarily for use with a CMS not necessarily admin interfaces.
Surely in a standard Rails app, /articles/1 is the standard way to look at the content and /articles/1/edit is the standard way to edit the content? Not sure that the current way isn't unnecessarily confusing, since existing scaffold-generated stuff will not load with Mercury at all…
Is there a simple way to do it this way from routes.rb while leaving the /editor route disabled? If I take out the mount line, Mercury is unable to load includes like /mercury/modals/htmleditor.html. If I leave it in, people can get to pages via /editor/whatever, and I don't want them to be able to do that. I've tried adding match '/editor' => '/'
in routes.rb, but Mercury simply overrides that.
Mercury isn't meant to aid in editing a standard Rails app. It was designed for CMS's where the paths are globbed and content authors need to see the page they are editing. If you want to use it to edit a RESTful model in the Rails way follow the advice of the issue above. As for the routes that is a current limitation of Rails Engines. They don't allow multiple mount points without hacking the Rails routing. If you don't want the '/editor' route to be accessible there are a variety of ways built into Rails to accomplish that, but those methods have nothing to do with Mercury.
Thanks — I think I'm probably better off going with something like RedactorJS instead for this project, TBH.
right tool for the right job. good luck with your project.
I do agree with him on the issue of removing the editor
path. Even if we did follow the RESTful model or excluded an edit path altogether, the /editor
path is still exposed as a security loophole that we have to plug up. Rather than force the developer to validate sessions on a path they don't want, wouldn't it be better to provide an option to remove it?
Mercury only has 4 routes in the engine routing file. If you want to exclude one or more of them simply don't mount the engine and manually add the routes yourself. It doesn't need a way of excluding routes. This is how I manage it in my own project where I only use one of the default Mercury routes.
Would the routing file be in the system's gem installation or in the rails app itself? Or if you could point to it on Github, I would appreciate it.
This should probably be mentioned under the Rails Integration docs, especially considering that it advertises the exclusion of the /editor
path. Also maybe consider generating a comment about further customizing routes when including the mount (I <3 inline documentation)?
Thanks for you help.
It's time consuming enough to support the intended use cases much less support other use cases. Feel free to create a pull request and add the docs to help support the project.
Hi
I've been working on getting Mercury up and running in my Rails project and have been trying a few things out. I've tried out both
mercury_loader.js
and the native rails approach and I'm kinda stuck in the middle.The rails approach is nice as far it's file setup, but I really dislike using the /editor/ path and loading a new page to use it. I'm only going to be using the editor on the administration side of the site, so I don't mind pre-loading it on each page for admins and then just activating it through the
toggle:interface
event when needed.So I started using the
mercury_loader.js
instead. However, I realize this wasn't designed to be used with the rails install and there are probably some redundancies.So I guess my question is:
Is there an easy way to get mercury to load on pages without the
/editor/
path or what parts of themercury_loader.js
are really necessary with a rails install?edit: I also just realized that my save event is firing twice. bleh
Thanks for your help! -Michael