extends vibenews.web.layout

block title
	- import vibe.textfilter.urlencode;

	- title = info.group.caption;

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

block vibenews.body
	include vibenews.inc.gravatar

	p
		a.link-button(href="../post?group=#{info.group.name}") Post new topic

	- 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();

	table.overview.thread-overview
		col.topic
		col.num-answers
		col.last-post
		tr
			th.topic Topic
			th.num-answers Replies
			th.last-post Last reply
		- foreach (ti, thr; info.threads)
			tr(class=ti % 2 ? "odd" : "even")
				td.topic
					- if (info.settings.showOverviewAvatars)
						- mixinAvatarImage(thr.firstPost.poster.email, 32);
					.primary
						a.title(href="thread/#{thr.firstPost.number}/")= thr.subject
					.secondary
						| by 
						a(href=profileLink(thr.firstPost.poster.email))= thr.firstPost.poster.name
						|  on #{thr.firstPost.date}
					- if( thr.pageCount > 1 )
						span.pages Pages: 
							- bool last = true;
							- foreach( i; 0 .. thr.pageCount )
								- if( i > 4 && i+5 < thr.pageCount )
									- last = false;
									- continue;
								- if( !last )
									| …
									- last = true;
								a.page(href="thread/#{thr.firstPost.number}/?page=#{i+1}")= i+1
				td.num-answers= thr.postCount-1
				td.last-post
					- if (thr.lastPost.number > thr.firstPost.number)
						- if (info.settings.showLastPostAvatars)
							- mixinAvatarImage(thr.lastPost.poster.email, 32);
						.primary
							a(href="post/#{thr.lastPost.number}")= thr.lastPost.subject.length ? thr.lastPost.subject : "(no subject)"
						.secondary
							| by 
							a(href=profileLink(thr.lastPost.poster.email))= thr.lastPost.poster.name
							|  on #{thr.lastPost.date}
					
	- pageLinks();
