Created
May 11, 2010 01:09
-
-
Save parndt/396780 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id='editor_switch'> | |
<% | |
if admin? | |
(r = ::ActionController::TestRequest.new(request.env)).path = (request.request_uri.to_s.match(/\/admin(.*)\/edit/)[1] rescue root_url) | |
public_route = ((c = ActionController::Routing::Routes.recognize(r)).present? and c != ApplicationController) ? r.path : root_url rescue root_url | |
else | |
if @page.present? and !@page.home? | |
editor_route = edit_admin_page_url(@page) | |
else | |
editor_route = (request.request_uri.to_s == '/') ? admin_root_url : "/admin#{request.request_uri}/edit" | |
end | |
end | |
-%> | |
<%= | |
link_to_if(admin?, "Switch to live view", public_route) do | |
link_to "Switch to editor view", editor_route | |
end | |
-%> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment