extends vibelog.blocks

block vibelog.title
	- title = "All posts";

block vibelog-content
	- import vibe.inet.message;
	#vibelogContent
		- if (info.loginError.length)
			.error= info.loginError

		#vibelogPostList
			- foreach( i, post; info.posts )
				.blogMultiPost
					.blogPost
						header
							- if (post.headerImage.length && info.settings.placePostHeaderImageFirst)
								img.headerImage(alt="Header image", src="#{post.headerImage}")
							h2
								a(href="posts/#{post.name}")= post.header
							.blogPostHeaderContent
								- if (post.headerImage.length && !info.settings.placePostHeaderImageFirst)
									img.headerImage(alt="Header image", src="#{post.headerImage}")
								.blogPostHeaderText(class='#{post.headerImage.length ? "with-image" : "without-image"}')
									- import vibe.inet.message : toRFC822DateString;
									span.blogPostDate= toRFC822DateString(post.date)
									| #{post.subHeader}
									- if (!info.settings.showFullPostsInPostList && info.settings.inlineReadMoreButton)
										a(href="posts/#{post.name}#trackback") Read more…
						- if (info.settings.showFullPostsInPostList)
							.blogPostContent(class='#{post.headerImage.length ? "with-image" : "without-image"}')
								!= post.renderContentAsHtml(info.settings, info.refPath, 2)
							footer
								- import vibe.inet.message : toRFC822TimeString;
								| Posted at #{toRFC822TimeString(post.date)} by #{post.author in info.users ? info.users[post.author].name : post.author}
								|  #[a(href="posts/#{post.name}#comments") #{info.commentCount[i]} comments]
								- if (post.trackbacks.length > 0)
									|  #[a(href="posts/#{post.name}#trackback") #{post.trackbacks.length} trackbacks]
						- else if (!info.settings.inlineReadMoreButton)
							a(href="posts/#{post.name}#trackback") Read more…

		.pageNumbers
			p Pages:
				- foreach( p; 0 .. info.pageCount )
					- if( p == info.pageNumber )
						em  #{p+1}
					- else
						|  #[a(href="?page=#{p+1}") #{p+1}]

block vibelog-recent-list
	include vibelog.inc.postlist
	- insertVibelogPostList();
