# tdiary_toc.rb $Revision: 1 $
# Copyright (C) 2009 Michitaka Ohno <elpeo@mars.dti.ne.jp>
# You can redistribute it and/or modify it under GPL2.
# ¡ô

if 'day' == @mode && @conf.bot? then
	add_body_leave_proc do |date|
		diary = @diaries[date.strftime('%Y%m%d')]
		r = <<-HTML
		<div class="caption">ÌÜ¼¡</div>
		<ul>
		HTML
		index = 1
		diary.each_section do |s|
			old_apply_plugin = @conf['apply_plugin']
			@conf['apply_plugin'] = true
			title = apply_plugin( s.subtitle_to_html, true ).strip
			title.sub!( /^(\[.+?\])+ */, '' )
			if title.empty?
				title = apply_plugin( s.body_to_html, true ).strip
				title = @conf.shorten( title.gsub( /&.*?;/, '' ), 20 )
			end
			r << <<-HTML
			<li><a href="#{'#p%02d'%index}">#{title}</a></li>
			HTML
			@conf['apply_plugin'] = old_apply_plugin
			index += 1
		end
		r << <<-HTML
		</ul>
		HTML
	end
end
