Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add notifier and formatter hooks

 * :notifier is passed posted comments, use it to notify yourself about
   them
 * :formatter is used to format comment bodies
  • Loading branch information...
commit 7e3782d626cefcc576cdf4005a72e1eff003ca6b 1 parent daa9509
François Vaux authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/haze.rb
8 lib/haze.rb
View
@@ -42,6 +42,10 @@ def opt(opt)
"Home" => ["Home", "/"],
"Archives" => ["View archives", "/archive"]
}
+ set :notifier, proc {|c|
+ puts "New comment on #{c.entry} by #{c.author}"
+ }
+ set :formatter, proc {|b| b }
def reload!
@entries = read_entries('entries/*.hz')
@@ -120,6 +124,8 @@ def self.create(params)
data[k] = Rack::Utils.escape_html(data[k])
}
+ data[:body] = Haze.opt(:formatter).call(data[:body])
+
super(data)
end
end
@@ -231,7 +237,7 @@ def try_path(path)
halt 500, "invalid form data" if params[f].empty?
}
- Comment.create(params)
+ Haze.opt(:notifier).call Comment.create(params)
redirect request.url + '#comments'
end
Please sign in to comment.
Something went wrong with that request. Please try again.