	[% IF user %]
	[% PROCESS "user_tags.html" %]
	[% END %]

	[% IF tags.size %]
	<div class='taglist related'>
	<h3>related tags</h3>
	<h4>add to query</h4>
	[% FOREACH tag = related_tags %]
	<div class='tag'>
	<span class='tag_count'>[% tag.1 %]</span>
	&nbsp;
	<a class='plus' href='[% uri.entries(user => user, tags => tags.keys.merge([tag.0]) ) %]'>
    [% tag.0 %]
  </a>
	&nbsp;
	</div>
	[% END %]
	<br />
	<h4>remove</h4>
	[% FOREACH tag = tags.keys %]
	<div class='tag'>
	<span class='tag_count'>&nbsp;</span>
	&nbsp;
	<a class='plus' href='[% uri.entries(user => user, tags => remove(tag, tags.keys)) %]'>[% tag %]</a>
	&nbsp;</div>
	[% END %]
  <br />
  [% IF (user && (user == current_user)) %]
  <h4><a href='[% uri.entries(tags => tags) %]'>for all users</a></h4>
  [% ELSE %]
  <h4><a href='[% uri.entries(user => current_user, tags => tags) %]'>for you</a></h4>
  [% END %]
	</div>
	[% END %]

	[% IF recent_tags.size %]
	<div class='taglist recent'>
	<h3>recent tags</h3>
	[% FOREACH tag = recent_tags %]
	<div class='tag'>
		<span class='tag_count'>[% tag.1 %]</span>
		&nbsp;
		<a href='[% uri.entries(tags => [ tag.0 ]) %]'>[% tag.0 %]</a>
		&nbsp;
	</div>
	[% END %]
	</div>
	[% END %]

	<div class='search'>
		<span>search:</span>
		<form action='[% self_url %]' style='display:inline'>
      [% widget.input(name => 'like', attr => { size => 60 }) %]
		</form>
	</div>

	<h2 class='query'>[% query_description %]</h2>
	<div class='rss'><a href='[% uri.entries(user => user, tags => tags, has_link => has_link, has_body => has_body, format => "rss" ) %]'>RSS</a> available
	for this query</div>
	<div class='expandcollapse'><a href='?long_form=[% long_form ? 0 : 1 %]&page=[%page%]'>[%
	long_form ? "collapse" : "expand"
	%]</a> entry bodies</div>
	<div class='entries'>
	[% IF entries.count %]
		[% WHILE (entry = entries.next) %]
		[% IF long_form %]
		[% PROCESS "entry_long.html" %]
		[% ELSE %]
		[% PROCESS "entry.html" %]
		[% END %]
		[% END %]
	[% ELSE %]
		<h3>no results for this query</h3>
	[% END %]
	</div>

	[% PROCESS "page_data.html" %]
