Skip to content

Commit

Permalink
We can be generic about passing attributes via the URL for creating n…
Browse files Browse the repository at this point in the history
…ew snips, by using the parameter 'name' instead of 'snip_to_edit' or 'snip_to_create'. This lets us pass other attributes via the URL too.
  • Loading branch information
lazyatom committed Jul 17, 2008
1 parent dfca2f0 commit c4ae2d9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/vanilla/dynasnips/edit.rb
Expand Up @@ -10,7 +10,7 @@ class EditSnip < Dynasnip

def get(snip_name=nil)
return login_required unless logged_in?
snip = Vanilla.snip(snip_name || app.request.params[:snip_to_edit])
snip = Vanilla.snip(snip_name || app.request.params[:name])
edit(snip)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vanilla/dynasnips/new.rb
Expand Up @@ -8,7 +8,7 @@ class NewSnip < Dynasnip

def handle(*arg)
return login_required unless logged_in?
base_params = {:name => 'newsnip', :render_as => '', :content => '', :author => current_user}
base_params = {:render_as => '', :content => '', :author => current_user}.update(app.request.params)
editor = EditSnip.new(app).edit(Snip.new(base_params))
end
end
4 changes: 2 additions & 2 deletions lib/vanilla/routes.rb
Expand Up @@ -17,11 +17,11 @@ def url_to_raw(snip_name, part=nil)
end

def edit_link(snip_name, link_text)
%[<a href="/edit?snip_to_edit=#{snip_name}">#{link_text}</a>]
%[<a href="/edit?name=#{snip_name}">#{link_text}</a>]
end

def new_link(snip_name="New")
%[<a href="/new" class="new">#{snip_name}</a>]
%[<a href="/new?name=#{snip_name}" class="new">#{snip_name}</a>]
end

extend self
Expand Down

0 comments on commit c4ae2d9

Please sign in to comment.