Sha256: e473bc3626d32a64c35f4c2243be23f77c79e14600af388051a798f48e75e4a2

Contents?: true

Size: 1.28 KB

Versions: 38

Compression:

Stored size: 1.28 KB

Contents

# recent_namazu.rb
#
# recent_namazu: Namazu検索語新しい順
# 		 namazi.cgiが作成する検索キーワードログ(NMZ.slog)から
#		 最新xx件分の検索語を表示します。
# パラメタ:
#   file:       検索キーワードログファイル名(絶対パス表記)
#   namazu:     なまずcgi名
#   limit:      表示件数(未指定時:5)
#   sep:        セパレータ(未指定時:空白)
#   make_link:  <a>を生成するか?(未指定時:生成する)
#
#
# Copyright (c) 2002 Hiroyuki Ikezoe <zoe@kasumi.sakura.ne.jp>
# Distributed under the GPL2 or any later version.

def recent_namazu(file, namazu, limit = 5, sep='&nbsp;', make_link = true)
	begin
		lines = []
		log = open(file)
		if log.stat.size > 300 * limit then
			log.seek(-300 * limit,IO::SEEK_END)
		end
		log.each_line do |line|
			lines << line
		end

		result = []
		lines.reverse.each_with_index do |line,idx|
			break if idx >= limit
			word = line.split(/\t/)[0]
			if make_link
				result << %Q[<a href="#{h( namazu )}?query=#{u( word )}">#{h( word )}</a>]
			else
				result << h( word )
			end
		end
		result.join( sep )
	rescue
		%Q[<p class="message">#$! (#{$!.class})<br>cannot read #{file}.</p>]
	end
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:

Version data entries

38 entries across 28 versions & 1 rubygems

Version Path
tdiary-5.3.0 misc/plugin/recent_namazu.rb
tdiary-5.2.4 misc/plugin/recent_namazu.rb
tdiary-5.2.3 misc/plugin/recent_namazu.rb
tdiary-5.2.2 misc/plugin/recent_namazu.rb
tdiary-5.2.1 misc/plugin/recent_namazu.rb
tdiary-5.2.0 misc/plugin/recent_namazu.rb
tdiary-5.1.7 misc/plugin/recent_namazu.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/misc/plugin/recent_namazu.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/misc/plugin/recent_namazu.rb
tdiary-5.1.6 misc/plugin/recent_namazu.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/misc/plugin/recent_namazu.rb
tdiary-5.1.5 misc/plugin/recent_namazu.rb
tdiary-5.1.4 misc/plugin/recent_namazu.rb
tdiary-5.1.3 misc/plugin/recent_namazu.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/misc/plugin/recent_namazu.rb
tdiary-5.1.2 misc/plugin/recent_namazu.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/misc/plugin/recent_namazu.rb
tdiary-5.1.1 misc/plugin/recent_namazu.rb
tdiary-5.1.0 misc/plugin/recent_namazu.rb
tdiary-5.0.14 misc/plugin/recent_namazu.rb