aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-11-23 15:05:58 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-11-23 15:05:58 +0100
commitfc936f76f65db94469959883c8ef2926ff0e779b (patch)
tree7b3d64fc103abc02efdb6d000194062854409d34
parent6bcb17d78da2ed2df16c4d994c866dcf57ebe3f4 (diff)
new feature selecting parts of history
-rw-r--r--dudle.css3
-rwxr-xr-xhistory.rb6
-rw-r--r--log.rb19
-rw-r--r--poll.rb34
4 files changed, 55 insertions, 7 deletions
diff --git a/dudle.css b/dudle.css
index c0d2d56..fadd2e7 100644
--- a/dudle.css
+++ b/dudle.css
@@ -96,6 +96,9 @@ td.create_poll, td.charset{
text-align:left;
}
+td.historycomment{
+ text-align:left;
+}
td {
vertical-align:middle;
text-align:center;
diff --git a/history.rb b/history.rb
index 6edacdc..43c5264 100755
--- a/history.rb
+++ b/history.rb
@@ -63,7 +63,11 @@ $html << "<h2>#{versiontitle}</h2>"
$html << table.to_html("",false)
$html << "<h2>History</h2>"
-$html << "<div id='history'>#{table.history_to_html(maxrev, revno)}</div>"
+$html << "<div id='history'>"
+historyselect = $cgi.include?("history") ? $cgi["history"] : nil
+$html << table.history_selectform(revno == maxrev ? nil : revno, historyselect)
+$html << table.history_to_html(maxrev, revno, historyselect)
+$html << "</div>"
$html << "</div></body>"
diff --git a/log.rb b/log.rb
index 2d62090..fe0d4f5 100644
--- a/log.rb
+++ b/log.rb
@@ -33,7 +33,7 @@ class LogEntry
ret += "</a>" if link
ret += "</td>"
ret += "<td>#{@timestamp.strftime('%d.%m, %H:%M')}</td>"
- ret += "<td>#{CGI.escapeHTML(@comment)}</td>"
+ ret += "<td class='historycomment'>#{CGI.escapeHTML(@comment)}</td>"
ret += "</tr>"
ret
end
@@ -89,6 +89,12 @@ class Log
def each
@log.each{|e| yield(e)}
end
+ def collect
+ @log.collect{|e| yield(e)}
+ end
+ def comment_matches(regex)
+ Log.new(@log.collect{|e| e if e.comment =~ regex}.compact)
+ end
end
if __FILE__ == $0
@@ -97,16 +103,19 @@ require "test/unit"
def test_indexes
l = Log.new
- l.add(10,Time.now,"foo 10")
+ l.add(10,Time.now,"baz 10")
20.times{|i|
l.add(i,Time.now,"foo #{i}") unless i == 10
}
assert_equal(0,l.min.rev)
assert_equal(19,l.max.rev)
- assert_equal("foo 10",l[10].comment)
- l = l[9..11]
- assert_equal([9,10,11],[l[9].rev,l[10].rev,l[11].rev])
+ assert_equal("baz 10",l[10].comment)
+
+ p = l[9..11]
+ assert_equal([9,10,11],[p[9].rev,p[10].rev,p[11].rev])
+
+ assert_equal([10],l.comment_matches(/^baz \d*$/).collect{|e| e.rev})
end
end
end
diff --git a/poll.rb b/poll.rb
index e69c8c7..66e2d5f 100644
--- a/poll.rb
+++ b/poll.rb
@@ -228,8 +228,40 @@ ADDCOMMENT
ret
end
- def history_to_html(maxrev, middlerevision)
+ def history_selectform(revision, selected)
+ ret = <<FORM
+<form method='get' action=''>
+ <div>
+ <select name='history'>
+FORM
+ ["comments","participants","columns"].each{|opt|
+ ret += "<option value='#{opt}' #{selected == opt ? "selected='selected'" : ""} >#{opt}</option>"
+ }
+ ret += "<input type='hidden' name='revision' value='#{revision}' />" if revision
+ ret += <<FORM
+ </select>
+ <input type='submit' />
+ </div>
+</form>
+FORM
+ ret
+ end
+
+ def history_to_html(maxrev, middlerevision,only)
log = VCS.history
+ if only
+ case only
+ when "comments"
+ match = /^Comment .*$/
+ when "participants"
+ match = /^Participant .*$/
+ when "columns"
+ match = /^Column .*$/
+ else
+ raise "invalid value #{only}"
+ end
+ log = log.comment_matches(match)
+ end
log[((middlerevision-5)..(middlerevision+5))].to_html(maxrev, middlerevision)
end