<%
## accesskeys
if @conf.accesskey_enabled
accesskeys = {
		'year'    => ' accesskey="Y"',
		'month'   => ' accesskey="M"',
		'day'     => ' accesskey="D"',
		'edit'    => ' accesskey="E"',
		'body'    => ' accesskey="C"',
		'preview' => ' accesskey="P"',
		'submit'  => ' accesskey="A"',
		'hide'    => ' accesskey="H"',
	}
else
	accesskeys = {}
end
%>
<%%=navi%>

<h1><%=h @conf.html_title %> [<%%= submit_label %>]</h1>

<div class="update day">
<h2><span class="title">日記の更新</span></h2>
<div class="form">
	<form class="update" method="post" action="<%=h @conf.update %>"><div>
		<h3 class="subtitle">日記本文</h3>
		<input type="hidden" name="old" value="<%= @date.strftime( '%Y%m%d' ) %>">
		<%=@csrf_protection%>
		<span class="field year">
			<input class="field" id="year" name="year" tabindex="1"<%= accesskeys['year'] %> size="4" value="<%= @date.year %>">年
		</span>
		<span class="field month">
			<input class="field" id="month" name="month" tabindex="2"<%= accesskeys['month'] %> size="2" value="<%= @date.mon %>">月
		</span>
		<span class="field day">
			<input class="field" id="day" name="day" tabindex="3"<%= accesskeys['day'] %> size="2" value="<%= @date.day %>">日
		</span>
		<span class="button edit">
			<input type="submit" tabindex="4"<%= accesskeys['edit'] %> name="edit" value="この日付の日記を編集">
		</span>
		<div class="field title">
			タイトル: <input class="field" id="title" name="title" tabindex="5"<%= accesskeys['title'] %> size="40" value="<%=h @diary.title %>">
		</div>
		<div class="textarea">
			本文(<span id="style"><%=h @conf.style %></span>スタイル<%%= style_howto %>):<textarea id="body" name="body" tabindex="6"<%= accesskeys['body'] %> cols="70" rows="15"><%=h @diary.to_src %></textarea>
		</div>
		<%%=edit_proc( @date )%>
		<span class="button preview">
			<input type="submit" tabindex="998"<%= accesskeys['preview'] %> name="<%%= preview_command %>" value="<%%= preview_label %>">
		</span>
		<span class="button append">
			<input type="submit" tabindex="999"<%= accesskeys['submit'] %> name="<%%= submit_command %>" value=" <%%= submit_label %> ">
		</span>
		<span class="checkbox hidediary"><label for="hide">
			<input type="checkbox" id="hide" name="hide" value="true" <% unless @diary.visible? then %>checked <% end %>tabindex="1000"<%= accesskeys['hide'] %>>この日の日記を隠す
		</label></span>
	</div></form>
</div>

<%%=form_proc( @date )%>

<hr class="sep">

<div class="comment">
	<div class="caption"><%%=comment_today%></div>
	<form class="commentstat" method="post" action="<%=h @conf.update %>"><div>
		<input type="hidden" name="year" value="<%= @date.year %>">
		<input type="hidden" name="month" value="<%= @date.month %>">
		<input type="hidden" name="day" value="<%= @date.day %>">
		<%=@csrf_protection%>
		<div class="commentbody"><%
		idx = 0
		@diary.each_comment do |comment|
			comment_checkbox_id = "commentcheckboxr#{idx}" %>
			<div class="commentator">
				<span class="checkbox">
					<input class="checkbox" type="checkbox" id="<%= comment_checkbox_id %>" tabindex="<%=2000+idx%>" name="<%= idx += 1 %>" value="true"<% if comment.visible? then %> checked<% end %>>
				</span>
				<label for="<%= comment_checkbox_id %>">
					<span class="commentator"><%=h comment.name %><%=h( " <#{comment.mail}>" ) unless comment.mail.empty? %></span>
					<span class="commenttime"><%%=comment_date( Time::at( <%=comment.date.to_i%> ) )%></span>
				</label>
			</div>
			<p><%= comment.body.make_link.gsub( /\n/, "<br>" ).gsub( /<br><br>\Z/, '' ) %></p><%
		end
		if idx > 0 then %>
			<div class="button">
				<input type="submit" tabindex="<%=2000+idx%>" name="comment" value="ツッコミ表示状態変更">
			</div><%
		end %>
		</div>
	</div></form>
</div>

<hr class="sep">

<div class="refererlist">
	<%%= referer_of_today_long( @diaries['<%=@date.strftime( '%Y%m%d' )%>'], 100 )%>
</div>

</div>

<hr class="sep">
