This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 360a121d4e041a23eb78daa9f28c60e2936f7ea3
tree 2b5da439dfba9036f5ac9dcdb550392c1d14a7d7
parent bff0c9aad4a4f8d7c6dcc9f9405096471daf8b1c
tree 2b5da439dfba9036f5ac9dcdb550392c1d14a7d7
parent bff0c9aad4a4f8d7c6dcc9f9405096471daf8b1c
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Thu Apr 02 15:29:29 -0700 2009 | |
| |
README | Thu Apr 02 15:29:04 -0700 2009 | |
| |
Rakefile | Thu Apr 02 15:29:29 -0700 2009 | |
| |
init.rb | Thu Apr 02 15:29:29 -0700 2009 | |
| |
install.rb | Thu Apr 02 15:29:29 -0700 2009 | |
| |
lib/ | Thu Apr 02 15:29:04 -0700 2009 | |
| |
tasks/ | Thu Apr 02 15:29:04 -0700 2009 | |
| |
test/ | Thu Apr 02 15:29:04 -0700 2009 | |
| |
uninstall.rb | Thu Apr 02 15:29:29 -0700 2009 |
README
LinkToRemoteWithSeo =================== link_to_remote_with_seo adds optional SEO-friendliness to link_to_remote. Pass the :seo => true option to link_to_remote when you want GoogleBot and other search engines to follow your links. In addition to setting onclick, it also sets html_options[:href] to the SAME URL that you passed in to options[:url]. See the big honking warning at the bottom for an explanation of why this plugin doesn't just override the behavior of link_to_remote. Home page: http://bmorearty.wordpress.com/2009/04/02/link-to-remote-with-seo/ Example ======= The following example shows a "Next" link in paginated output. (Plain vanilla without automated pagination.) Clicking the link in a browser results in an AJAX call (using POST) that retrieves just the "page" partial and inserts it into the "results" div on the page with a highlight visual effect. When a search engine sees the link, however, it will send a GET request to the same URL and the entire page (not just the partial) will be sent in the response. Putting this in the view (home/index.html.erb): <div id="results"> <%= render :partial => "page" -%> </div> <%= link_to_remote "Next", { :update => "#results", :url => { :action => "next_page" }, :complete => visual_effect(:highlight, "#results"), :seo => true } %> Produces (pay attention to the href attrbute): <div id="results"> <!-- first page of results shown here --> </div> <a href="/home/next_page" onclick="new Ajax.Updater('#results', '/home/next_page', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("#results",{});}}); return false;"> Next </a> In the controller (home.rb), render just the partial if called in an XHR (AJAX) request: def next_page if request.xhr? render :partial => "page" else # Render the entire page, including the "results" section. render :action => "index" end end WARNING ABOUT INCORRECT USE OF THIS FUNCTION ============================================ Sorry but I have to yell for emphasis here. When Google crawls your site it will follow all links on a page in advance, even before the user clicks on them. Adding :confirm => "Are you sure?" WILL NOT HELP because it generates JavaScript that Google doesn't execute. So DO NOT USE :seo => true when linking to destructive links because they will go in the href attribute. Instead, override html_options[:href] to link to an intermediate page with "Are you sure?" and a BUTTON (not a link. The crawler will not click the link, so the data will not be deleted. See http://jlaine.net/2005/8/25/using-rails-ajax-helpers-to-create-safe-state-changing-links and search the page for "request.post?" for an explanation and some sample code. Copyright (c) 2009 Brian Morearty, released under the MIT license







