extends vibenews.web.layout

block title
	- import vibe.textfilter.markdown;
	- import vibe.textfilter.html;
	- import std.string : indexOf;

	- title = info.thread.subject;

	- string obfuscateEmail(string email)
		- auto idx = email.indexOf('@');
		- if( idx < 0 ) return email;
		- return email[0 .. idx] ~ " /at/ " ~ email[idx+1 .. $];

block vibenews.navigation
	- import vibenews.webstrings;
	ul
		li
			a(href="../../../../")= forumIndexNavCaption
		li
			a(href="../../")= info.group.caption
		li
			a(href="./")= info.thread.subject

block vibenews.body
	include vibenews.inc.gravatar

	- void pageLinks()
		- if( info.pageCount > 1 )
			p.pages Pages: 
				- bool last = true;
				- foreach( i; 0 .. info.pageCount )
					- if( i > 3 && i+4 < info.pageCount && (i+4 < info.page || i > info.page+4) )
						- last = false;
						- continue;
					- if( !last )
						| â€¦
						- last = true;
					- if( info.page == i )
						span.active-page= i+1
					- else
						a.page(href="?page=#{i+1}")= i+1
					|  

	- pageLinks();

	- foreach( i, post; info.posts )
		a(id='post-#{post.number}')
		.post(class='#{i==0?"first odd":i%2==0?"odd":"even"}')
			.post-header
				h2.skeleton= post.subject
				.permalink Permalink: 
					a(href="../../post/#{post.number}") HTTP
					a(href="nntp://#{info.settings.hostName}/#{info.group.name}/#{post.number}") NNTP
			.post-body
				.post-info
					- mixinAvatarImage(post.poster.email, 120, false);
					
					.poster-name
						a(href="mailto:#{obfuscateEmail(post.poster.email)}")= post.poster.name
					
					.posting-info Posted #{post.date}
						- if (post.repliedToPoster.email.length)
							|  in reply to #[a(href="../../post/#{post.repliedToPostNumber}")= post.repliedToPoster.name]
					a.reply-link.link-button(href="../../../post?group=#{info.group.name}&amp;thread=#{info.thread.firstPost.number}&amp;reply-to=#{post.number}") Reply
				.post-content
					!= filterMarkdown(post.message, MarkdownFlags.forumDefault)

	- pageLinks();
