<?xml version="1.0" encoding="UTF-8"?>

<!--記事別日記の生成-->

<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns="http://www.w3.org/1999/xhtml"
	version="1.0">

<xsl:include href="core.xsl" />
<xsl:include href="header.xsl" />
<xsl:include href="xml2xhtml.xsl" />
<xsl:include href="diary_genre.xsl" />
<xsl:include href="navi_atcl.xsl" />

<xsl:variable name="year" select="/diary/@year" />
<xsl:variable name="month" select="/diary/@month" />
<xsl:param name="day" />
<xsl:param name="atcl" />
<xsl:variable name="depth">../../../..</xsl:variable>
<xsl:variable name="title" select="concat($this_atcl_name, ' [',$year, '年', $month_num, '月', $day_num, '日の', $diary_name, ' その', $atcl_num, ']')" />
<xsl:template name="header">
	<div id="title">
		<h1><xsl:value-of select="concat($year, '年', $month_num, '月の', $diary_name)" /></h1>
	</div>
</xsl:template>

<xsl:template match="d">
	<xsl:if test="@day = $day">
		<div class="section">
			<xsl:attribute name="id">
				<xsl:value-of select="concat('D', @day)" />
			</xsl:attribute>
			<h2>
				<xsl:value-of select="concat($month_num, '月', $day_num, '日')" />
			</h2>
			<xsl:apply-templates select="atcl[position()=$atcl]" />
		</div>
	</xsl:if>
</xsl:template>


<xsl:template match="ttl">
	<h3><a>
		<xsl:attribute name="href">
			<xsl:number count="atcl" format="a" />
		</xsl:attribute>
		<xsl:value-of select="." />
	</a></h3>
</xsl:template>

<xsl:template match="atcl">
	<div class="subsection">
		<xsl:attribute name="id">
			<xsl:choose>
				<xsl:when test="../../../@year &lt; 2004">
					<xsl:value-of select="concat('d', ../@day, '-')" />
					<xsl:number count="atcl" format="1" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>A</xsl:text>
					<xsl:number count="atcl" format="01" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:attribute>
		<xsl:apply-templates />
		<xsl:call-template name="follow-up">
			<xsl:with-param name="key">
				<xsl:value-of select="concat($year,$month,$day)" />
				<xsl:number count="atcl" format="a" />
			</xsl:with-param>
		</xsl:call-template>
		<xsl:if test="string(@genre)">
			<xsl:call-template name="diary_genre">
				<xsl:with-param name="depth" select="$depth" />
				<xsl:with-param name="genre" select="@genre" />
			</xsl:call-template>
		</xsl:if>
	</div>
</xsl:template>

<xsl:template name="head">
	<xsl:call-template name="header_basic" />
	<meta name="Robots" content="INDEX,FOLLOW" />
	<link rel="up" href="../" title="{$up_name}" />
	<xsl:if test="$prev_atcl">
		<link rel="prev" href="{$prev_atcl_path}" title="{$prev_atcl_name} [{$prev_atcl_date}]" />
	</xsl:if>
	<xsl:if test="$next_atcl">
		<link rel="next" href="{$next_atcl_path}" title="{$next_atcl_name} [{$next_atcl_date}]" />
	</xsl:if>
	<xsl:call-template name="stylesheets" />
	<title>
		<xsl:value-of select="$title" />
	</title>
</xsl:template>

<xsl:template name="guide">
	<ul>
		<li class="start"><a rel="home" href="{$depth}/">最新の日記</a></li>
		<li class="up"><a rel="up" href="./"><xsl:value-of select="substring-before($up_name, 'の')" /></a></li>
		<xsl:if test="$prev_atcl">
			<li class="prev"><a rel="prev" href="{$prev_atcl_path}"><xsl:value-of select="$prev_atcl_name" /></a></li>
		</xsl:if>
		<xsl:if test="$next_atcl">
			<li class="next"><a rel="next" href="{$next_atcl_path}"><xsl:value-of select="$next_atcl_name" /></a></li>
		</xsl:if>
		<li class="log"><a rel="index" href="../../">日付別一覧</a></li>
		<li class="log"><a rel="index" href="../../../genre/">種類別一覧</a></li>
		<li class="search"><a rel="search" href="{$depth}{$search_path}">サイト内検索</a></li>
	</ul>
</xsl:template>

<xsl:template name="update">
	<xsl:value-of select="//update" />
</xsl:template>

<xsl:template name="access_analysis">
	<xsl:comment>
		<xsl:value-of select="concat('#include virtual=&quot;', $depth, $count_path, '?LOG=d', substring(/diary/@year,3,2), /diary/@month, '&quot;')" />
	</xsl:comment>
</xsl:template>

<xsl:variable name="up_name">
	<xsl:value-of select="concat($year, '年', $month_num, '月', $day_num, '日の', $diary_name)" />
</xsl:variable>

<xsl:template name="follow-up">
	<xsl:param name="key" />
	<xsl:variable name="notice">メッセージはここに</xsl:variable>
	<div class="follow-up" id="ct{$key}">
		<h4>このアーティクルへのフォローアップ</h4>
		<xsl:comment><xsl:value-of select="concat('#include virtual=&quot;',$depth,$comment_path,'/',$key,'.html&quot;')" /></xsl:comment>
		<!--HTML化するログは10程度に抑えて、それ以上はview.phpを参照させる-->
		<fieldset>
			<legend>書き込む</legend>
			<form method="post" action="{$depth}/comment?key={$key}">
				<dl id="comment_form">
					<dt>名前</dt>
					<dd><input name="name" size="45" value="" /></dd>
					<dt>本文</dt>
					<dd><textarea name="body" cols="45" rows="3" onfocus="if(this.value=='{$notice}')this.value='';" onblur="if(this.value=='')this.value='{$notice}';"><xsl:value-of select="$notice" /></textarea></dd>
					<dt>ボタン</dt>
					<dd><input type="submit" name="submit" value="書き込む" /></dd>
				</dl>
			</form>
		</fieldset>
	</div>
</xsl:template>

<!--注意: タグ不可、実体参照有効、URLは自動でリンク、"&gt;&gt;数字"でそのレスへのリンク、"&gt; "で引用。段落の変わり目以外の改行無用-->

</xsl:stylesheet>
