{{ define "title" }}Recent Comments{{ end }}
{{ define "content" }}

<h1>Recent Comments</h1>

{{ with .V.PagedComments }}
	{{ range .Comments }}
		{{ if gt .PostID 0 }}
			<div class="alert alert-info">
				<strong>In post <a href="{{ .Post.Fragment }}">{{ or .Post.Title "Untitled" }}</a>:</strong>
			</div>
		{{ else if .OriginURL }}
			<div class="alert alert-info">
				<strong>On page <a href="{{ .OriginURL }}">{{ .OriginURL }}</a>:</strong>
			</div>
		{{ end }}

		{{ RenderComment $.ResponseWriter $.Request . "/comments" false }}
	{{ end }}

	<div class="alert alert-success">
		Page {{ .Page }} of {{ .Pages }} ({{ .Total }} total)
		{{ if or (gt .PreviousPage 0) (gt .NextPage 0) }}
		[
			{{ if gt .NextPage 0 }}
				<a href="/comments?page={{ .NextPage }}&per_page={{ .PerPage }}">Older</a>
				{{ if gt .PreviousPage 0 }} | {{ end }}
			{{ end }}
			{{ if gt .PreviousPage 0 }}
				<a href="/comments?page={{ .PreviousPage }}&per_page={{ .PerPage }}">Newer</a>
			{{ end }}
		]
		{{ end }}
	</div>
{{ end }}

{{ end }}
