Skip to content
This repository has been archived by the owner on Apr 14, 2018. It is now read-only.

Commit

Permalink
logout link and prevent people from entering in inline ruby code
Browse files Browse the repository at this point in the history
  • Loading branch information
phallstrom committed Apr 10, 2009
1 parent 07fd545 commit bae3174
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/helpers/helper_helper.rb
Expand Up @@ -18,12 +18,8 @@ def extract_helper_options(params)

def helper_invocation(prefix, params, suffix = ")")
options = extract_helper_options(params)
'<%= ' +
prefix +
(', ' unless options.blank?).to_s +
options.map {|e| ":#{e.first} => #{e.last}" }.join(', ') +
suffix +
' %>'
invocation = '<%= ' + prefix + (', ' unless options.blank?).to_s + options.map {|e| ":#{e.first} => #{e.last}" }.join(', ') + suffix + ' %>'
invocation.gsub(/\#{.*?}/, '{SORRY}')
end

end
Expand Down
29 changes: 29 additions & 0 deletions app/views/helper/_fb_logout_link.html.erb
@@ -0,0 +1,29 @@
<% form_tag do %>

<b><%= @helper_name %>(</b>
<blockquote>
<%= text_field_tag :link_text, (params[:link_text] || 'Logout'), :title => "Clickable text for logout link" %>,
<br />
<%= text_field_tag :redirect_url, (params[:redirect_url] || request.url), :size => 70, :title => "URL to redirect to upon logout" %>
<br />
</blockquote>
<b>)</b>

<%= submit_tag 'Go' %>
<% end %>
<% if request.post? %>
<% invocation = helper_invocation("#{@helper_name}(\"#{params[:link_text]}\", \"#{h params[:redirect_url]}\"", {}) %>

<h3>Invocation</h3>
<div class='boxed'>
<%= h invocation %>
</div>

<h3>Result</h3>
<div class='boxed'>
<%= render :inline => invocation %>
</div>
<% end %>
1 change: 1 addition & 0 deletions app/views/home/index.html.erb
Expand Up @@ -32,6 +32,7 @@
<li>
<h2>Explore the links on the right.</h2>
<p>The links to the right will let you play with the various Facebooker helper methods, see their invocation, and their output.</p>
<p>If an argument to a helper isn't named (ie. via a hash) and isn't clear from it's context, try hovering the mouse over it for a short description.</p>
</li>
</ol>
</div>
5 changes: 5 additions & 0 deletions config/application_config.yml
Expand Up @@ -13,6 +13,11 @@ development: &defaults
:description: Renders a Facebook Connect login button image on your site.
:wiki_url: http://wiki.developers.facebook.com/index.php/Fb:login-button
:not_in_fb: true
:fb_logout_link:
:description: Log user out from this session and Facebook, then redirect to the specified url.
:wiki_url: http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Connect.LogoutAndRedirect
:not_in_fb: true


test:
<<: *defaults
Expand Down
5 changes: 5 additions & 0 deletions public/stylesheets/application.css
Expand Up @@ -207,6 +207,11 @@ small, .small {
font-family: "Monaco", "Courier New";
}

#helper form blockquote {
padding: 0;
margin: 0 0 0 1em;
}

#helper form label {
width: 33%;
display: inline-block;
Expand Down

0 comments on commit bae3174

Please sign in to comment.