aboutsummaryrefslogtreecommitdiffstats
path: root/Bonus/scanhist.rb
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:05:14 +0000
committerTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:05:14 +0000
commit72f72d64a422d6628c4796f5c0bf2e508f134214 (patch)
tree0c9ea90cc53310832c977265521fb44db24a515e /Bonus/scanhist.rb
parentAdding upstream version 0.3 (diff)
downloadw3m-1ef51c20e0ea7b35c8c9cad6f9d9bc1e16664cc5.tar.gz
w3m-1ef51c20e0ea7b35c8c9cad6f9d9bc1e16664cc5.zip
Adding upstream version 0.5.1upstream/0.5.1
Diffstat (limited to 'Bonus/scanhist.rb')
-rw-r--r--Bonus/scanhist.rb88
1 files changed, 88 insertions, 0 deletions
diff --git a/Bonus/scanhist.rb b/Bonus/scanhist.rb
new file mode 100644
index 0000000..69dcc9d
--- /dev/null
+++ b/Bonus/scanhist.rb
@@ -0,0 +1,88 @@
+#!/usr/local/bin/ruby
+
+# scan history
+
+def usage
+ STDERR.print "usage: scanhist -h HISTORY ML-archive1 ML-archive2 ...\n"
+ exit 1
+end
+
+def html_quote(s)
+ s.gsub!(/&/,"&amp;")
+ s.gsub!(/</,"&lt;")
+ s.gsub!(/>/,"&gt;")
+ s
+end
+
+if ARGV.size == 0 then
+ usage
+end
+
+histfile = nil
+
+while ARGV[0] =~ /^-/
+ case ARGV.shift
+ when "-h"
+ histfile = ARGV.shift
+ else
+ usage
+ end
+end
+
+if histfile.nil? then
+ usage
+end
+
+patched = {}
+histline = {}
+f = open(histfile)
+while f.gets
+ if /Subject: (\[w3m-dev.*\])/ then
+ patched[$1] = true
+ histline[$1] = $.
+ end
+end
+f.close
+
+archive = {}
+subject = nil
+for fn in ARGV
+ f = open(fn)
+ while f.gets
+ if /^From / then
+ # beginning of a mail
+ subject = nil
+ elsif subject.nil? and /^Subject: / then
+ $_ =~ /Subject: (\[w3m-dev.*\])/
+ subject = $1
+ archive[subject] = [$_.chop.sub(/^Subject:\s*/,""),false,fn+"#"+($.).to_s]
+ elsif /^\+\+\+/ or /\*\*\*/ or /filename=.*(patch|diff).*/ or /^begin \d\d\d/
+ archive[subject][1] = true
+ end
+ end
+ f.close
+end
+
+print "<html><head><title>w3m patch configuration\n</title></head><body>\n"
+print "<pre>\n"
+for sub in archive.keys.sort
+ a = archive[sub]
+ if a[1] then
+ if patched[sub] then
+ print "[<a href=\"#{histfile}\##{histline[sub]}\">+</a>]"
+ else
+ print "[-]"
+ end
+ print "<a href=\"#{a[2]}\">"
+ print "<b>",html_quote(a[0]),"</b></a>\n"
+ else
+ if patched[sub] then
+ print "[<a href=\"#{histfile}\##{histline[sub]}\">o</a>]"
+ else
+ print " "
+ end
+ print "<a href=\"#{a[2]}\">"
+ print "<b>",html_quote(a[0]),"</b></a>\n"
+ end
+end
+print "</pre></body></html>\n"