<%% @anchor_name = <%=opt['anchor'] || false%> %>
<div class="day autopagerize_page_element">
<h2><%%= title_proc( Time::at( <%=@date.to_i%> ), <%= title.dump.gsub( /%/, '\\\\045' ) %> ) %></h2>

<div class="body">
<%%= body_enter_proc( Time::at( <%=@date.to_i%> ) ) %>
<%= to_html( opt ) %>
<%%= body_leave_proc( Time::at( <%=@date.to_i%> ) ) %>
</div>

<div class="comment">
<%
if opt['show_comment'] and count_comments > 0 then
	if opt['long_mode'] then %>
		<div class="caption"><%%=comment_today%><%%=comment_total( <%=count_comments%> )%> [<a name="c00" href="<%=h opt['index'] %><%%=anchor "<%= @date.strftime( '%Y%m%d' ) %>#c" %>"><%%=comment_new%></a>]</div>
		<div class="commentbody"><%
		each_visible_comment( opt['comment_limit'] ) do |comment,idx|
			if comment.visible? %>
				<div class="commentator">
					<a <% if opt['anchor'] then %>name="c<%= '%02d' % idx %>" <% end %>href="<%=h opt['index'] %><%%=anchor "<%= @date.strftime( '%Y%m%d' ) %>#c<%= '%02d' % idx %>" %>"><%= opt['comment_anchor'] %></a>
					<span class="commentator"><%=h comment.name %></span>
					<span class="commenttime"><%%=comment_date( Time::at( <%=comment.date.to_i%> ) )%></span>
				</div>
				<p><% if opt['bot'] then %>
					<%=h comment.body.gsub( /\n/ , "<br>" ).gsub( /<br><br>\Z/, '' ) %>
				<% else %>
					<%= comment.body.make_link.emojify.gsub( /\n/ , "<br>" ).gsub( /<br><br>\Z/, '' ) %>
				<% end %></p><%
			end
		end %>
		</div><%
	else %>
		<div class="caption"><%%=comment_today%><%%=comment_total( <%=count_comments%> )%> [<a href="<%=h opt['index'] %><%%=anchor "<%= @date.strftime( '%Y%m%d' ) %>#c" %>"><%%=comment_new%></a>]</div>
		<div class="commentshort"><%
		if count_comments > opt['comment_limit'] then %>
			<p><a href="<%=h opt['index'] %><%%=anchor "<%= @date.strftime( '%Y%m%d' ) %>#c00" %>">Before...</a></p><%
		end
		each_comment_tail( opt['comment_limit'] ) do |comment,idx|
			if comment.visible? %>
				<p><a href="<%=h opt['index'] %><%%=anchor "<%= @date.strftime( '%Y%m%d' ) %>#c<%= '%02d' % idx %>" %>"><%= opt['comment_anchor'] %></a>
				<span class="commentator"><%=h comment.name %></span>&nbsp;[<%=h(comment.shorten( opt['comment_length'] )).emojify %>]</p><%
			end
		end %>
		</div><%
	end
elsif !opt['hide_comment_form'] %>
	<div class="caption">[<a href="<%=h opt['index'] %><%%=anchor "<%= @date.strftime( '%Y%m%d' ) %>#c" %>"><%%=comment_new%></a>]</div><%
end %>
</div>

<%% if @mode == 'day' %><div id="comment-form-section"><%%=comment_form%></div><%% end %>

<%%= comment_leave_proc( Time::at( <%=@date.to_i%> ) ) %>

<%% unless @plugin_files.grep(/tb-show.rb\z/).empty? then %><%
	if opt['long_mode'] then %><%%=
		trackbacks_of_today_long( @diaries["<%= @date.strftime( '%Y%m%d' ) %>"] )
	 %><% else %><%%=
		trackbacks_of_today_short( @diaries["<%= @date.strftime( '%Y%m%d' ) %>"] )
	%><% end %><%%
end %>

<%% unless @plugin_files.grep(/pb-show.rb\z/).empty? then %><%
	if opt['long_mode'] then %><%%=
		pingbacks_of_today_long( @diaries["<%= @date.strftime( '%Y%m%d' ) %>"] )
	 %><% else %><%%=
		pingbacks_of_today_short( @diaries["<%= @date.strftime( '%Y%m%d' ) %>"] )
	%><% end %><%%
end %>

<%
if opt['show_referer'] then
	if opt['long_mode'] then %>
		<div class="refererlist">
		<%%= referer_of_today_long( @diaries['<%=@date.strftime( '%Y%m%d' )%>'], <%=opt['referer_limit']%> )%>
		</div><%
	else %>
		<div class="referer">
		<%%=referer_of_today_short( @diaries['<%=@date.strftime( '%Y%m%d' )%>'], <%=opt['referer_limit']%> )%>
		</div><%
	end
end %>
</div>
