File: comment_rank.rb

package info (click to toggle)
tdiary 2.0.2%2B20060303-5
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 8,172 kB
  • ctags: 1,957
  • sloc: ruby: 23,926; lisp: 514; makefile: 87; sh: 71; sql: 32
file content (27 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# comment_rank.rb $Revision: 1.3.2.1 $
#
# comment_rank: ĥåߤοǥ󥭥
#   ѥ᥿:
#     max:  ɽ(̤:5)
#     sep:  ѥ졼(̤:)
#     except:        ̵뤹̾(Ĥ⤢,Ƕڤä¤٤)
#
# Copyright (C) 2002 by TADA Tadashi <sho@spc.gr.jp>
# You can redistribute it and/or modify it under GPL2.
#
def comment_rank( max = 5, sep = '&nbsp;', *except )
	name = Hash::new(0)
	@diaries.each_value do |diary|
		diary.each_comment( 100 ) do |comment|
			next if except.include?(comment.name)
			name[comment.name] += 1
		end
	end
	result = []
	name.sort{|a,b| (a[1])<=>(b[1])}.reverse.each_with_index do |ary,idx|
		break if idx >= max
		result << "<strong>#{idx+1}.</strong>#{CGI::escapeHTML( ary[0].to_s )}(#{ary[1].to_s})"
	end
	result.join( sep )
end