Comments (9)
If you're using rails, just follow the installation steps.. rails g mercury:install will put a template in your rails app.. basically read about the routes method -- it doesn't do a double load of the page and doesn't use the mercury loader.
from mercury.
but as far as I understand, it does require the url to have a special "loader" path, like /homepage becomes /mercury/homepage. I try to avoid that in my system to confuse admins as little as possible. Am I correct in this thinking?
Op woensdag 2 november 2011, om 17:09 heeft Jeremy Jackson het volgende geschreven:
If you're using rails, just follow the installation steps.. rails g mercury:install will put a template in your rails app.. basically read about the routes method -- it doesn't do a double load of the page and doesn't use the mercury loader.
Reply to this email directly or view it on GitHub:
#66 (comment)
from mercury.
Well, I've always had a toolbar that loaded.. and then when you click to edit it or something, it swaps out.
On Nov 2, 2011, at 10:12 AM, Jean Mertz wrote:
but as far as I understand, it does require the url to have a special "loader" path, like /homepage becomes /mercury/homepage. I try to avoid that in my system to confuse admins as little as possible. Am I correct in this thinking?
Op woensdag 2 november 2011, om 17:09 heeft Jeremy Jackson het volgende geschreven:
If you're using rails, just follow the installation steps.. rails g mercury:install will put a template in your rails app.. basically read about the routes method -- it doesn't do a double load of the page and doesn't use the mercury loader.
Reply to this email directly or view it on GitHub:
#66 (comment)Reply to this email directly or view it on GitHub:
#66 (comment)
from mercury.
I actually want it to load the iframe part on the server and not have
a special URL. I guess I could build the page with the iframe on the
server and then tell Mercury everything is set when the page is
loaded. I'll see if I can get it working and create a wiki entry for
anyone who is interested
Verstuurd vanaf mijn iPad
Op 2 nov. 2011 om 20:25 heeft Jeremy Jackson
[email protected]
het volgende geschreven:
Well, I've always had a toolbar that loaded.. and then when you click to edit it or something, it swaps out.
On Nov 2, 2011, at 10:12 AM, Jean Mertz wrote:
but as far as I understand, it does require the url to have a special "loader" path, like /homepage becomes /mercury/homepage. I try to avoid that in my system to confuse admins as little as possible. Am I correct in this thinking?
Op woensdag 2 november 2011, om 17:09 heeft Jeremy Jackson het volgende geschreven:
If you're using rails, just follow the installation steps.. rails g mercury:install will put a template in your rails app.. basically read about the routes method -- it doesn't do a double load of the page and doesn't use the mercury loader.
Reply to this email directly or view it on GitHub:
#66 (comment)Reply to this email directly or view it on GitHub:
#66 (comment)Reply to this email directly or view it on GitHub:
#66 (comment)
from mercury.
I would also like to be able to set everything, including the iframe, up server side and then just let Mercury know the page is ready for it to process.
Using the route loading method, a request is made to /editor/thepage, which builds the Mercury stuff, then creates an iframe and strips out the '/editor/' part out of the URL and uses that as the src for the iframe, which results in another web request. So you get two web requests.
At the very least, I'd like to be able to configure the editor route. Using /editor/thepage doesn't fit in with the flow of my app. If I have to stick with the route loading technique, I'd rather use a route like, /pages/123/editor. This currently isn't possible because the logic used to strip out the '/editor/' portion of the URL is hardcoded in the PageEditor.iframeSrc method.
I just submitted a pull request (issue #68) that makes the PageEditor.iframeSrc method configurable via Mercury.config.iframeSrcMethod. Maybe not the best solution, but it allows me to do what I need for now. Being able to set everything up in a single web request would be ideal.
from mercury.
I see what you guys mean, and it makes sense.. I'll take a look at how we could do this, or potentially make suggestions.
@nreckart -- thanks for the pull request -- it was useful to see what you needed. =)
I expect we could add a way to pass in the iframe you want to use to PageEditor (so one isn't created for you), and this will give you some flexibility -- but understand it'll still make two requests (the iframe request isn't made until after the first request is loaded).
Other suggestions? I'm open to ideas.
from mercury.
I exposed a few bugs while playing around with this.. so I'll be fixing those here in a bit.. but I came up with something sort of like this:
Make your top level controller (eg. ApplicationController
) determine a layout that should be used.. in this case if someone can_edit, and there's not a mercury_preview param set -- this param is passed back in when mercury loads it's iframe.
class ApplicationController < ActionController::Base
protect_from_forgery
layout :layout_with_mercury
def layout_with_mercury
if can_edit? && !params[:mercury_preview]
'mercury'
else
'application'
end
end
def can_edit?
true
end
end
Then, in the config file (this is where I found bugs -- seems rails loads things from vendor before your app/assets path wtf?).. anyway, I had to rename my mercury.js file to mercury_config.js and adjust the mercury.html.erb layout to also point to this file.. then at the bottom of that file (with the recent updates inspired by @nreckart) I added:
jQuery(window).bind('mercury:loaded', function() { Mercury.PageEditor.prototype.iframeSrc = function(url) { return (url || window.location.href) + '?mercury_preview=true'; } });
Clearly the param thing is a hack, and if you're using any real params, it's likely an issue.. but it works in the simple case. I'll likely expand on this approach, and document something about it.. but give some things like that a shot and let me know what you think.
from mercury.
Sorry, I must have been getting tired towards the end of the day yesterday. I now realize that there will always need to be two web requests to load the editor and then the iframe content. So building the iframe server side probably wouldn't help much.
I like the 'mercury:loaded' event concept and will try it out today.
from mercury.
I added some features, and a wiki article with more detailed instructions for this sort of technique. I'm closing this issue, as it was the inspiration for those features that are now a little easier to use.
from mercury.
Related Issues (20)
- Routes method is patch, can we do it?
- Is mercury stopped since 2013 dec? HOT 2
- How to prevent loading mercury.js on all pages?
- Paste image from clipboard
- Can we use mecury editor as docx editing tool ? HOT 1
- mercury editor blank page in heroku HOT 1
- Mercury2 normal html example ?
- Snippets with javascripts included HOT 1
- Snippet options not saved correctly [$15]
- Mercury2 on HTML
- Uncaught TypeError: Cannot read property 'stylesheets' of undefined
- /usr/local/rvm/gems/ruby-2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb:238:in `add_request_method': You should not use the `match` method in your router without specifying an HTTP method. (ArgumentError)
- 34324
- bundler 1.13.1 objects to git protocol
- Section: Rails support in Readme.md? HOT 1
- How to remove mercury? HOT 1
- Neither install or post_install are working in Rails 5.2 HOT 2
- Regular Expression DoS vulnerability
- Mercury failed to load Live www.domain.com HOT 1
- Mode Set is closed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mercury.