commit e46eb6be10617eb75cbc426de82f9f7e49d921bc
parent 1511f4f017b114129c6882ff5d8567f2914ddde6
Author: Marcus Williams <marcus-sup@bar-coded.net>
Date: Tue, 15 Jan 2008 09:40:04 +0000
Added quoteline hook for reply mode
This hook allows a user to configure a quote line for replies. The
default is the standard sup quote line "Excerpts from...". Multiple
lines are allowed.
Diffstat:
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
@@ -10,6 +10,14 @@ class ReplyMode < EditMessageMode
:user => "Customized"
}
+ HookManager.register "quoteline", <<EOS
+Generates a quote line "On 1/4/2007, Joe Bloggs wrote:".
+Variables:
+ message: A message object representing the message being replied to
+Return value:
+ A string containing the text of the quote line (can be multi-line)
+EOS
+
def initialize message
@m = message
@@ -115,11 +123,16 @@ protected
end
def reply_body_lines m
- lines = ["Excerpts from #{@m.from.name}'s message of #{@m.date}:"] + m.quotable_body_lines.map { |l| "> #{l}" }
+ quoteline = HookManager.run("quoteline", :message => m) || default_quoteline(m)
+ lines = quoteline.split("\n") + m.quotable_body_lines.map { |l| "> #{l}" }
lines.pop while lines.last =~ /^\s*$/
lines
end
+ def default_quoteline m
+ "Excerpts from #{@m.from.name}'s message of #{@m.date}:"
+ end
+
def handle_new_text new_header, new_body
old_header = @headers[@type_selector.val]
if new_header.size != old_header.size || old_header.any? { |k, v| new_header[k] != v }