home, index, New :: wham-bam-thank-you-spamEdit | Delete

Wham, Bam, Thank You Spam!

My ultra-secure commenting system has finally fallen foul of the malicious robots of spammers. They're probably terrorists, hijacking the precious interblah.net-page-rank fluids to build some kind of net-bomb. Unthinkable!

Anyway, this is good for me, because it forces me to develop some new stuff to counter the spam. And the first step is being able to delete snips. Here's my quick-n-dirty dynasnip for the moment:

delete

Usage: (no details)

require 'vanilla/dynasnip'
require 'vanilla/dynasnips/login'

class Delete < Dynasnip
  include Login::Helper

  def handle
    return login_required unless logged_in?
    name = app.request.params[:snip_to_delete]
    snip_to_delete = Vanilla.snip(name)
    snip_to_delete.destroy if snip_to_delete
    "Snip #[snip 'name' cannot be found] has been deleted."
  end
  self
end

(If the dynasnip only contains a class name, it's probably loaded from the Vanilla application directly. This is typical of the basic dynasnips like link_to, etc)

I've also added the link to the template, but this in turn raises some interesting, unanswered questions about how to take Vanilla.rb from an interesting toy into a proper web platform.

Comments