Mercurial > hgrepos > hgweb.cgi > after5
diff after5.rb @ 40:ca416d5020fe draft
Hack subject tag.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Mon, 07 May 2012 01:17:48 +0900 |
parents | 338cd77f85a7 |
children | c4e517ccfd99 |
line wrap: on
line diff
--- a/after5.rb Sun May 06 23:42:13 2012 +0900 +++ b/after5.rb Mon May 07 01:17:48 2012 +0900 @@ -4,7 +4,7 @@ # Associative Scheduling Table - after5 # (C)2003, 2004, 2006, 2008, 2012 by HIROSE Yuuji [yuuji<at>gentei.org] # $Id: after5.rb,v 1.19 2012/04/01 11:52:25 yuuji Exp yuuji $ -# Last modified Sun May 6 23:41:31 2012 on firestorm +# Last modified Mon May 7 01:15:16 2012 on firestorm # See http://www.gentei.org/~yuuji/software/after5/ # このスクリプトはEUCで保存してください。 $hgid = <<_HGID_.split[1..-2].join(" ") @@ -2514,6 +2514,36 @@ exit 0 end # ML functions + def tagify_subj(body, tag) + hold = [] + ret = [] + skip = false + regexp = /^Subject: / + while line = body.shift + case line.toeuc + when /^$/ + hold << "\n" + break + when regexp + skip = true + ret += hold + hold = [line] + when /^\s/ # continued line + hold << line + else + if skip then + sj = hold.join.toeuc.sub("Subject: ", "").gsub(tag, "").strip + sj = sj.sub(/^(re: *)+/i, "Re:").gsub("\n", "").squeeze + ret << "Subject: "+NKF.nkf('-jM', tag+" "+sj)+"\n" + else + ret += hold + end + skip = false + hold = [line] + end + end + ret + hold + body + end def list() # For debug: # LOCAL=1 DEFAULT=name ./after5.rb -list @@ -2529,7 +2559,6 @@ if viamail then prohibitviahttp() name = ENV['DEFAULT'] - body = STDIN.readlines.join else # via http return nil unless checkauth name = @params['name'] @@ -2541,6 +2570,10 @@ subj = @params['subject'] || "Message from "+@myname sjtag = sprintf(@opt['mailbracket'], nickname(name)) subj = sjtag.strip+" "+subj.gsub(sjtag, "") + if viamail then + body = tagify_subj(STDIN.readlines, sjtag).join + # body = STDIN.readlines.join + end header = { "Reply-to" => to, "X-ML-Driver" => $hgid,